Fix shadow visualization

This commit is contained in:
Benau 2018-01-13 15:38:52 +08:00
parent 9e90bd251d
commit 4194977df5
6 changed files with 13 additions and 14 deletions

View File

@ -209,13 +209,13 @@ public:
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
void render(GLuint normal_depth_texture, void render(GLuint normal_depth_texture,
GLuint depth_stencil_texture, GLuint depth_stencil_texture,
const FrameBuffer& shadow_framebuffer, const FrameBuffer* shadow_framebuffer,
const core::vector3df &direction, const core::vector3df &direction,
const video::SColorf &col) const video::SColorf &col)
{ {
setTextureUnits(normal_depth_texture, setTextureUnits(normal_depth_texture,
depth_stencil_texture, depth_stencil_texture,
shadow_framebuffer.getDepthTexture() ); shadow_framebuffer->getDepthTexture() );
drawFullScreenEffect(ShadowMatrices::m_shadow_split[1], drawFullScreenEffect(ShadowMatrices::m_shadow_split[1],
ShadowMatrices::m_shadow_split[2], ShadowMatrices::m_shadow_split[2],
ShadowMatrices::m_shadow_split[3], ShadowMatrices::m_shadow_split[3],
@ -418,7 +418,7 @@ void LightingPasses::updateLightsInfo(scene::ICameraSceneNode * const camnode,
void LightingPasses::renderLights( bool has_shadow, void LightingPasses::renderLights( bool has_shadow,
GLuint normal_depth_texture, GLuint normal_depth_texture,
GLuint depth_stencil_texture, GLuint depth_stencil_texture,
const FrameBuffer& shadow_framebuffer, const FrameBuffer* shadow_framebuffer,
GLuint specular_probe) GLuint specular_probe)
{ {
{ {

View File

@ -50,7 +50,7 @@ public:
void renderLights( bool has_shadow, void renderLights( bool has_shadow,
GLuint normal_depth_texture, GLuint normal_depth_texture,
GLuint depth_stencil_texture, GLuint depth_stencil_texture,
const FrameBuffer& shadow_framebuffer, const FrameBuffer* shadow_framebuffer,
GLuint specular_probe); GLuint specular_probe);
void renderLightsScatter(GLuint depth_stencil_texture, void renderLightsScatter(GLuint depth_stencil_texture,
const FrameBuffer& half1_framebuffer, const FrameBuffer& half1_framebuffer,

View File

@ -149,7 +149,7 @@ public:
unsigned int getWidth () const { return m_width ; } unsigned int getWidth () const { return m_width ; }
unsigned int getHeight() const { return m_height; } unsigned int getHeight() const { return m_height; }
FrameBufferLayer &getShadowFrameBuffer() { return *m_shadow_FBO; } FrameBufferLayer* getShadowFrameBuffer() { return m_shadow_FBO; }
unsigned getDepthStencilTexture() const { return DepthStencilTexture; } unsigned getDepthStencilTexture() const { return DepthStencilTexture; }
unsigned getRenderTarget(enum TypeRTT target) const { return RenderTargetTextures[target]; } unsigned getRenderTarget(enum TypeRTT target) const { return RenderTargetTextures[target]; }
FrameBuffer& getFBO(enum TypeFBO fbo) { return FrameBuffers[fbo]; } FrameBuffer& getFBO(enum TypeFBO fbo) { return FrameBuffers[fbo]; }

View File

@ -187,7 +187,7 @@ void ShaderBasedRenderer::renderShadows()
glClearColor(1.0f, 1.0f, 1.0f, 1.0f); glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
for (unsigned cascade = 0; cascade < 4; cascade++) for (unsigned cascade = 0; cascade < 4; cascade++)
{ {
m_rtts->getShadowFrameBuffer().bindLayerDepthOnly(cascade); m_rtts->getShadowFrameBuffer()->bindLayerDepthOnly(cascade);
glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);
SP::sp_cur_shadow_cascade = cascade; SP::sp_cur_shadow_cascade = cascade;
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_SHADOWS_CASCADE0 + cascade)); ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_SHADOWS_CASCADE0 + cascade));
@ -596,7 +596,7 @@ void ShaderBasedRenderer::renderPostProcessing(Camera * const camera)
camera->activate(); camera->activate();
m_post_processing->renderPassThrough(m_rtts->getFBO(FBO_HALF1_R).getRTT()[0], viewport.LowerRightCorner.X - viewport.UpperLeftCorner.X, viewport.LowerRightCorner.Y - viewport.UpperLeftCorner.Y); m_post_processing->renderPassThrough(m_rtts->getFBO(FBO_HALF1_R).getRTT()[0], viewport.LowerRightCorner.X - viewport.UpperLeftCorner.X, viewport.LowerRightCorner.Y - viewport.UpperLeftCorner.Y);
} }
else if (irr_driver->getShadowViz()) else if (irr_driver->getShadowViz() && m_rtts->getShadowFrameBuffer())
{ {
m_shadow_matrices.renderShadowsDebug(m_rtts->getShadowFrameBuffer(), m_post_processing); m_shadow_matrices.renderShadowsDebug(m_rtts->getShadowFrameBuffer(), m_post_processing);
} }

View File

@ -22,7 +22,6 @@
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "graphics/central_settings.hpp" #include "graphics/central_settings.hpp"
#include "graphics/frame_buffer.hpp" #include "graphics/frame_buffer.hpp"
#include "graphics/glwrap.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "graphics/post_processing.hpp" #include "graphics/post_processing.hpp"
#include "graphics/rtts.hpp" #include "graphics/rtts.hpp"
@ -320,24 +319,24 @@ void ShadowMatrices::renderWireFrameFrustrum(float *tmp, unsigned i)
glDrawElements(GL_LINES, 24, GL_UNSIGNED_INT, 0); glDrawElements(GL_LINES, 24, GL_UNSIGNED_INT, 0);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void ShadowMatrices::renderShadowsDebug(const FrameBuffer &shadow_framebuffer, void ShadowMatrices::renderShadowsDebug(const FrameBuffer* shadow_framebuffer,
const PostProcessing *post_processing) const PostProcessing *post_processing)
{ {
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0, UserConfigParams::m_height / 2, glViewport(0, UserConfigParams::m_height / 2,
UserConfigParams::m_width / 2, UserConfigParams::m_height / 2); UserConfigParams::m_width / 2, UserConfigParams::m_height / 2);
post_processing->renderTextureLayer(shadow_framebuffer.getRTT()[0], 0); post_processing->renderTextureLayer(shadow_framebuffer->getDepthTexture(), 0);
renderWireFrameFrustrum(m_shadows_cam[0], 0); renderWireFrameFrustrum(m_shadows_cam[0], 0);
glViewport(UserConfigParams::m_width / 2, UserConfigParams::m_height / 2, glViewport(UserConfigParams::m_width / 2, UserConfigParams::m_height / 2,
UserConfigParams::m_width / 2, UserConfigParams::m_height / 2); UserConfigParams::m_width / 2, UserConfigParams::m_height / 2);
post_processing->renderTextureLayer(shadow_framebuffer.getRTT()[0], 1); post_processing->renderTextureLayer(shadow_framebuffer->getDepthTexture(), 1);
renderWireFrameFrustrum(m_shadows_cam[1], 1); renderWireFrameFrustrum(m_shadows_cam[1], 1);
glViewport(0, 0, UserConfigParams::m_width / 2, UserConfigParams::m_height / 2); glViewport(0, 0, UserConfigParams::m_width / 2, UserConfigParams::m_height / 2);
post_processing->renderTextureLayer(shadow_framebuffer.getRTT()[0], 2); post_processing->renderTextureLayer(shadow_framebuffer->getDepthTexture(), 2);
renderWireFrameFrustrum(m_shadows_cam[2], 2); renderWireFrameFrustrum(m_shadows_cam[2], 2);
glViewport(UserConfigParams::m_width / 2, 0, UserConfigParams::m_width / 2, glViewport(UserConfigParams::m_width / 2, 0, UserConfigParams::m_width / 2,
UserConfigParams::m_height / 2); UserConfigParams::m_height / 2);
post_processing->renderTextureLayer(shadow_framebuffer.getRTT()[0], 3); post_processing->renderTextureLayer(shadow_framebuffer->getDepthTexture(), 3);
renderWireFrameFrustrum(m_shadows_cam[3], 3); renderWireFrameFrustrum(m_shadows_cam[3], 3);
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height); glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
} }

View File

@ -66,7 +66,7 @@ public:
GLuint depth_stencil_texture); GLuint depth_stencil_texture);
void addLight(const core::vector3df &pos); void addLight(const core::vector3df &pos);
void updateSunOrthoMatrices(); void updateSunOrthoMatrices();
void renderShadowsDebug(const FrameBuffer &shadow_framebuffer, void renderShadowsDebug(const FrameBuffer* shadow_framebuffer,
const PostProcessing *post_processing); const PostProcessing *post_processing);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------