Graphics Reference
In-Depth Information
Optimizing tessellation based on
displacement decal (displacement
adaptive tessellation)
By modifying our hull shader constant function, we can easily modify the tessellation factor
based on whether or not a decal is located within the vicinity of a patch. This is also known
as displacement adaptive tessellation.
Getting ready
Within the completed sample available for download in Implementing displacement decals ,
there is an additional function in Shaders\CommonDecal.hlsl that adds the provided
tessellation factor to the appropriate edges and inside tessellation factors depending on
whether the decal position and radius would impact the current patch.
void DecalTessellationFactor(float3 p[3], inout float3 edgeTessFactor,
inout float insideTessFactor, float tessellation)
How to do it…
To apply displacement adaptive tessellation to the triangle tessellation hull shader perform
the following steps:
1.
Update the triangle hull shader constant function HS_TrianglesConstant with the
following highlighted changes:
...SNIP
ProcessTriTessFactorsMax((float3)TessellationFactor, 1.0,
roundedEdgeTessFactor, roundedInsideTessFactor, insideTessFactor);
float3 p[3];
[unroll]
for (uint j = 0; j < 3; j++)
p[j] = patch[j].WorldPosition;
// Increase tessellation by 10 if decal
DecalTessellationFactor(p, roundedEdgeTessFactor,
roundedInsideTessFactor, 10);
// 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;
...SNIP
 
Search WWH ::




Custom Search