From 5dbf839f7601ca63f0a07ed759fdcdd88cadb8cb Mon Sep 17 00:00:00 2001 From: Faerbit Date: Sun, 31 May 2015 17:51:11 +0200 Subject: [PATCH] Reverting to old way when to sample the directional shadow, because of a bug introduced by this. --- data/shader/phong.fsh | 7 +++---- game/graphics.cc | 12 ------------ game/graphics.hh | 1 - 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/data/shader/phong.fsh b/data/shader/phong.fsh index 29b199c..585c2ec 100644 --- a/data/shader/phong.fsh +++ b/data/shader/phong.fsh @@ -51,7 +51,6 @@ uniform bool movingTexture; uniform vec2 movement; uniform vec2 movingTextureOffset; uniform float time; -uniform bool sampleDirectionalShadowSwitch; vec2 poissonDisk[16] = vec2[]( vec2( -0.94201624, -0.39906216 ), @@ -209,9 +208,9 @@ void main() // direction lighting float sunAngle = -1.0; - if(sampleDirectionalShadowSwitch) { - vec3 directionalVector = normalize(directionalLightVector); - sunAngle = dot(vec3(0.0, 1.0, 0.0), directionalVector); + vec3 directionalVector = normalize(directionalLightVector); + sunAngle = dot(vec3(0.0, 1.0, 0.0), directionalVector); + if(sunAngle > 0.0) { float directionalVisibility = 1.0f; float directionalIntensity = sunIntensity(sunAngle); if (distanceToBorder(shadowCoord3.xy) <= 0.5 && distanceToBorder(shadowCoord3.xy) > 0.2) { diff --git a/game/graphics.cc b/game/graphics.cc index 34805db..0bf6ec7 100644 --- a/game/graphics.cc +++ b/game/graphics.cc @@ -30,7 +30,6 @@ Graphics::Graphics(glm::uvec2 windowSize, float nearPlane, renderFlames = true; renderWorld = true; renderDebug = false; - directionalShadowSwitch = false; } Graphics::Graphics() { @@ -197,7 +196,6 @@ void Graphics::init(Level* level) { lightingShader->setUniform("fogColorRise", level->getFogColourRise()); lightingShader->setUniform("fogColorNight", level->getFogColourNight()); lightingShader->setUniform("ambientColor", level->getAmbientLight()); - lightingShader->setUniform("sampleDirectionalShadowSwitch", false); if(level->getDirectionalLight()) { lightingShader->setUniform("directionalLightVector", level->getDirectionalLight()->getPosition()); @@ -370,11 +368,6 @@ void Graphics::render(double time) glm::vec3 sunVector = (level->getCameraCenter()->getPosition() + level->getDirectionalLight()->getPosition()); if (sunAngle > 0.0f) { - if (!directionalShadowSwitch) { - lightingShader->use(); - lightingShader->setUniform("sampleDirectionalShadowSwitch", true); - directionalShadowSwitch = true; - } depthShader->use(); for (unsigned int i = 0; ibind(); @@ -405,11 +398,6 @@ void Graphics::render(double time) } } } - else if (directionalShadowSwitch) { - lightingShader->use(); - lightingShader->setUniform("sampleDirectionalShadowSwitch", false); - directionalShadowSwitch = false; - } } // lighting render pass diff --git a/game/graphics.hh b/game/graphics.hh index 467c00f..0560e27 100644 --- a/game/graphics.hh +++ b/game/graphics.hh @@ -84,7 +84,6 @@ class Graphics { bool renderFlames; bool renderDebug; bool renderWorld; - bool directionalShadowSwitch; DebugDraw debugDrawer; SharedArrayBuffer debug_ab; SharedVertexArrayObject debug_vao;