|
|
|
|
|
|
// TODO: Handle inverse culling (for mirror)! |
|
|
|
if (_TessellationBackFaceCullEpsilon > -0.99) // Is backface culling enabled ? |
|
|
|
{ |
|
|
|
faceCull = BackFaceCullTriangle(p0, p1, p2, _TessellationBackFaceCullEpsilon, _WorldSpaceCameraPos); |
|
|
|
faceCull = BackFaceCullTriangle(p0, p1, p2, _TessellationBackFaceCullEpsilon, GetCurrentCameraPosition()); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
// Distance based tessellation |
|
|
|
if (_TessellationFactorMaxDistance > 0.0) |
|
|
|
{ |
|
|
|
float3 distFactor = GetDistanceBasedTessFactor(p0, p1, p2, _WorldSpaceCameraPos, _TessellationFactorMinDistance, _TessellationFactorMaxDistance); |
|
|
|
float3 distFactor = GetDistanceBasedTessFactor(p0, p1, p2, GetCurrentCameraPosition(), _TessellationFactorMinDistance, _TessellationFactorMaxDistance); |
|
|
|
// We square the disance factor as it allow a better percptual descrease of vertex density. |
|
|
|
tessFactor *= distFactor * distFactor; |
|
|
|
} |
|
|
|