1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 22:23:51 +00:00

Calculate viewNormal only when needed

This commit is contained in:
Andrei Kortunov 2020-06-15 12:43:51 +04:00
parent 0d1b7fd3f0
commit f30cb9f8bc
4 changed files with 26 additions and 4 deletions

View file

@ -83,7 +83,9 @@ void main()
mat3 tbnTranspose = mat3(normalizedTangent, binormal, normalizedNormal);
vec3 viewNormal = gl_NormalMatrix * normalize(tbnTranspose * (normalTex.xyz * 2.0 - 1.0));
#else
#endif
#if (!@normalMap && (@parallax || @forcePPL))
vec3 viewNormal = gl_NormalMatrix * normalize(passNormal);
#endif
@ -184,7 +186,12 @@ void main()
#endif
if (matSpec != vec3(0.0))
{
#if (!normalMap && !@parallax && !forcePPL)
vec3 viewNormal = gl_NormalMatrix * normalize(passNormal);
#endif
gl_FragData[0].xyz += getSpecular(normalize(viewNormal), normalize(passViewPos.xyz), shininess, matSpec) * shadowing;
}
#if @radialFog
float depth;
// For the less detailed mesh of simple water we need to recalculate depth on per-pixel basis

View file

@ -63,7 +63,9 @@ void main(void)
euclideanDepth = length(viewPos.xyz);
linearDepth = gl_Position.z;
#if (@envMap || !PER_PIXEL_LIGHTING || @shadows_enabled)
vec3 viewNormal = normalize((gl_NormalMatrix * gl_Normal).xyz);
#endif
#if @envMap
vec3 viewVec = normalize(viewPos.xyz);
@ -112,5 +114,7 @@ void main(void)
passViewPos = viewPos.xyz;
passNormal = gl_Normal.xyz;
#if (@shadows_enabled)
setupShadowCoords(viewPos, viewNormal);
#endif
}

View file

@ -43,8 +43,10 @@ void main()
mat3 tbnTranspose = mat3(tangent, binormal, normalizedNormal);
vec3 viewNormal = normalize(gl_NormalMatrix * (tbnTranspose * (normalTex.xyz * 2.0 - 1.0)));
#else
vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);
#endif
#if (!@normalMap && (@parallax || @forcePPL))
vec3 viewNormal = gl_NormalMatrix * normalize(passNormal);
#endif
#if @parallax
@ -93,7 +95,12 @@ void main()
#endif
if (matSpec != vec3(0.0))
{
#if (!normalMap && !@parallax && !forcePPL)
vec3 viewNormal = gl_NormalMatrix * normalize(passNormal);
#endif
gl_FragData[0].xyz += getSpecular(normalize(viewNormal), normalize(passViewPos), shininess, matSpec) * shadowing;
}
#if @radialFog
float fogValue = clamp((euclideanDepth - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0);

View file

@ -27,7 +27,9 @@ void main(void)
euclideanDepth = length(viewPos.xyz);
linearDepth = gl_Position.z;
#if (!PER_PIXEL_LIGHTING || @shadows_enabled)
vec3 viewNormal = normalize((gl_NormalMatrix * gl_Normal).xyz);
#endif
#if !PER_PIXEL_LIGHTING
lighting = doLighting(viewPos.xyz, viewNormal, gl_Color, shadowDiffuseLighting);
@ -38,5 +40,7 @@ void main(void)
uv = gl_MultiTexCoord0.xy;
#if (@shadows_enabled)
setupShadowCoords(viewPos, viewNormal);
#endif
}