Graphics Reference
In-Depth Information
2.
The common domain shader input structure is as follows:
// Max 32 outputs
struct DS_ControlPointInput {
float3 Position : BEZIERPOS;
float4 Diffuse : COLOR0;
};
8.
With the prerequisites in place, let us create a new vertex shader for use with the
tessellation pipeline.
1.
With VS.hlsl open, add a new include directive:
#include "CommonTess.hlsl"
2.
Create a copy of your existing vertex shader function and name
it as VSPassThruTessellate . Then, change the return type to
HullShaderInput .
9.
Update the vertex shader to set the four properties of the preceding
HullShaderInput structure. We will continue to apply the PerObject.World
transform to the position and normal variables.
How it works…
As the domain shader will now be performing the multiplication of the position by the
ViewProjection matrix and it is easier to work with the vertices in world space, we need
to ensure our per object structures in Common.hlsl and ConstantBuffers.cs include a
copy of our ViewProjection matrix to take the position from world space to view/projection
space (or clip space).
The vertex shader now simply passes through the vertex attributes within world space to be
processed by the hull and domain shaders.
Tessellating a triangle and quad
In this recipe, we will perform tessellation upon a triangle and a quad patch. We will create
the hull and domain shaders that are necessary to use the triangle and quad tessellation
domains, respectively.
As the fixed function tessellation stage is used to define new vertices, it is necessary
to move some of the vertex shader code into the applicable domain shader, such as
applying the ViewProjection matrix and calculating the interpolated vertex normal
and texture coordinates.
 
Search WWH ::




Custom Search