mirror of
https://github.com/ioquake/ioq3.git
synced 2024-11-10 07:11:46 +00:00
OpenGL2: Flip normals for backfacing triangles.
https://github.com/ioquake/ioq3/issues/513
This commit is contained in:
parent
b8be5a8bd7
commit
bc8737d707
1 changed files with 4 additions and 3 deletions
|
@ -264,7 +264,8 @@ void main()
|
||||||
float NL, NH, NE, EH, attenuation;
|
float NL, NH, NE, EH, attenuation;
|
||||||
|
|
||||||
#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||||
mat3 tangentToWorld = mat3(var_Tangent.xyz, var_Bitangent.xyz, var_Normal.xyz);
|
vec3 surfNormal = (!gl_FrontFacing ? var_Normal : -var_Normal).xyz;
|
||||||
|
mat3 tangentToWorld = mat3(var_Tangent.xyz, var_Bitangent.xyz, surfNormal);
|
||||||
viewDir = vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w);
|
viewDir = vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w);
|
||||||
E = normalize(viewDir);
|
E = normalize(viewDir);
|
||||||
#endif
|
#endif
|
||||||
|
@ -335,7 +336,7 @@ void main()
|
||||||
N.z = sqrt(clamp((0.25 - N.x * N.x) - N.y * N.y, 0.0, 1.0));
|
N.z = sqrt(clamp((0.25 - N.x * N.x) - N.y * N.y, 0.0, 1.0));
|
||||||
N = tangentToWorld * N;
|
N = tangentToWorld * N;
|
||||||
#else
|
#else
|
||||||
N = var_Normal.xyz;
|
N = surfNormal;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
N = normalize(N);
|
N = normalize(N);
|
||||||
|
@ -361,7 +362,7 @@ void main()
|
||||||
|
|
||||||
#if !defined(USE_LIGHT_VECTOR)
|
#if !defined(USE_LIGHT_VECTOR)
|
||||||
ambientColor = lightColor;
|
ambientColor = lightColor;
|
||||||
float surfNL = clamp(dot(var_Normal.xyz, L), 0.0, 1.0);
|
float surfNL = clamp(dot(surfNormal, L), 0.0, 1.0);
|
||||||
|
|
||||||
// reserve 25% ambient to avoid black areas on normalmaps
|
// reserve 25% ambient to avoid black areas on normalmaps
|
||||||
lightColor *= 0.75;
|
lightColor *= 0.75;
|
||||||
|
|
Loading…
Reference in a new issue