From 1995d2734e4ed792778466b75c551ac6a3fb9f83 Mon Sep 17 00:00:00 2001 From: Steffen Temme Date: Sun, 29 Oct 2017 08:37:11 +0100 Subject: [PATCH] Fiddling around with lighting and a Rendermanager --- Lights/LightingManager.py | 2 ++ fragment.glsl | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Lights/LightingManager.py b/Lights/LightingManager.py index e5fe629..70fd585 100644 --- a/Lights/LightingManager.py +++ b/Lights/LightingManager.py @@ -52,6 +52,8 @@ class LightingManager: def render(self, projMatrix, geometryRotMatrix): self.light.finishDepthMapping() + + def addRenderStep(self,alternateprogramdict,structure): r = self.__Renderstep(alternateprogramdict,structure) self.renderSteps.append(r) diff --git a/fragment.glsl b/fragment.glsl index f1dd73c..60655ba 100644 --- a/fragment.glsl +++ b/fragment.glsl @@ -23,6 +23,11 @@ const float screenGamma = 2.2; const float pitl = 2*3.14159265359 / 16.0; const float circlelength = 700.0; +bool isVisible(int i, vec2 offs) +{ + return !(texture(ShadowMaps[i],lightviewpos[i].xy + offs).x <= (lightviewpos[i].z - 0.0005*tan(acos(dot(normal,-normalize(lightpos[i] - pos.xyz)))))); +} + void main() { vec3 colorLinear = ambientFactor * colorin; @@ -39,7 +44,7 @@ void main() float visible = 0; for(int j = 0; j < 4; j++){ vec2 offs = vec2(cos(j*4*pitl),sin(j*4*pitl)) / circlelength; - visible += float(!(texture(ShadowMaps[i],lightviewpos[i].xy + offs).x <= (lightviewpos[i].z - 0.0005*tan(acos(dot(normal,-normalize(lightpos[i] - pos.xyz))))))) * 1.0/16.0; + visible += float(isVisible(i, offs)) * 1.0/16.0; } if(visible == 0.25) visible = 1.0; @@ -47,9 +52,11 @@ void main() visible = 0; for(int j = 0; j < 16; j++){ vec2 offs = vec2(cos(j*pitl),sin(j*pitl)) / circlelength; - visible += float(!(texture(ShadowMaps[i],lightviewpos[i].xy + offs).x <= (lightviewpos[i].z - 0.0005*tan(acos(dot(normal,-normalize(lightpos[i] - pos.xyz))))))) * 1.0/16.0; + visible += float(isVisible(i, offs)) * 1.0/16.0; } colorLinear += (visible * 0.5 + 0.5) *(lambertian * diffuseFactor * colorin * lightColor[i] + specular * specFactor*colorin); + + colorLinear /= dot(lightpos[i] - pos.xyz, lightpos[i] - pos.xyz)/200; //colorLinear = vec3(visible * specular); }