Sweet Canyon Mesas

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:




1. 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 parameters like following in the dialog appears:

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

Launch Awakening, 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:



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.



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 the 1st texture with decalmap.bmp, and the 2nd texture with normalmap.tga; load 'scattering\ScatteringTer.fx' 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 'scattering\ScatteringSky.fx' to D3D Effect; then assign this material to the sky mesh.

Now your scene should looks like below image:




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'.




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:

require 'scripts\\Scattering\\Sun'
require 'scripts\\Scattering\\Atmosphere'

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

2). In FrameMove() function, add below codes:


local vsundir=sunlight.getPosition()

if (vsundir.z>0) then -- assume your sun light circles x-axis

OK, we've finished it. Select the Shot 'runs' and play the scene, you'll see the landscape.