|
|
|
|
|
|
{ |
|
|
|
float maxDisplacement = GetMaxDisplacement(); |
|
|
|
|
|
|
|
#if defined(SHADERPASS) && (SHADERPASS != SHADERPASS_SHADOWS) |
|
|
|
#else |
|
|
|
bool frustumCulled = WorldViewFrustumCull(p0, p1, p2, maxDisplacement, (float4[4])unity_CameraWorldClipPlanes); |
|
|
|
#endif |
|
|
|
// 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 = GetPrimaryCameraPosition(); |
|
|
|
|
|
|
|
faceCull = BackFaceCullTriangle(p0, p1, p2, _TessellationBackFaceCullEpsilon, camPosWS); |
|
|
|
faceCull = BackFaceCullTriangle(p0, p1, p2, _TessellationBackFaceCullEpsilon, GetCurrentViewPosition()); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
return float4(0.0, 0.0, 0.0, 0.0); |
|
|
|
} |
|
|
|
|
|
|
|
// We use the parameters 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! |
|
|
|
// Aaptive screen space tessellation |
|
|
|
// Adaptive screen space tessellation |
|
|
|
tessFactor *= GetScreenSpaceTessFactor( p0, p1, p2, GetWorldToHClipMatrix(), _ScreenParams, _TessellationFactorTriangleSize); |
|
|
|
tessFactor *= GetScreenSpaceTessFactor( p0, p1, p2, _ViewProjMatrix, _ScreenSize, _TessellationFactorTriangleSize); |
|
|
|
float3 distFactor = GetDistanceBasedTessFactor(p0, p1, p2, camPosWS, _TessellationFactorMinDistance, _TessellationFactorMaxDistance); |
|
|
|
float3 distFactor = GetDistanceBasedTessFactor(p0, p1, p2, GetPrimaryCameraPosition(), _TessellationFactorMinDistance, _TessellationFactorMaxDistance); |
|
|
|
// We square the disance factor as it allow a better percptual descrease of vertex density. |
|
|
|
tessFactor *= distFactor * distFactor; |
|
|
|
} |
|
|
|