Graphics Reference
In-Depth Information
result.EdgeTessFactor[2] = 0;
result.InsideTessFactor = 0;
return result; // culled, so no further processing
}
// end: backface culling
...SNIP rest of function excluded from listing
3.
Running the project and switching to wireframe (the F key in the provided code)
will show that the back-facing triangles are no longer rendered. The following
screenshot shows the output.
The sample project has disabled back-face culling within the rasterizer state
( RasterizerStateDescription.CullMode = CullMode.None ),
so that this can be tested correctly.
Back-face culling using vertex normal vectors
Consider the following steps:
1.
Comment out or remove the previous code for back-face culling based
on the face normal, and include the following code instead:
...SNIP
HS_TrianglePatchConstant result = (HS_TrianglePatchConstant)0;
// Backface culling - using Vertex normals
bool backFacing = true; // default to cull
[unroll]
for (uint j = 0; j < 3; j++)
{
// Create view vector
float3 view = normalize(CameraPosition -
patch[j].WorldPosition);
float a = dot(view, patch[j].WorldNormal);
if (a >= -0.125) {
backFacing = false; // do not cull patch
}
}
if (backFacing) {
result.EdgeTessFactor[0] = 0;
result.EdgeTessFactor[1] = 0;
result.EdgeTessFactor[2] = 0;
result.InsideTessFactor = 0;
 
Search WWH ::




Custom Search