Merge branch 'better-ambient-term' into 'master'

Draft: Better per-pixel lighting ambient term

See merge request OpenMW/openmw!3972
This commit is contained in:
cykoder 2025-08-01 18:25:14 +00:00
commit 267a9776ac

View File

@ -42,8 +42,21 @@ void doLighting(vec3 viewPos, vec3 viewNormal, float shininess, out vec3 diffuse
shininess = max(shininess, 1e-4);
vec3 sunDir = normalize(lcalcPosition(0));
diffuseLight = lcalcDiffuse(0) * calcLambert(viewNormal, sunDir, viewDir);
vec3 sunColor = lcalcDiffuse(0);
float sunIntensity = calcLambert(viewNormal, sunDir, viewDir);
diffuseLight = sunColor * sunIntensity;
#if PER_PIXEL_LIGHTING
ambientLight = mix(
gl_LightModel.ambient.xyz,
mix(sunColor, gl_LightModel.ambient.xyz, shadowing),
sunIntensity * 0.5
);
#else
ambientLight = gl_LightModel.ambient.xyz;
#endif
specularLight = lcalcSpecular(0).xyz * calcSpecIntensity(viewNormal, viewDir, shininess, sunDir);
#if PER_PIXEL_LIGHTING
diffuseLight *= shadowing;