Support some debug option for GI
This commit is contained in:
parent
af16682a9e
commit
40df4afc74
14
data/shaders/rhdebug.frag
Normal file
14
data/shaders/rhdebug.frag
Normal file
@ -0,0 +1,14 @@
|
||||
uniform sampler3D SHR;
|
||||
uniform sampler3D SHG;
|
||||
uniform sampler3D SHB;
|
||||
|
||||
in vec3 uvw;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
float r = texture(SHR, uvw).w;
|
||||
float g = texture(SHG, uvw).w;
|
||||
float b = texture(SHB, uvw).w;
|
||||
FragColor = max(vec4(r, g, b, 1.0), vec4(0.));
|
||||
}
|
30
data/shaders/rhdebug.vert
Normal file
30
data/shaders/rhdebug.vert
Normal file
@ -0,0 +1,30 @@
|
||||
uniform vec3 extents;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
uniform mat4 RHMatrix;
|
||||
|
||||
ivec3 resolution = ivec3(32, 16, 32);
|
||||
|
||||
out vec3 uvw;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// Determine the RH center
|
||||
float gx = int(gl_VertexID) & (resolution.x - 1);
|
||||
float gy = int(gl_VertexID >> 5) & (resolution.y - 1);
|
||||
float gz = int(gl_VertexID >> 9) & (resolution.z - 1);
|
||||
uvw = vec3(gx, gy, gz) / vec3(resolution);
|
||||
vec3 WorldPos = (2. * uvw - 1.) * extents;
|
||||
gl_Position = ProjectionMatrix * ViewMatrix * RHMatrix * vec4(WorldPos, 1.);
|
||||
gl_PointSize = 100. / gl_Position.w;
|
||||
|
||||
}
|
@ -110,7 +110,7 @@ IrrDriver::IrrDriver()
|
||||
m_post_processing = NULL;
|
||||
m_wind = new Wind();
|
||||
m_mipviz = m_wireframe = m_normals = m_ssaoviz = \
|
||||
m_lightviz = m_shadowviz = m_distortviz = 0;
|
||||
m_lightviz = m_shadowviz = m_distortviz = m_rsm = m_rh = m_gi = 0;
|
||||
SkyboxCubeMap = 0;
|
||||
} // IrrDriver
|
||||
|
||||
|
@ -310,6 +310,9 @@ private:
|
||||
bool m_mipviz;
|
||||
bool m_normals;
|
||||
bool m_ssaoviz;
|
||||
bool m_rsm;
|
||||
bool m_rh;
|
||||
bool m_gi;
|
||||
bool m_shadowviz;
|
||||
bool m_lightviz;
|
||||
bool m_distortviz;
|
||||
@ -575,6 +578,9 @@ public:
|
||||
m_mipviz = false;
|
||||
m_normals = false;
|
||||
m_ssaoviz = false;
|
||||
m_rsm = false;
|
||||
m_rh = false;
|
||||
m_gi = false;
|
||||
m_shadowviz = false;
|
||||
m_lightviz = false;
|
||||
m_distortviz = false;
|
||||
@ -596,6 +602,18 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
bool getSSAOViz() { return m_ssaoviz; }
|
||||
// ------------------------------------------------------------------------
|
||||
void toggleRSM() { m_rsm = !m_rsm; }
|
||||
// ------------------------------------------------------------------------
|
||||
bool getRSM() { return m_rsm; }
|
||||
// ------------------------------------------------------------------------
|
||||
void toggleRH() { m_rh = !m_rh; }
|
||||
// ------------------------------------------------------------------------
|
||||
bool getRH() { return m_rh; }
|
||||
// ------------------------------------------------------------------------
|
||||
void toggleGI() { m_gi = !m_gi; }
|
||||
// ------------------------------------------------------------------------
|
||||
bool getGI() { return m_gi; }
|
||||
// ------------------------------------------------------------------------
|
||||
void toggleShadowViz() { m_shadowviz = !m_shadowviz; }
|
||||
// ------------------------------------------------------------------------
|
||||
bool getShadowViz() { return m_shadowviz; }
|
||||
|
@ -334,8 +334,8 @@ void IrrDriver::renderScene(scene::ICameraSceneNode * const camnode, std::vector
|
||||
glBindTexture(GL_TEXTURE_3D, m_rtts->getRH().getRTT()[1]);
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_3D, m_rtts->getRH().getRTT()[2]);
|
||||
FullScreenShader::RHDebug::setUniforms(rh_extend, 0, 1, 2);
|
||||
glDrawArrays(GL_POINTS, 0, 128 * 128 * 128);
|
||||
FullScreenShader::RHDebug::setUniforms(rh_matrix, rh_extend, 0, 1, 2);
|
||||
glDrawArrays(GL_POINTS, 0, 32 * 16 * 32);
|
||||
glDisable(GL_PROGRAM_POINT_SIZE);
|
||||
}
|
||||
|
||||
|
@ -282,6 +282,7 @@ void Shaders::loadShaders()
|
||||
FullScreenShader::ShadowedSunLightShader::init();
|
||||
FullScreenShader::ShadowedSunLightDebugShader::init();
|
||||
FullScreenShader::RadianceHintsConstructionShader::init();
|
||||
FullScreenShader::RHDebug::init();
|
||||
FullScreenShader::GlobalIlluminationReconstructionShader::init();
|
||||
FullScreenShader::MotionBlurShader::init();
|
||||
FullScreenShader::GodFadeShader::init();
|
||||
@ -2352,6 +2353,36 @@ namespace FullScreenShader
|
||||
glUniform3f(uniform_extents, extents.X, extents.Y, extents.Z);
|
||||
}
|
||||
|
||||
GLuint RHDebug::Program;
|
||||
GLuint RHDebug::uniform_extents;
|
||||
GLuint RHDebug::uniform_SHR;
|
||||
GLuint RHDebug::uniform_SHG;
|
||||
GLuint RHDebug::uniform_SHB;
|
||||
GLuint RHDebug::uniform_RHMatrix;
|
||||
|
||||
void RHDebug::init()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/rhdebug.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/rhdebug.frag").c_str());
|
||||
uniform_extents = glGetUniformLocation(Program, "extents");
|
||||
uniform_SHR = glGetUniformLocation(Program, "SHR");
|
||||
uniform_SHG = glGetUniformLocation(Program, "SHG");
|
||||
uniform_SHB = glGetUniformLocation(Program, "SHB");
|
||||
uniform_RHMatrix = glGetUniformLocation(Program, "RHMatrix");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
void RHDebug::setUniforms(const core::matrix4 &RHMatrix, const core::vector3df &extents, unsigned TU_SHR, unsigned TU_SHG, unsigned TU_SHB)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_RHMatrix, 1, GL_FALSE, RHMatrix.pointer());
|
||||
glUniform3f(uniform_extents, extents.X, extents.Y, extents.Z);
|
||||
glUniform1i(uniform_SHR, TU_SHR);
|
||||
glUniform1i(uniform_SHG, TU_SHG);
|
||||
glUniform1i(uniform_SHB, TU_SHB);
|
||||
}
|
||||
|
||||
GLuint GlobalIlluminationReconstructionShader::Program;
|
||||
GLuint GlobalIlluminationReconstructionShader::uniform_ntex;
|
||||
GLuint GlobalIlluminationReconstructionShader::uniform_dtex;
|
||||
|
@ -620,6 +620,16 @@ public:
|
||||
static void setUniforms(const core::matrix4 &RSMMatrix, const core::matrix4 &RHMatrix, const core::vector3df &extents, unsigned TU_ctex, unsigned TU_ntex, unsigned TU_dtex);
|
||||
};
|
||||
|
||||
class RHDebug
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_extents, uniform_SHR, uniform_SHG, uniform_SHB, uniform_RHMatrix;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &RHMatrix, const core::vector3df &extents, unsigned TU_SHR, unsigned TU_SHG, unsigned TU_SHB);
|
||||
};
|
||||
|
||||
class GlobalIlluminationReconstructionShader
|
||||
{
|
||||
public:
|
||||
|
@ -54,6 +54,9 @@ enum DebugMenuCommand
|
||||
DEBUG_GRAPHICS_MIPMAP_VIZ,
|
||||
DEBUG_GRAPHICS_NORMALS_VIZ,
|
||||
DEBUG_GRAPHICS_SSAO_VIZ,
|
||||
DEBUG_GRAPHICS_RSM_VIZ,
|
||||
DEBUG_GRAPHICS_RH_VIZ,
|
||||
DEBUG_GRAPHICS_GI_VIZ,
|
||||
DEBUG_GRAPHICS_SHADOW_VIZ,
|
||||
DEBUG_GRAPHICS_LIGHT_VIZ,
|
||||
DEBUG_GRAPHICS_DISTORT_VIZ,
|
||||
@ -157,6 +160,9 @@ bool onEvent(const SEvent &event)
|
||||
sub->addItem(L"Mipmap viz", DEBUG_GRAPHICS_MIPMAP_VIZ );
|
||||
sub->addItem(L"Normals viz", DEBUG_GRAPHICS_NORMALS_VIZ );
|
||||
sub->addItem(L"SSAO viz", DEBUG_GRAPHICS_SSAO_VIZ );
|
||||
sub->addItem(L"RSM viz", DEBUG_GRAPHICS_RSM_VIZ);
|
||||
sub->addItem(L"RH viz", DEBUG_GRAPHICS_RH_VIZ);
|
||||
sub->addItem(L"GI viz", DEBUG_GRAPHICS_GI_VIZ);
|
||||
sub->addItem(L"Shadow viz", DEBUG_GRAPHICS_SHADOW_VIZ );
|
||||
sub->addItem(L"Light viz", DEBUG_GRAPHICS_LIGHT_VIZ );
|
||||
sub->addItem(L"Distort viz", DEBUG_GRAPHICS_DISTORT_VIZ );
|
||||
@ -265,6 +271,30 @@ bool onEvent(const SEvent &event)
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleSSAOViz();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_RSM_VIZ)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleRSM();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_RH_VIZ)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleRH();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_GI_VIZ)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleGI();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_SHADOW_VIZ)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
|
Loading…
x
Reference in New Issue
Block a user