Improve Skybox eyeDirection precision (#7685)
This commit is contained in:
@@ -58,6 +58,15 @@ fragment {
|
||||
|
||||
vertex {
|
||||
void materialVertex(inout MaterialVertexInputs material) {
|
||||
material.eyeDirection.xyz = material.worldPosition.xyz;
|
||||
// This code is taken from computeWorldPosition and assumes the vertex domain is 'device'.
|
||||
vec4 p = getPosition();
|
||||
// GL convention to inverted DX convention
|
||||
p.z = p.z * -0.5 + 0.5;
|
||||
vec4 worldPosition = getWorldFromClipMatrix() * p;
|
||||
// Getting the true world position would require dividing by w, but since this is a skybox
|
||||
// at inifinity, this results in very large numbers for material.eyeDirection.
|
||||
// Since the eyeDirection is only used as a direction vector in the fragment shader, we can
|
||||
// skip that step to improve precision.
|
||||
material.eyeDirection.xyz = worldPosition.xyz;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user