1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-14 01:19:59 +00:00

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-03-09 14:30:21 +00:00
commit 4ae55b568a

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;