Merge branch 'vertex_lighting_fix' into 'master'

Correct vertex lighting

Closes #5973

See merge request OpenMW/openmw!770
pull/593/head
AnyOldName3 4 years ago
commit 90fecdeda2

@ -73,12 +73,7 @@ void main()
vec3 diffuseLight, ambientLight;
doLighting(passViewPos, normalize(viewNormal), shadowing, diffuseLight, ambientLight);
lighting = diffuseLight + ambientLight;
#endif
#if @clamp
lighting = clamp(lighting, vec3(0.0), vec3(1.0));
#else
lighting = max(lighting, 0.0);
clampLightingResult(lighting);
#endif
gl_FragData[0].xyz *= lighting;

@ -165,6 +165,7 @@ void main(void)
vec3 diffuseLight, ambientLight;
doLighting(viewPos.xyz, viewNormal, diffuseLight, ambientLight, shadowDiffuseLighting);
passLighting = diffuseLight + ambientLight;
clampLightingResult(passLighting);
#endif
#if (@shadows_enabled)

@ -129,3 +129,12 @@ vec4 lcalcSpecular(int lightIndex)
return @getLight[lightIndex].specular;
#endif
}
void clampLightingResult(inout vec3 lighting)
{
#if @clamp
lighting = clamp(lighting, vec3(0.0), vec3(1.0));
#else
lighting = max(lighting, 0.0);
#endif
}

@ -78,11 +78,7 @@ void main()
#endif
vec3 lighting = diffuseColor.xyz * diffuseLight + getAmbientColor().xyz * ambientLight + emission;
#if @clamp
lighting = clamp(lighting, vec3(0.0), vec3(1.0));
#else
lighting = max(lighting, 0.0);
#endif
clampLightingResult(lighting);
gl_FragData[0].xyz *= lighting;

@ -176,12 +176,7 @@ void main()
doLighting(passViewPos, normalize(viewNormal), shadowing, diffuseLight, ambientLight);
vec3 emission = getEmissionColor().xyz * emissiveMult;
lighting = diffuseColor.xyz * diffuseLight + getAmbientColor().xyz * ambientLight + emission;
#endif
#if @clamp
lighting = clamp(lighting, vec3(0.0), vec3(1.0));
#else
lighting = max(lighting, 0.0);
clampLightingResult(lighting);
#endif
gl_FragData[0].xyz *= lighting;

@ -125,6 +125,7 @@ void main(void)
doLighting(viewPos.xyz, viewNormal, diffuseLight, ambientLight, shadowDiffuseLighting);
vec3 emission = getEmissionColor().xyz * emissiveMult;
passLighting = getDiffuseColor().xyz * diffuseLight + getAmbientColor().xyz * ambientLight + emission;
clampLightingResult(passLighting);
shadowDiffuseLighting *= getDiffuseColor().xyz;
#endif

@ -87,12 +87,7 @@ void main()
vec3 diffuseLight, ambientLight;
doLighting(passViewPos, normalize(viewNormal), shadowing, diffuseLight, ambientLight);
lighting = diffuseColor.xyz * diffuseLight + getAmbientColor().xyz * ambientLight + getEmissionColor().xyz;
#endif
#if @clamp
lighting = clamp(lighting, vec3(0.0), vec3(1.0));
#else
lighting = max(lighting, 0.0);
clampLightingResult(lighting);
#endif
gl_FragData[0].xyz *= lighting;

@ -47,6 +47,7 @@ void main(void)
vec3 diffuseLight, ambientLight;
doLighting(viewPos.xyz, viewNormal, diffuseLight, ambientLight, shadowDiffuseLighting);
passLighting = getDiffuseColor().xyz * diffuseLight + getAmbientColor().xyz * ambientLight + getEmissionColor().xyz;
clampLightingResult(passLighting);
shadowDiffuseLighting *= getDiffuseColor().xyz;
#endif

Loading…
Cancel
Save