fixes illumination behind light

This commit is contained in:
zomseffen 2020-07-19 11:21:12 +02:00
parent dede00377e
commit 2096b24e74

View file

@ -10,6 +10,7 @@ uniform int numLights;
uniform sampler2D ShadowMaps[3]; uniform sampler2D ShadowMaps[3];
uniform vec3 lightpos[3]; uniform vec3 lightpos[3];
uniform vec3 lightColor[3]; uniform vec3 lightColor[3];
uniform float near;
layout(location = 0) out vec4 colorOut; layout(location = 0) out vec4 colorOut;
layout(location = 1) out float depth; layout(location = 1) out float depth;
@ -25,15 +26,9 @@ const float circlelength = 100000.0;
bool isVisible(int i, vec2 offs, float lambertian) 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); vec2 size = textureSize(ShadowMaps[i], 0);
float bias = (1.0 / (10.0 * max(size.x, size.y)))*sin(acos(lambertian)); float bias = (1.0 / (10.0 * max(size.x, size.y)))*sin(acos(lambertian));
// bias = 0.0001*(1.0 - lambertian); return !((texture(ShadowMaps[i],lightviewpos[i].xy + offs).x) < (lightviewpos[i].z - bias)) && lightviewpos[i].z > near * 2;
// bias = max(bias, 0.001);
return !((texture(ShadowMaps[i],lightviewpos[i].xy + offs).x) < (lightviewpos[i].z - bias));
} }
void main() void main()
@ -64,11 +59,11 @@ void main()
visible = float(condition) * 1.0 + float(!condition) * visible; 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 += (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)); vec3 colorGammaCorrected = colorLinear;//pow(colorLinear, vec3(1.0/screenGamma));
colorOut = vec4(colorGammaCorrected,1.0); colorOut = vec4(colorGammaCorrected,1.0);
depth = gl_FragCoord.z; depth = gl_FragCoord.z;