Graphics Reference
In-Depth Information
GerstnerWaveTessendorf(4, 1, 0.5, 1, direction + float2(0,
1), vertex.Position, waveOffset, N, T);
GerstnerWaveTessendorf(2.5, 2, 0.5, 1, direction +
float2(0, 0.5), vertex.Position, waveOffset, N, T);
GerstnerWaveTessendorf(2, 2, 0.5, 1, direction,
vertex.Position, waveOffset, N, T);
This completes our HLSL shader code.
12. Now, render the mesh within your render loop, and ensure that the correct vertex
shader is assigned (if a new shader has been created, compile it within the
appropriate location).
// If showing normal map
waterMesh.DisableNormalMap = disableNormalMap;
waterMesh.PerMaterialBuffer = perMaterialBuffer;
waterMesh.PerArmatureBuffer = perArmatureBuffer;
waterMesh.Render();
The completed project in the downloadable companion code maps the Backspace
key to switch between the previous physics scene and this recipe. Pressing Shift + N
toggles between the diffuse mapping as well as the diffuse and normal mapping,
and the N key will toggle the display of the debug normal vectors. The final result
of the gentle and choppy waves, is shown in the following diagram:
Multiple Gerstner waves: gentle ocean waves (left), choppy ocean waves (right), wireframe (top) with debug normal
vectors (top-left), diffuse shader (middle), and diffuse + normal mapping (bottom).
 
Search WWH ::




Custom Search