Graphics Reference
In-Depth Information
[outputtopology("triangle_ccw")] // order of the tris
[ outputcontrolpoints(4) ] // Number of times called for patch
// The constant hull shader function
[patchconstantfunc("HS_QuadsConstant")] DS_ControlPointInput HS_
QuadsInteger(
InputPatch<HullShaderInput, 4> 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;
}
13. Now, add the quad patch constant function. Here, the changes from the triangle
tessellator are highlighted:
HS_QuadPatchConstant HS_QuadsConstant(
InputPatch<HullShaderInput, 4> patch)
{
HS_QuadPatchConstant result = (HS_QuadPatchConstant)0;
// Perform rounding
float4 roundedEdgeTessFactor;
float2 roundedInsideTessFactor, insideTessFactor;
Process2DQuadTessFactorsMax ( (float4) 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.EdgeTessFactor[3] = roundedEdgeTessFactor.w;
result.InsideTessFactor[0] = roundedInsideTessFactor.x;
result.InsideTessFactor[1] = roundedInsideTessFactor.y;
// Apply constant information
[unroll]
for (uint i = 0; i < 4; i++)
{
result.TextureUV[i] = patch[i].TextureUV;
result.WorldNormal[i] = patch[i].WorldNormal;
}
return result;
}
 
Search WWH ::




Custom Search