diff options
author | Rye Mutt <rye@alchemyviewer.org> | 2023-03-10 09:28:35 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-10 08:28:35 -0600 |
commit | 97b5f07edd077e9b451e874275e9ce49c134f841 (patch) | |
tree | b14e3f6d7104cea00931e2285b0d97724ee9ee63 /indra/newview/app_settings/shaders/class3 | |
parent | b9df40c5a3bfa9d5ea4df9e77d9e7422c2c18eb3 (diff) |
This corrects tangents on blinn-phong surfaces to use proper mikkt calculation (#118)
Diffstat (limited to 'indra/newview/app_settings/shaders/class3')
-rw-r--r-- | indra/newview/app_settings/shaders/class3/deferred/materialF.glsl | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index d0c4b68013..6e41df34a4 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -210,9 +210,9 @@ uniform float minimum_alpha; #endif #ifdef HAS_NORMAL_MAP -VARYING vec3 vary_mat0; -VARYING vec3 vary_mat1; -VARYING vec3 vary_mat2; +in vec3 vary_normal; +in vec3 vary_tangent; +flat in float vary_sign; VARYING vec2 vary_texcoord1; #else VARYING vec3 vary_normal; @@ -227,14 +227,17 @@ vec2 encode_normal(vec3 n); vec3 getNormal(inout float glossiness) { #ifdef HAS_NORMAL_MAP - vec4 norm = texture2D(bumpMap, vary_texcoord1.xy); - glossiness *= norm.a; - - norm.xyz = norm.xyz * 2 - 1; + vec4 vNt = texture2D(bumpMap, vary_texcoord1.xy); + glossiness *= vNt.a; + vNt.xyz = vNt.xyz * 2 - 1; + float sign = vary_sign; + vec3 vN = vary_normal; + vec3 vT = vary_tangent.xyz; + + vec3 vB = sign * cross(vN, vT); + vec3 tnorm = normalize( vNt.x * vT + vNt.y * vB + vNt.z * vN ); - return normalize(vec3(dot(norm.xyz,vary_mat0), - dot(norm.xyz,vary_mat1), - dot(norm.xyz,vary_mat2))); + return tnorm; #else return normalize(vary_normal); #endif |