Ensure double sided normalmaps work, fixes #23760
This commit is contained in:
parent
998d3a30a5
commit
78624ad22c
1 changed files with 10 additions and 10 deletions
|
@ -1585,24 +1585,24 @@ void main() {
|
||||||
|
|
||||||
float alpha = 1.0;
|
float alpha = 1.0;
|
||||||
|
|
||||||
#if defined(DO_SIDE_CHECK)
|
|
||||||
float side = gl_FrontFacing ? 1.0 : -1.0;
|
|
||||||
#else
|
|
||||||
float side = 1.0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ALPHA_SCISSOR_USED)
|
#if defined(ALPHA_SCISSOR_USED)
|
||||||
float alpha_scissor = 0.5;
|
float alpha_scissor = 0.5;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY)
|
#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY)
|
||||||
vec3 binormal = normalize(binormal_interp) * side;
|
vec3 binormal = normalize(binormal_interp);// * side;
|
||||||
vec3 tangent = normalize(tangent_interp) * side;
|
vec3 tangent = normalize(tangent_interp);// * side;
|
||||||
#else
|
#else
|
||||||
vec3 binormal = vec3(0.0);
|
vec3 binormal = vec3(0.0);
|
||||||
vec3 tangent = vec3(0.0);
|
vec3 tangent = vec3(0.0);
|
||||||
#endif
|
#endif
|
||||||
vec3 normal = normalize(normal_interp) * side;
|
vec3 normal = normalize(normal_interp);
|
||||||
|
|
||||||
|
#if defined(DO_SIDE_CHECK)
|
||||||
|
if (!gl_FrontFacing) {
|
||||||
|
normal = -normal;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(ENABLE_UV_INTERP)
|
#if defined(ENABLE_UV_INTERP)
|
||||||
vec2 uv = uv_interp;
|
vec2 uv = uv_interp;
|
||||||
|
@ -1658,7 +1658,7 @@ FRAGMENT_SHADER_CODE
|
||||||
normalmap.xy = normalmap.xy * 2.0 - 1.0;
|
normalmap.xy = normalmap.xy * 2.0 - 1.0;
|
||||||
normalmap.z = sqrt(max(0.0, 1.0 - dot(normalmap.xy, normalmap.xy))); //always ignore Z, as it can be RG packed, Z may be pos/neg, etc.
|
normalmap.z = sqrt(max(0.0, 1.0 - dot(normalmap.xy, normalmap.xy))); //always ignore Z, as it can be RG packed, Z may be pos/neg, etc.
|
||||||
|
|
||||||
normal = normalize(mix(normal_interp, tangent * normalmap.x + binormal * normalmap.y + normal * normalmap.z, normaldepth)) * side;
|
normal = normalize(mix(normal, tangent * normalmap.x + binormal * normalmap.y + normal * normalmap.z, normaldepth));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue