From 7fb1b853ac06872e48eff6ffeda81a264b5e8ad3 Mon Sep 17 00:00:00 2001 From: Pixelflinger Date: Wed, 2 Sep 2020 14:55:46 -0700 Subject: [PATCH] fix dynamic lighting frozen calculation this broke recently with the reverse-z, the froxel calculation relies on the depth, which is now inverted. we actually fix our getNormalizedViewportCorrd() public API, which the froxel code uses. --- shaders/src/getters.fs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shaders/src/getters.fs b/shaders/src/getters.fs index 663a91cdf1..0e1652b7fa 100644 --- a/shaders/src/getters.fs +++ b/shaders/src/getters.fs @@ -89,11 +89,13 @@ highp vec3 getLightSpacePosition() { /** * Returns the normalized [0, 1] viewport coordinates with the origin at the viewport's bottom-left. + * Z coordinate is in the [0, 1] range as well. * * @public-api */ highp vec3 getNormalizedViewportCoord() { - return vec3(shading_normalizedViewportCoord, gl_FragCoord.z); + // make sure handle our reversed-z + return vec3(shading_normalizedViewportCoord, 1.0 - gl_FragCoord.z); } #if defined(HAS_SHADOWING) && defined(HAS_DYNAMIC_LIGHTING)