GI use sun color value

This commit is contained in:
Vincent Lejeune 2014-10-06 22:51:37 +02:00
parent a4ac9f95c2
commit 20ea7ca271
4 changed files with 10 additions and 7 deletions

View File

@ -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);

View File

@ -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<GLuint>(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);
}
}

View File

@ -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");
}

View File

@ -407,14 +407,14 @@ public:
ShadowedSunLightShader();
};
class RadianceHintsConstructionShader : public ShaderHelperSingleton<RadianceHintsConstructionShader, core::matrix4, core::matrix4, core::vector3df>, public TextureRead<Bilinear_Filtered, Bilinear_Filtered, Bilinear_Filtered>
class RadianceHintsConstructionShader : public ShaderHelperSingleton<RadianceHintsConstructionShader, core::matrix4, core::matrix4, core::vector3df, video::SColorf>, public TextureRead<Bilinear_Filtered, Bilinear_Filtered, Bilinear_Filtered>
{
public:
RadianceHintsConstructionShader();
};
// Workaround for a bug found in kepler nvidia linux and fermi nvidia windows
class NVWorkaroundRadianceHintsConstructionShader : public ShaderHelperSingleton<NVWorkaroundRadianceHintsConstructionShader, core::matrix4, core::matrix4, core::vector3df, int>, public TextureRead<Bilinear_Filtered, Bilinear_Filtered, Bilinear_Filtered>
class NVWorkaroundRadianceHintsConstructionShader : public ShaderHelperSingleton<NVWorkaroundRadianceHintsConstructionShader, core::matrix4, core::matrix4, core::vector3df, int, video::SColorf>, public TextureRead<Bilinear_Filtered, Bilinear_Filtered, Bilinear_Filtered>
{
public:
NVWorkaroundRadianceHintsConstructionShader();