I am now at step 10 of Riemers advanced terrain tutorial. Instead of using complex wave mathematics, Riemer uses a bump map. A bump map contains normal vectors in the
Step 11 works in the refraction map created earlier into the scene. Based on the angle of camera and the normal, the amount of reflection and refraction is adjusted. This is called a Fresnel term, and is calculated using the dot product of the two vectors. In addition, this step adds a bit of dullness to the output to make the water surface less shiny.
The next step makes the water move. Again lots of vector and HLSL tricks. Here a new
In step 12, a specular effect is added to the water. As the light shines on the water the water sparkles when the sun is reflected on the surface. This is done by adding to the intensity of the
Trees are added in step 13 using a billboard technique. I created a component called
The next step cleans out some problems with the billboards by drawing non-transparent pixels only. Riemer explains a trick that avoids ordering the trees before drawing them. A downside of billboards becomes clear when the world is viewed from the top.
The second last step is about creating perlin noise. Almost the work is done in HLSL. I placed this into a new component called
The final step is subtle but adds a lot to the realism. Here this sky gradient is changed in HLSL so that the sky on the bottom of the horizon is lighter than the sky on the top.
Now, its done, the terrain tutorials are great. I now have a collection of components to use in my own terrain. I published this work on Game Projects.
RGB
of each pixel. Using new inputs to the HLSL effect, waveLength
and waveHeight
, the pixels in the mirror is perturbed with the pixels in the bump map.Step 11 works in the refraction map created earlier into the scene. Based on the angle of camera and the normal, the amount of reflection and refraction is adjusted. This is called a Fresnel term, and is calculated using the dot product of the two vectors. In addition, this step adds a bit of dullness to the output to make the water surface less shiny.
The next step makes the water move. Again lots of vector and HLSL tricks. Here a new
xTime
parameter is added to the parameters. Together with a parameters that shows the wind direction, the chosen coordinates in the bump map changes. I created a component called Environment
to keep these aspects. This component updates the parameters in the effect when it draws.In step 12, a specular effect is added to the water. As the light shines on the water the water sparkles when the sun is reflected on the surface. This is done by adding to the intensity of the
RGB
components on the pixel shader.Trees are added in step 13 using a billboard technique. I created a component called
BilboardTrees
to make this work. I had to make the vertexes of the terrain a public property for the billboard trees to be placed on the terrain.The next step cleans out some problems with the billboards by drawing non-transparent pixels only. Riemer explains a trick that avoids ordering the trees before drawing them. A downside of billboards becomes clear when the world is viewed from the top.
The second last step is about creating perlin noise. Almost the work is done in HLSL. I placed this into a new component called
PerlinNoise
. This component generates a texture that contains perlin noise. The noise gradually shifts as time passes -- making clouds that change over time. Very cool!The final step is subtle but adds a lot to the realism. Here this sky gradient is changed in HLSL so that the sky on the bottom of the horizon is lighter than the sky on the top.
Now, its done, the terrain tutorials are great. I now have a collection of components to use in my own terrain. I published this work on Game Projects.
(Edit: Please note that there has been additional improvements on the published code that might be of interest to you. Read all about it on this blog entry).
No comments:
Post a Comment