From 2096b24e7429ee1a547d10df4e86ecb219438202 Mon Sep 17 00:00:00 2001 From: zomseffen Date: Sun, 19 Jul 2020 11:21:12 +0200 Subject: [PATCH] fixes illumination behind light --- fragment.glsl | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/fragment.glsl b/fragment.glsl index 264112f..6fc9d06 100644 --- a/fragment.glsl +++ b/fragment.glsl @@ -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,11 +59,11 @@ 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)); - + colorOut = vec4(colorGammaCorrected,1.0); depth = gl_FragCoord.z;