Graphics Reference
In-Depth Information
As mentioned in the recipe, Rendering a cube and sphere , in Chapter 3 ,
Rendering Meshes , the ViewProjection matrix should ideally be placed
within the PerFrame constant buffer. Here, for simplicity, we continue to
group the matrices within the PerObject constant buffer.
2. Update the corresponding structure in ConstantBuffers.cs to include public
Matrix ViewProjection ; remember that it also needs to be transposed in the
Transpose method.
3. To reflect the desired tessellation factor, update the perFrame constant buffer in
Common.hlsl to include a new member named float TessellationFactor .
4.
In the corresponding PerFrame structure in the ConstantBuffers.cs file,
we add public float TessellationFactor ; remember to keep in mind
the 16-byte alignment and to match the layout with the HLSL structure.
5.
Jump over to the D3DApp render loop and locate where the perObject.
WorldViewProjection property is set and add the following:
perObject.ViewProjection = viewProjection;
6. Then, find where the perFrame.CameraPosition property is updated and
add the following:
perFrame.TessellationFactor = tessellationFactor;
The tessellationFactor variable is a float value that
is set between 1.0f and 64.0f . The completed sample
maps the + / - keys to increase/decrease the value.
We are now done with the changes to Common.hlsl and the constant buffers.
7.
Next, let's create the Shaders\CommonTess.hlsl file that houses the
common shader structures and functions used by our tessellation shader code.
Now, we will add the following HLSL structures:
1.
The HullShaderInput structure, a subset of the existing vertex structure
input, is as shown in the following code snippet:
struct HullShaderInput
{
float3 WorldPosition : POSITION;
float4 Diffuse : COLOR;
float2 TextureUV: TEXCOORD0;
float3 WorldNormal : TEXCOORD1;
};
 
Search WWH ::




Custom Search