Fix global illumination on instanced rendering
This commit is contained in:
parent
df6ab0a7fd
commit
f7e0babe02
@ -547,16 +547,11 @@ void LightingPasses::updateLightsInfo(scene::ICameraSceneNode * const camnode,
|
||||
} // updateLightsInfo
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void LightingPasses::renderGlobalIllumination( const ShadowMatrices& shadow_matrices,
|
||||
const FrameBuffer& radiance_hint_framebuffer,
|
||||
const FrameBuffer& reflective_shadow_map_framebuffer,
|
||||
const FrameBuffer& diffuse_framebuffer,
|
||||
GLuint normal_depth_texture,
|
||||
GLuint depth_stencil_texture)
|
||||
void LightingPasses::renderRadianceHints( const ShadowMatrices& shadow_matrices,
|
||||
const FrameBuffer& radiance_hint_framebuffer,
|
||||
const FrameBuffer& reflective_shadow_map_framebuffer)
|
||||
{
|
||||
//Radiance hints
|
||||
#if !defined(USE_GLES2)
|
||||
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_RH));
|
||||
glDisable(GL_BLEND);
|
||||
radiance_hint_framebuffer.bind();
|
||||
glBindVertexArray(SharedGPUObjects::getFullScreenQuadVAO());
|
||||
@ -595,18 +590,18 @@ void LightingPasses::renderGlobalIllumination( const ShadowMatrices& shadow_mat
|
||||
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, 32);
|
||||
}
|
||||
#endif //!defined(USE_GLES2)
|
||||
} // renderRadianceHints
|
||||
|
||||
//Global illumination
|
||||
{
|
||||
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_GI));
|
||||
diffuse_framebuffer.bind();
|
||||
GlobalIlluminationReconstructionShader::getInstance()
|
||||
->render(shadow_matrices.getRHMatrix(),
|
||||
shadow_matrices.getRHExtend(),
|
||||
radiance_hint_framebuffer,
|
||||
normal_depth_texture,
|
||||
depth_stencil_texture);
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
void LightingPasses::renderGlobalIllumination( const ShadowMatrices& shadow_matrices,
|
||||
const FrameBuffer& radiance_hint_framebuffer,
|
||||
GLuint normal_depth_texture,
|
||||
GLuint depth_stencil_texture)
|
||||
{
|
||||
GlobalIlluminationReconstructionShader::getInstance()
|
||||
->render(shadow_matrices.getRHMatrix(), shadow_matrices.getRHExtend(),
|
||||
radiance_hint_framebuffer, normal_depth_texture,
|
||||
depth_stencil_texture);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -614,19 +609,15 @@ void LightingPasses::renderLights( bool has_shadow,
|
||||
GLuint normal_depth_texture,
|
||||
GLuint depth_stencil_texture,
|
||||
const FrameBuffer& shadow_framebuffer,
|
||||
const FrameBuffer& diffuse_specular_framebuffer,
|
||||
GLuint specular_probe)
|
||||
{
|
||||
diffuse_specular_framebuffer.bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
{
|
||||
{
|
||||
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_ENVMAP));
|
||||
renderEnvMap(normal_depth_texture,
|
||||
depth_stencil_texture,
|
||||
specular_probe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Render sunlight if and only if track supports shadow
|
||||
if (!World::getWorld() || World::getWorld()->getTrack()->hasShadows())
|
||||
{
|
||||
|
@ -47,18 +47,19 @@ public:
|
||||
|
||||
void updateLightsInfo(irr::scene::ICameraSceneNode * const camnode,
|
||||
float dt);
|
||||
|
||||
|
||||
void renderRadianceHints( const ShadowMatrices& shadow_matrices,
|
||||
const FrameBuffer& radiance_hint_framebuffer,
|
||||
const FrameBuffer& reflective_shadow_map_framebuffer);
|
||||
|
||||
void renderGlobalIllumination( const ShadowMatrices& shadow_matrices,
|
||||
const FrameBuffer& radiance_hint_framebuffer,
|
||||
const FrameBuffer& reflective_shadow_map_framebuffer,
|
||||
const FrameBuffer& diffuse_framebuffer,
|
||||
GLuint normal_depth_texture,
|
||||
GLuint depth_stencil_texture);
|
||||
void renderLights( bool has_shadow,
|
||||
GLuint normal_depth_texture,
|
||||
GLuint depth_stencil_texture,
|
||||
const FrameBuffer& shadow_framebuffer,
|
||||
const FrameBuffer& diffuse_specular_framebuffer,
|
||||
GLuint specular_probe);
|
||||
void renderAmbientScatter(GLuint depth_stencil_texture);
|
||||
void renderLightsScatter(GLuint depth_stencil_texture,
|
||||
|
@ -356,30 +356,37 @@ void ShaderBasedRenderer::renderScene(scene::ICameraSceneNode * const camnode,
|
||||
if (CVS->isDefferedEnabled())
|
||||
{
|
||||
if (CVS->isGlobalIlluminationEnabled() && hasShadow)
|
||||
{
|
||||
{
|
||||
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_RH));
|
||||
m_lighting_passes.renderRadianceHints( m_shadow_matrices,
|
||||
m_rtts->getRadianceHintFrameBuffer(),
|
||||
m_rtts->getReflectiveShadowMapFrameBuffer());
|
||||
}
|
||||
|
||||
m_rtts->getFBO(FBO_COMBINED_DIFFUSE_SPECULAR).bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
m_rtts->getFBO(FBO_DIFFUSE).bind();
|
||||
|
||||
if (CVS->isGlobalIlluminationEnabled() && hasShadow)
|
||||
{
|
||||
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_GI));
|
||||
m_lighting_passes.renderGlobalIllumination( m_shadow_matrices,
|
||||
m_rtts->getRadianceHintFrameBuffer(),
|
||||
m_rtts->getReflectiveShadowMapFrameBuffer(),
|
||||
m_rtts->getFBO(FBO_DIFFUSE),
|
||||
m_rtts->getRenderTarget(RTT_NORMAL_AND_DEPTH),
|
||||
m_rtts->getDepthStencilTexture());
|
||||
}
|
||||
|
||||
GLuint specular_probe;
|
||||
if(m_skybox)
|
||||
}
|
||||
|
||||
m_rtts->getFBO(FBO_COMBINED_DIFFUSE_SPECULAR).bind();
|
||||
GLuint specular_probe = 0;
|
||||
if (m_skybox)
|
||||
{
|
||||
specular_probe = m_skybox->getSpecularProbe();
|
||||
}
|
||||
else
|
||||
{
|
||||
specular_probe = 0;
|
||||
}
|
||||
|
||||
|
||||
m_lighting_passes.renderLights( hasShadow,
|
||||
m_rtts->getRenderTarget(RTT_NORMAL_AND_DEPTH),
|
||||
m_rtts->getDepthStencilTexture(),
|
||||
m_rtts->getShadowFrameBuffer(),
|
||||
m_rtts->getFBO(FBO_COMBINED_DIFFUSE_SPECULAR),
|
||||
specular_probe);
|
||||
}
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
@ -468,8 +475,6 @@ void ShaderBasedRenderer::renderScene(scene::ICameraSceneNode * const camnode,
|
||||
m_rtts->getFBO(FBO_COLORS).bind();
|
||||
m_lighting_passes.renderGlobalIllumination(m_shadow_matrices,
|
||||
m_rtts->getRadianceHintFrameBuffer(),
|
||||
m_rtts->getReflectiveShadowMapFrameBuffer(),
|
||||
m_rtts->getFBO(FBO_DIFFUSE),
|
||||
m_rtts->getRenderTarget(RTT_NORMAL_AND_DEPTH),
|
||||
m_rtts->getDepthStencilTexture());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user