Register  |  FAQ  |  Search  |  Memberlist  |  Usergroups  |  Log in 
Reply to topic
 Sweet Canyon Mesas 
Vincent


Joined: 25 Dec 2006
Posts: 296
Reply with quote


In this tutorial, we'll create a sweet canyon mesas scene use Awakening's atmosphere & terrain rendering system.

You need first install below softwares before starting:

*Awakeing2.5 with Extension Package
*World Machine
*Adobe PhotoShop ( you can use other image processing software if only it can produce normal map from height map )
*Nvidia's Photoshop .dds Plug-in
View user's profile Send private message
 Part 1 : Modeling 
Vincent


Joined: 25 Dec 2006
Posts: 296
Reply with quote
Launch World Machine 1.25, open the scene: "World Machine\Examples\Basic Edition Examples\Sweet Canyon Mesas.tmd". Press Ctrl+1 switch to Device View, select the File Output device, the press Ctrl+3 switch to 3D View, you should see a sweet canyon terrain.
Select World Commands > Wolrd Size... from menu, set parameters like following in the dialog appears:



Press OK button, you'll see below terrain in 3D View:



Now we've finished terrain modeling in World Machine, let's output the mesh data. Press Ctrl+1 switch to Device View again, double-click the File Output device, set paramters like following in the dialog appears:



then press the Write output to disk! button. Ok, the terrain mesh data has been saved to the "Awakening2.5\models\output.ter" file.

Launch Awakening 2.5, select File > Import... from menu, a Open File Dialog appears. Select Terragen Terrain Files (*.ter) in Files Type List, then select the output.ter file we've just saved, click Open button, you should see terrain in Awakening now:



Last edited by Vincent on Sat Feb 16, 2008 1:51 am; edited 2 times in total
View user's profile Send private message
 Part 2 : Textures 
Vincent


Joined: 25 Dec 2006
Posts: 296
Reply with quote
Back to World Machine, open the Wolrd Size dialog again, set Size to 512 x 512, see below image:



Close this dialog, then press Ctrl+2 switch to 2D View, click the Height button under the Terrain Preview Window:



You should see below image in 2D View:



Select File > Save Viewport As Image... from menu, save as decalmap.bmp (if this command sometime does not work, try to switch 3D view then back to 2D view), so the decalmap.bmp is our terrain's decal texture.

Again, under the Terrain Preview Window, click the Set Terrain Color... button, select the Greyscale color method in the Colortable Selector Dialog appears; the 2D view should like this:



save the viewport to heightmap.bmp.

