From 20ea7ca2711f0cbe5320b4877a5d332b3b935893 Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Mon, 6 Oct 2014 22:51:37 +0200 Subject: [PATCH] GI use sun color value --- data/shaders/rh.frag | 3 ++- src/graphics/render_lighting.cpp | 6 ++++-- src/graphics/shaders.cpp | 4 ++-- src/graphics/shaders.hpp | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/data/shaders/rh.frag b/data/shaders/rh.frag index 17eadd2af..89fcd3fcb 100644 --- a/data/shaders/rh.frag +++ b/data/shaders/rh.frag @@ -9,6 +9,7 @@ uniform mat4 RSMMatrix; uniform sampler2D dtex; uniform sampler2D ctex; uniform sampler2D ntex; +uniform vec3 suncol; flat in int slice; layout (location = 0) out vec4 SHRed; @@ -63,7 +64,7 @@ void loop(in int i, float dotprod = max(dot(RSM_to_RH_dir, normal.xyz), 0.); float factor = dotprod / (0.1 + dist * dist); - vec3 color = RSMAlbedo.rgb * factor; + vec3 color = RSMAlbedo.rgb * factor * suncol.rgb; SHr += DirToSh(RSM_to_RH_dir, color.r); SHg += DirToSh(RSM_to_RH_dir, color.g); diff --git a/src/graphics/render_lighting.cpp b/src/graphics/render_lighting.cpp index f1e3d08dc..aa49be335 100644 --- a/src/graphics/render_lighting.cpp +++ b/src/graphics/render_lighting.cpp @@ -9,6 +9,7 @@ #include "modes/world.hpp" #include "tracks/track.hpp" #include "utils/profiler.hpp" +#include "callbacks.hpp" #define MAX2(a, b) ((a) > (b) ? (a) : (b)) #define MIN2(a, b) ((a) > (b) ? (b) : (a)) @@ -114,6 +115,7 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow) glDisable(GL_BLEND); m_rtts->getRH().Bind(); glBindVertexArray(SharedObject::FullScreenQuadVAO); + SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT); if (irr_driver->needRHWorkaround()) { glUseProgram(FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->Program); @@ -121,7 +123,7 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow) createVector(m_rtts->getRSM().getRTT()[0], m_rtts->getRSM().getRTT()[1], m_rtts->getRSM().getDepthTexture())); for (unsigned i = 0; i < 32; i++) { - FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->setUniforms(rsm_matrix, rh_matrix, rh_extend, i); + FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->setUniforms(rsm_matrix, rh_matrix, rh_extend, i, video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue())); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } } @@ -135,7 +137,7 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow) m_rtts->getRSM().getDepthTexture() ) ); - FullScreenShader::RadianceHintsConstructionShader::getInstance()->setUniforms(rsm_matrix, rh_matrix, rh_extend); + FullScreenShader::RadianceHintsConstructionShader::getInstance()->setUniforms(rsm_matrix, rh_matrix, rh_extend, video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue())); glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, 32); } } diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index 4cdb4b051..bcc243444 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -1496,7 +1496,7 @@ namespace FullScreenShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/rh.frag").c_str()); } - AssignUniforms("RSMMatrix", "RHMatrix", "extents"); + AssignUniforms("RSMMatrix", "RHMatrix", "extents", "suncol"); AssignSamplerNames(Program, 0, "ctex", 1, "ntex", 2, "dtex"); } @@ -1507,7 +1507,7 @@ namespace FullScreenShader GL_GEOMETRY_SHADER, file_manager->getAsset("shaders/rhpassthrough.geom").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/rh.frag").c_str()); - AssignUniforms("RSMMatrix", "RHMatrix", "extents", "slice"); + AssignUniforms("RSMMatrix", "RHMatrix", "extents", "slice", "suncol"); AssignSamplerNames(Program, 0, "ctex", 1, "ntex", 2, "dtex"); } diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp index 0c7e42133..6cba24ff9 100644 --- a/src/graphics/shaders.hpp +++ b/src/graphics/shaders.hpp @@ -407,14 +407,14 @@ public: ShadowedSunLightShader(); }; -class RadianceHintsConstructionShader : public ShaderHelperSingleton, public TextureRead +class RadianceHintsConstructionShader : public ShaderHelperSingleton, public TextureRead { public: RadianceHintsConstructionShader(); }; // Workaround for a bug found in kepler nvidia linux and fermi nvidia windows -class NVWorkaroundRadianceHintsConstructionShader : public ShaderHelperSingleton, public TextureRead +class NVWorkaroundRadianceHintsConstructionShader : public ShaderHelperSingleton, public TextureRead { public: NVWorkaroundRadianceHintsConstructionShader();