Compute shading_view will full precision (#6611)

This commit is contained in:
Ben Doherty
2023-03-03 13:48:36 -08:00
committed by GitHub
parent 5f3f3f1b24
commit d684fc4096
2 changed files with 3 additions and 2 deletions

View File

@@ -10,3 +10,4 @@ appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md).
fog: fixed fog height falloff and computation precision on mobile [⚠️ **Recompile Materials**]
materials: new alphaToCoverage property can be used to control alpha to coverage behavior
engine: fix precision issue with `shading_view` in large scenes

View File

@@ -36,10 +36,10 @@ void computeShadingParams() {
// With perspective camera, the view vector is cast from the fragment pos to the eye position,
// With ortho camera, however, the view vector is the same for all fragments:
shading_view = isPerspectiveProjection() ?
highp vec3 sv = isPerspectiveProjection() ?
(frameUniforms.cameraPosition - shading_position) :
frameUniforms.worldFromViewMatrix[2].xyz; // ortho camera backward dir
shading_view = normalize(shading_view);
shading_view = normalize(sv);
// we do this so we avoid doing (matrix multiply), but we burn 4 varyings:
// p = clipFromWorldMatrix * shading_position;