Graphics Reference
In-Depth Information
The simTime variable is a System.Diagnostics.Stopwatch
instance that has the P key mapped to pause/unpause the simulation
in the completed sample.
4.
Next, add the SubdividedPlane.fbx to your project, set the Build Action to
MeshContentTask, and load it into a MeshRenderer instance. Alternatively,
if you are using the tessellation pipeline, create a quad with a width (X-axis)
and depth (Z-axis) of around 24 units and a tessellation factor in the range
of approximately 10.0 to 20.0.
var loadedMesh =
Common.Mesh.LoadFromFile("SubdividedPlane.cmo");
var waterMesh = ToDispose(new
MeshRenderer(loadedMesh.First()));
waterMesh.Initialize(this);
Now, we can update the vertex shader to implement the displacement. If you
are using the tessellation pipeline, the same changes will be made to your
domain shader instead.
5. First, we will add a new HLSL function to our vertex shader file in order to
generate the waveform.
void GerstnerWaveTessendorf(
float waveLength,
float speed,
float amplitude,
float steepness,
float2 direction,
in float3 position,
inout float3 result,
inout float3 normal,
inout float3 tangent)
{
...SNIP see next steps
}
6.
Within the preceding function, we will initialize the values for the Gerstner formula
as follows:
float L = waveLength;// wave crest to crest
float A = amplitude; // wave height
float k = 2.0 * 3.1416 / L; // wave length
float kA = k*A;
float2 D = normalize(direction); // normalized direction
 
Search WWH ::




Custom Search