Add a way to display shadow map.
This commit is contained in:
parent
e959d6c857
commit
8cbeca44fd
10
data/shaders/layertexturequad.frag
Normal file
10
data/shaders/layertexturequad.frag
Normal file
@ -0,0 +1,10 @@
|
||||
uniform sampler2DArray tex;
|
||||
uniform int layer;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = texture(tex, vec3(uv, float(layer)));
|
||||
}
|
@ -380,6 +380,7 @@ private:
|
||||
void renderSSAO();
|
||||
void renderLights(unsigned pointlightCount);
|
||||
void renderDisplacement();
|
||||
void renderShadowsDebug();
|
||||
void doScreenShot();
|
||||
public:
|
||||
IrrDriver();
|
||||
|
@ -477,6 +477,21 @@ void PostProcessing::renderPassThrough(GLuint tex)
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
void PostProcessing::renderTextureLayer(unsigned tex, unsigned layer)
|
||||
{
|
||||
glUseProgram(FullScreenShader::LayerPassThroughShader::Program);
|
||||
glBindVertexArray(FullScreenShader::LayerPassThroughShader::vao);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glUniform1i(FullScreenShader::LayerPassThroughShader::uniform_texture, 0);
|
||||
glUniform1i(FullScreenShader::LayerPassThroughShader::uniform_layer, layer);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
void PostProcessing::renderGlow(unsigned tex)
|
||||
{
|
||||
|
||||
|
@ -90,6 +90,7 @@ public:
|
||||
|
||||
/** Render tex. Used for blit/texture resize */
|
||||
void renderPassThrough(unsigned tex);
|
||||
void renderTextureLayer(unsigned tex, unsigned layer);
|
||||
void applyMLAA();
|
||||
|
||||
void renderMotionBlur(unsigned cam, FrameBuffer &in_fbo, FrameBuffer &out_fbo);
|
||||
|
@ -197,6 +197,10 @@ void IrrDriver::renderGLSL(float dt)
|
||||
glViewport(viewport.UpperLeftCorner.X, viewport.UpperLeftCorner.Y, viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
|
||||
m_post_processing->renderPassThrough(m_rtts->getRSM().getRTT()[0]);
|
||||
}
|
||||
else if (irr_driver->getShadowViz())
|
||||
{
|
||||
renderShadowsDebug();
|
||||
}
|
||||
else
|
||||
fbo->BlitToDefault(viewport.UpperLeftCorner.X, viewport.UpperLeftCorner.Y, viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
|
||||
}
|
||||
@ -824,6 +828,20 @@ void IrrDriver::renderShadows()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IrrDriver::renderShadowsDebug()
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glViewport(0, 0, UserConfigParams::m_width / 2, UserConfigParams::m_height / 2);
|
||||
m_post_processing->renderTextureLayer(m_rtts->getShadowDepthTex(), 0);
|
||||
glViewport(UserConfigParams::m_width / 2, 0, UserConfigParams::m_width / 2, UserConfigParams::m_height / 2);
|
||||
m_post_processing->renderTextureLayer(m_rtts->getShadowDepthTex(), 1);
|
||||
glViewport(0, UserConfigParams::m_height / 2, UserConfigParams::m_width / 2, UserConfigParams::m_height / 2);
|
||||
m_post_processing->renderTextureLayer(m_rtts->getShadowDepthTex(), 2);
|
||||
glViewport(UserConfigParams::m_width / 2, UserConfigParams::m_height / 2, UserConfigParams::m_width / 2, UserConfigParams::m_height / 2);
|
||||
m_post_processing->renderTextureLayer(m_rtts->getShadowDepthTex(), 3);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void IrrDriver::renderGlow(std::vector<GlowData>& glows)
|
||||
|
@ -290,6 +290,7 @@ void Shaders::loadShaders()
|
||||
FullScreenShader::Gaussian6VBlurShader::init();
|
||||
FullScreenShader::GlowShader::init();
|
||||
FullScreenShader::PassThroughShader::init();
|
||||
FullScreenShader::LayerPassThroughShader::init();
|
||||
FullScreenShader::LinearizeDepthShader::init();
|
||||
FullScreenShader::SSAOShader::init();
|
||||
FullScreenShader::SunLightShader::init();
|
||||
@ -2554,6 +2555,20 @@ namespace FullScreenShader
|
||||
vao = createVAO(Program);
|
||||
}
|
||||
|
||||
GLuint LayerPassThroughShader::Program;
|
||||
GLuint LayerPassThroughShader::uniform_texture;
|
||||
GLuint LayerPassThroughShader::uniform_layer;
|
||||
GLuint LayerPassThroughShader::vao;
|
||||
void LayerPassThroughShader::init()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/layertexturequad.frag").c_str());
|
||||
uniform_texture = glGetUniformLocation(Program, "tex");
|
||||
uniform_layer = glGetUniformLocation(Program, "layer");
|
||||
vao = createVAO(Program);
|
||||
}
|
||||
|
||||
GLuint LinearizeDepthShader::Program;
|
||||
GLuint LinearizeDepthShader::uniform_zn;
|
||||
GLuint LinearizeDepthShader::uniform_zf;
|
||||
|
@ -720,6 +720,16 @@ public:
|
||||
static void init();
|
||||
};
|
||||
|
||||
class LayerPassThroughShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_layer, uniform_texture;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
};
|
||||
|
||||
class LinearizeDepthShader
|
||||
{
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user