浏览代码

Merge pull request #724 from Unity-Technologies/Fix-issue-with-tessellation-and-reflection-probe

HDRenderPipeline: Fix reflection probe and tessellation (object was badly culled)
/feature-ReflectionProbeFit
GitHub 7 年前
当前提交
e1a8285c
共有 2 个文件被更改,包括 12 次插入9 次删除
  1. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDCamera.cs
  2. 15
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/LitDataMeshModification.hlsl

6
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDCamera.cs


}
// Near, far.
frustumPlaneEquations[4] = new Vector4( camera.transform.forward.x, camera.transform.forward.y, camera.transform.forward.z, -Vector3.Dot(camera.transform.forward, relPos) - camera.nearClipPlane);
frustumPlaneEquations[5] = new Vector4(-camera.transform.forward.x, -camera.transform.forward.y, -camera.transform.forward.z, Vector3.Dot(camera.transform.forward, relPos) + camera.farClipPlane);
// We need to switch forward direction based on handness (Reminder: Regular camera have a negative determinant in Unity and reflection probe follow DX convention and have a positive determinant)
Vector3 forward = viewParam.x < 0.0f ? camera.transform.forward : -camera.transform.forward;
frustumPlaneEquations[4] = new Vector4( forward.x, forward.y, forward.z, -Vector3.Dot(forward, relPos) - camera.nearClipPlane);
frustumPlaneEquations[5] = new Vector4(-forward.x, -forward.y, -forward.z, Vector3.Dot(forward, relPos) + camera.farClipPlane);
m_LastFrameActive = Time.frameCount;
}

15
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/LitDataMeshModification.hlsl


input.uv3,
#else
float2(0.0, 0.0),
#endif
#endif
#endif
#endif
#ifdef _VERTEX_WIND
float3 rootWP = mul(GetObjectToWorldMatrix(), float4(0, 0, 0, 1)).xyz;
ApplyWindDisplacement(positionWS, normalWS, rootWP, _Stiffness, _Drag, _ShiverDrag, _ShiverDirectionality, _InitialBend, input.color.a, time);

// For tessellation we want to process tessellation factor always from the point of view of the camera (to be consistent and avoid Z-fight).
// For the culling part however we want to use the current view (shadow view).
// Thus the following code play with both.
float frustumEps = -maxDisplacement;
float frustumEps = -maxDisplacement; // "-" Expected parameter for CullTriangleEdgesFrustum
// TODO: the only reason I test the near plane here is that I am not sure that the product of other tessellation factors
// (such as screen-space/distance-based) results in the tessellation factor of 1 for the geometry behind the near plane.
// If that is the case (and, IMHO, it should be), we shouldn't have to test the near plane here.

if (_TessellationBackFaceCullEpsilon > -1.0) // Is back-face culling enabled ?
{
// Handle transform mirroring (like negative scaling)
// Note: We don't need to handle handness of view matrix here as the backface is perform in worldspace
float winding = unity_WorldTransformParams.w;
faceCull = CullTriangleBackFace(p0, p1, p2, _TessellationBackFaceCullEpsilon, GetCurrentViewPosition(), winding); // Use shadow view
}

input.texCoord3,
#else
float2(0.0, 0.0),
#endif
#endif
#endif
#endif
);
#endif // _TESSELLATION_DISPLACEMENT
}
正在加载...
取消
保存