Launch Adobe PhotoShop (please ensure Nvidia's dds plugin has been installed), load the heightmap.bmp, then select Filter > NVIDIA Tools > NormalMapFilter... from menu, in the dialog appears, set Scale to 8, then click OK button, the image should like following pattern:



save this image to normalmap.tga, it is terrain's normal map texture.

Now only the horizon map left to do, exact horizon map making is somewhat complex. Here, we use a simple method to approach.
In World Machine, switch to 2D View, click the Shader button under the Terrain Preview Window (TPW); then move mouse cursor to the center of TPW's top edge, press & hold mouse's left-button to do a slight dragging, the action will change sun light direction for terrain. The 2D View should like below:



Save the viewport to image and open it in Photoshop, select Image > Adjustments > Brightness/Contrast... from menu, in the dialog appears, set Brightness to +100, and Contrast to +50, the image should like this after adjustment:



OK, store this pseudo horizon map to the normalmap.tga's alpha channel.

This horizon map only for 0~90 degree sun angles; for 90~180 degree angles, we need another horizon map. First dragging mouse cursor at the center of TPW' bottom edge, then take the viewport image do same Brightness/Contrast adjustment as above, then combine with normal map and save to normalmap2.tga.

So we have two normal map textures, they have same RGB data, but Alpha data are two different horizon map.
View user's profile Send private message
 Part 3: Materials 
Vincent


Joined: 25 Dec 2006
Posts: 296
Reply with quote
Back to Awakening, we've already imported the terrain mesh. The terrain's Dimension is [21720, 6180, 21720] (check this in mesh's Properties Panel), it's too big for the Scattering Shader, so scale the mesh by [0.4,0.2,0.4], get a suitable terrain size for shader's default setting; and set terrain's position to [0,0,0].
(you also can adjust shader's parameters to fit terrain size, but scaling terrain is more easy)

Add textures (decalmap.bmp,normalmap.tga,normalmap2.tga) to scene. Then new a material named 'terrain'; set Texture0 with decalmap.bmp, and Texture1 with normalmap.tga; load 'Scattering.sha' to D3D Effect; then assign this material to the terrain mesh.

Create a Static Mesh by loading 'sphere.TRI', and scale it with [150,150,150], rotate it with [90,0,0], this is sky mesh. New a material named 'sky', load 'ScatteringSky.sha' to D3D Effect; then assign this material to the sky mesh.

Now your scene should looks like below image:



Last edited by Vincent on Sat Feb 16, 2008 2:22 am; edited 2 times in total
View user's profile Send private message
 Part 4: Animation 
Vincent


Joined: 25 Dec 2006
Posts: 296
Reply with quote
Create a Shot named 'runs', set it's time length to 120, and check Circle and Not Effect Camera styles.
Create a light named 'sunlight', set keys on time 0, 30, 60, 90, 120 respectively, below are light's parameters for every key:

time 0: position=[0,0,5000] color=[118,55,50]
time 30: position=[0,5000,0] color=[255,255,255]
time 60: position=[0,0,-5000] color=[111,73,57]
time 90: position=[0,-5000,0] color=[50,53,80]
time 120: position=[0,0,5000] color=[118,55,50]

Now in the light's controller list, right-click on the Position controller, select Assign Controller > Spline (continuous) from the contex menu; this make the light has a round trajectory.

So the 'sun' can run now, but Shader can not 'see' the 'sun' itself. In the next part, we'll write script to tell Shader necessary information about the 'sun'.
View user's profile Send private message
 Part 5: Scripting 
Vincent


Joined: 25 Dec 2006
Posts: 296
Reply with quote
We first need define script variables in Awakening:



here, terrain_nh.tga = normalmap.tga, terrain_nh2.tga = normalmap2.tga

Save our scene to disk, then you can edit scene's User Script File by selecting View > Edit User Script File... from menu.
In the User Script File:

1). Add below codes to the beginning:
Code:
require 'scripts\\Scattering_Sun'
require 'scripts\\Scattering_Atmosphere'

local materlist={sky,terrain}
local sun=Sun.new( materlist )
local atmo=Atmosphere.new( materlist )


2). In FrameMove() function, add below codes:
Code:
sun.setEye(camera.getPosition())
sun.setColor(sunlight.getDiffuse())
sun.setIntensity(40)

local vsundir=sunlight.getPosition()
vsundir.normalize()
sun.setDirection(-vsundir,-vec.new(-vsundir.x,vsundir.y,-vsundir.z))

if (vsundir.z>0) then -- assume your sun light circles x-axis
      terrain.setTexture(1,terrain_nh_tga)
else
     terrain.setTexture(1,terrain_nh2_tga)
end


OK, we've finished it. Select the Shot 'runs' and play the scene, you'll see the landscape.
View user's profile Send private message
  
matty47


Joined: 27 Nov 2007
Posts: 21
Reply with quote
Hi, I tried to follow the tutorial. I exported the .ter file with a 128 x 128 resolution however when I tried to import it into Awakening 2.5 I got an error message saying that there were more than 65536 vertices and that the result may be incirrect (which it was - distortion of the mesh and additional faces). I tried a 64 x 64 world size and had no problems. Any ideas?
Thanks
Matthew
View user's profile Send private message
  
Vincent


Joined: 25 Dec 2006
Posts: 296
Reply with quote
A 128 x 128 terrain mesh should has 16641 vertices. The problem maybe is output path. I've modified Part 1 of this tutorial: select output file to a explicit path: "C:\Awakening2.5\models\output.ter". Try again.
View user's profile Send private message
  
matty47


Joined: 27 Nov 2007
Posts: 21
Reply with quote
You are correct! ( and if I had bothered to do the math I should have known the number of vertices!!! - sorry)
Thanks for clearing up the path thing though
Matthew
View user's profile Send private message
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic