Graphics Reference
In-Depth Information
5. Create a new shader file named Shaders\TessellateTri.hlsl ; this will
contain our triangle tessellation hull shaders, hull shader patch constant function,
and domain shader.
Remember that the file encoding needs to be changed to Western
European (Windows) - Codepage 1252, and select Copy if newer.
6.
Add the following include directives to the start of the code:
#include "Common.hlsl"
#include "CommonTess.hlsl"
7.
For simplicity, we will create four hull shaders, one for each of the available
partitioning methods, HS_TrianglesInteger , HS_TrianglesFractionalOdd ,
HS_TrianglesFractionalEven , and HS_TrianglesPow2 . Each of these
functions is identical, except for the name and the partitioning type attribute applied.
[domain("tri")] // Triangle domain for our shader
[partitioning(" integer ")] // Partitioning type
[outputtopology("triangle_ccw")] // winding order
[outputcontrolpoints(3)] // Number of points for each patch
// The constant hull shader function
[patchconstantfunc("HS_TrianglesConstant")]
DS_ControlPointInput HS_TrianglesInteger (
InputPatch<HullShaderInput, 3> patch,
uint id : SV_OutputControlPointID,
uint patchID : SV_PrimitiveID )
{
DS_ControlPointInput result = (DS_ControlPointInput)0;
result.Position = patch[id].WorldPosition;
result.Diffuse = patch[id].Diffuse;
return result;
}
8.
Here, we have shown the integer partitioning type function; repeat the preceding
step for each of the following partitioning types (substituting the partitioning attribute
and changing the function name accordingly): fractional_odd , fractional_
even , and pow2 .
This could also be achieved by defining a conditional macro, for example:
#define HS_PARTITIONING "integer"
This can also be specified as a parameter to the HLSL compiler when
compiling the shader code.
 
Search WWH ::




Custom Search