Graphics Reference
In-Depth Information
9.
Next, we will add the patch constant function, which will be executed only once
for each patch; this is the same function used by each of the hull shaders and is
referenced in the hull shader with the patchconstantfunc attribute.
// Triangle patch constant function
// (executes once for each triangle patch)
HS_TrianglePatchConstant HS_TrianglesConstant(
InputPatch<HullShaderInput, 3> patch)
{
HS_TrianglePatchConstant result =
(HS_TrianglePatchConstant)0;
// Determine the rounded tess factor
float3 roundedEdgeTessFactor;
float roundedInsideTessFactor, insideTessFactor;
ProcessTriTessFactorsMax((float3)TessellationFactor,
1.0, roundedEdgeTessFactor, roundedInsideTessFactor,
insideTessFactor);
// Apply the edge and inside tessellation factors
result.EdgeTessFactor[0] = roundedEdgeTessFactor.x;
result.EdgeTessFactor[1] = roundedEdgeTessFactor.y;
result.EdgeTessFactor[2] = roundedEdgeTessFactor.z;
result.InsideTessFactor = roundedInsideTessFactor;
// Apply constant information
[unroll]
for (uint i = 0; i < 3; i++)
{
result.TextureUV[i] = patch[i].TextureUV;
result.WorldNormal[i] = patch[i].WorldNormal;
}
return result;
}
10. Next, we will add the domain shader. This shader performs the necessary
barycentric interpolation, and then returns the pixel shader input structure. The final
transformation to clip space with the view/projection matrix is also performed here:
// This domain shader applies control point weighting to
// the barycentric coords produced by the fixed function
// tessellator stage
[domain("tri")]
 
Search WWH ::




Custom Search