mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 13:53:53 +00:00
Stop shadowing ambient lighting from the light casting a shadow when using per-pixel lighting.
This commit is contained in:
parent
f50063402d
commit
c67b3267fb
1 changed files with 5 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
|||
#define MAX_LIGHTS 8
|
||||
|
||||
vec3 perLight(int lightIndex, vec3 viewPos, vec3 viewNormal, vec4 diffuse, vec3 ambient)
|
||||
vec3 perLight(int lightIndex, vec3 viewPos, vec3 viewNormal, vec4 diffuse, vec3 ambient, float shadowing)
|
||||
{
|
||||
vec3 lightDir;
|
||||
float d;
|
||||
|
@ -9,7 +9,7 @@ vec3 perLight(int lightIndex, vec3 viewPos, vec3 viewNormal, vec4 diffuse, vec3
|
|||
d = length(lightDir);
|
||||
lightDir = normalize(lightDir);
|
||||
|
||||
return (ambient * gl_LightSource[lightIndex].ambient.xyz + diffuse.xyz * gl_LightSource[lightIndex].diffuse.xyz * max(dot(viewNormal.xyz, lightDir), 0.0)) * clamp(1.0 / (gl_LightSource[lightIndex].constantAttenuation + gl_LightSource[lightIndex].linearAttenuation * d + gl_LightSource[lightIndex].quadraticAttenuation * d * d), 0.0, 1.0);
|
||||
return (ambient * gl_LightSource[lightIndex].ambient.xyz + diffuse.xyz * gl_LightSource[lightIndex].diffuse.xyz * max(dot(viewNormal.xyz, lightDir), 0.0)) * clamp(1.0 / (gl_LightSource[lightIndex].constantAttenuation + gl_LightSource[lightIndex].linearAttenuation * d + gl_LightSource[lightIndex].quadraticAttenuation * d * d), 0.0, 1.0) * shadowing;
|
||||
}
|
||||
|
||||
#ifdef FRAGMENT
|
||||
|
@ -31,13 +31,13 @@ vec4 doLighting(vec3 viewPos, vec3 viewNormal, vec4 vertexColor)
|
|||
vec4 lightResult = vec4(0.0, 0.0, 0.0, diffuse.a);
|
||||
|
||||
#ifdef FRAGMENT
|
||||
lightResult.xyz += perLight(0, viewPos, viewNormal, diffuse, ambient) * shadowing;
|
||||
lightResult.xyz += perLight(0, viewPos, viewNormal, diffuse, ambient, shadowing);
|
||||
#else
|
||||
lightResult.xyz += perLight(0, viewPos, viewNormal, diffuse, ambient);
|
||||
lightResult.xyz += perLight(0, viewPos, viewNormal, diffuse, ambient, 1.0);
|
||||
#endif
|
||||
for (int i=1; i<MAX_LIGHTS; ++i)
|
||||
{
|
||||
lightResult.xyz += perLight(i, viewPos, viewNormal, diffuse, ambient);
|
||||
lightResult.xyz += perLight(i, viewPos, viewNormal, diffuse, ambient, 1.0);
|
||||
}
|
||||
|
||||
lightResult.xyz += gl_LightModel.ambient.xyz * ambient;
|
||||
|
|
Loading…
Reference in a new issue