|
|
|
|
|
|
bool frustumCulled = WorldViewFrustumCull(p0, p1, p2, maxDisplacement, (float4[4])unity_CameraWorldClipPlanes); |
|
|
|
|
|
|
|
bool faceCull = false; |
|
|
|
|
|
|
|
// We use the position of the primary (scene view) camera in order |
|
|
|
// to have identical tessellation levels for both the scene view and |
|
|
|
// shadow views. Otherwise, depth comparisons become meaningless! |
|
|
|
float3 camPosWS = _WorldSpaceCameraPos; |
|
|
|
|
|
|
|
faceCull = BackFaceCullTriangle(p0, p1, p2, _TessellationBackFaceCullEpsilon, GetCurrentCameraPosition()); |
|
|
|
faceCull = BackFaceCullTriangle(p0, p1, p2, _TessellationBackFaceCullEpsilon, camPosWS); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
// Distance based tessellation |
|
|
|
if (_TessellationFactorMaxDistance > 0.0) |
|
|
|
{ |
|
|
|
float3 distFactor = GetDistanceBasedTessFactor(p0, p1, p2, GetCurrentCameraPosition(), _TessellationFactorMinDistance, _TessellationFactorMaxDistance); |
|
|
|
float3 distFactor = GetDistanceBasedTessFactor(p0, p1, p2, camPosWS, _TessellationFactorMinDistance, _TessellationFactorMaxDistance); |
|
|
|
// We square the disance factor as it allow a better percptual descrease of vertex density. |
|
|
|
tessFactor *= distFactor * distFactor; |
|
|
|
} |
|
|
|
|
|
|
#else |
|
|
|
float2(0.0, 0.0), |
|
|
|
#endif |
|
|
|
input.positionWS, |
|
|
|
input.positionWS, |
|
|
|
input.normalWS, |
|
|
|
layerTexCoord); |
|
|
|
|
|
|
|