fixes illumination behind light
This commit is contained in:
parent
dede00377e
commit
2096b24e74
1 changed files with 4 additions and 9 deletions
|
@ -10,6 +10,7 @@ uniform int numLights;
|
|||
uniform sampler2D ShadowMaps[3];
|
||||
uniform vec3 lightpos[3];
|
||||
uniform vec3 lightColor[3];
|
||||
uniform float near;
|
||||
|
||||
layout(location = 0) out vec4 colorOut;
|
||||
layout(location = 1) out float depth;
|
||||
|
@ -25,15 +26,9 @@ const float circlelength = 100000.0;
|
|||
|
||||
bool isVisible(int i, vec2 offs, float lambertian)
|
||||
{
|
||||
// float bias = 0.005*tan(acos(lambertian));
|
||||
// bias = clamp(bias,0.0,0.01);//*tan(acos(dot(normal,-normalize(lightpos[i] - pos.xyz))));
|
||||
// return !(texture(ShadowMaps[i],lightviewpos[i].xy + offs).x < (lightviewpos[i].z - bias));
|
||||
|
||||
vec2 size = textureSize(ShadowMaps[i], 0);
|
||||
float bias = (1.0 / (10.0 * max(size.x, size.y)))*sin(acos(lambertian));
|
||||
// bias = 0.0001*(1.0 - lambertian);
|
||||
// bias = max(bias, 0.001);
|
||||
return !((texture(ShadowMaps[i],lightviewpos[i].xy + offs).x) < (lightviewpos[i].z - bias));
|
||||
return !((texture(ShadowMaps[i],lightviewpos[i].xy + offs).x) < (lightviewpos[i].z - bias)) && lightviewpos[i].z > near * 2;
|
||||
}
|
||||
|
||||
void main()
|
||||
|
@ -64,7 +59,7 @@ void main()
|
|||
visible = float(condition) * 1.0 + float(!condition) * visible;
|
||||
|
||||
colorLinear += (visible * 0.5 + 0.0) *(lambertian * diffuseFactor * colorin * lightColor[i] + specular * specFactor*colorin) * (200.0/(length(lightpos[i] - pos.xyz) * length(lightpos[i] - pos.xyz)));
|
||||
|
||||
// colorLinear = vec3(visible, visible, visible);
|
||||
}
|
||||
|
||||
vec3 colorGammaCorrected = colorLinear;//pow(colorLinear, vec3(1.0/screenGamma));
|
||||
|
|
Loading…
Reference in a new issue