diff options
author | Cosmic Linden <cosmic@lindenlab.com> | 2023-10-13 10:42:02 -0700 |
---|---|---|
committer | Cosmic Linden <cosmic@lindenlab.com> | 2023-10-13 10:42:02 -0700 |
commit | 823fcddcb508fac6d1f819633f6a91230f06b114 (patch) | |
tree | c085bfcd6410ebb3f03150e970eaf3e218765a29 /indra/newview/app_settings/shaders | |
parent | be39e92f7d3c6df80eeb1f183723978ce1bf1b52 (diff) |
DRTVWR-592: (WIP) (has debug) Fix removing axial sign flip of normal texture during zero check, add another zero check
Diffstat (limited to 'indra/newview/app_settings/shaders')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/pbrterrainUtilF.glsl | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainUtilF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainUtilF.glsl index fc04afe513..c5de74604f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainUtilF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainUtilF.glsl @@ -80,7 +80,7 @@ vec4 _t_texture(sampler2D tex, vec2 uv_unflipped, float sign_or_zero) { // Handle case where sign is 0 float sign = (2.0*sign_or_zero) + 1.0; - sign /= sign; + sign /= abs(sign); // If the vertex normal is negative, flip the texture back // right-side up. vec2 uv = uv_unflipped * vec2(sign, 1); @@ -190,8 +190,8 @@ TerrainSample _t_sample(sampler2D tex, TerrainCoord terrain_coord, TerrainWeight ts.z = ts.x; break; } -#else // TODO: Remove debug -#if 0 +#else +#if 0 // TODO: Remove debug // This demonstrates the case when the bug does not occur: Sampling beforehand and assigning in switch..case // This otherwise uses the same logic as in the case that reproduces the bug. #define do_sample_x() _t_texture(tex, terrain_coord[0].zw, sign(vary_vertex_normal.x)) @@ -295,10 +295,15 @@ TerrainSampleNormal _t_sample_n(sampler2D tex, TerrainCoord terrain_coord, Terra { TerrainSample ts = _t_sample(tex, terrain_coord, tw); TerrainSampleNormal tsn; + // Unpack normals tsn.x = ts.x.xyz*2.0-1.0; tsn.y = ts.y.xyz*2.0-1.0; tsn.z = ts.z.xyz*2.0-1.0; + // Get sign vec3 ns = sign(vary_vertex_normal); + // Handle case where sign is 0 + ns = (2.0*ns) + 1.0; + ns /= abs(ns); // If the sign is negative, rotate normal by 180 degrees tsn.x.xy = (min(0, ns.x) * tsn.x.xy) + (min(0, -ns.x) * -tsn.x.xy); tsn.y.xy = (min(0, ns.y) * tsn.y.xy) + (min(0, -ns.y) * -tsn.y.xy); |