Port RHDebug and Passthrough Layer
This commit is contained in:
parent
0dd1fd605c
commit
03a6499c27
@ -457,15 +457,14 @@ void PostProcessing::renderPassThrough(GLuint tex)
|
||||
|
||||
void PostProcessing::renderTextureLayer(unsigned tex, unsigned layer)
|
||||
{
|
||||
glUseProgram(FullScreenShader::LayerPassThroughShader::Program);
|
||||
glBindVertexArray(FullScreenShader::LayerPassThroughShader::vao);
|
||||
glUseProgram(FullScreenShader::LayerPassThroughShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::LayerPassThroughShader::getInstance()->vao);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTexture(GL_TEXTURE0 + FullScreenShader::LayerPassThroughShader::getInstance()->TU_texture);
|
||||
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);
|
||||
FullScreenShader::LayerPassThroughShader::getInstance()->setUniforms(layer);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
@ -342,14 +342,14 @@ void IrrDriver::renderScene(scene::ICameraSceneNode * const camnode, unsigned po
|
||||
{
|
||||
glEnable(GL_PROGRAM_POINT_SIZE);
|
||||
m_rtts->getFBO(FBO_COLORS).Bind();
|
||||
glUseProgram(FullScreenShader::RHDebug::Program);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glUseProgram(FullScreenShader::RHDebug::getInstance()->Program);
|
||||
glActiveTexture(GL_TEXTURE0 + FullScreenShader::RHDebug::getInstance()->TU_SHR);
|
||||
glBindTexture(GL_TEXTURE_3D, m_rtts->getRH().getRTT()[0]);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glActiveTexture(GL_TEXTURE0 + FullScreenShader::RHDebug::getInstance()->TU_SHG);
|
||||
glBindTexture(GL_TEXTURE_3D, m_rtts->getRH().getRTT()[1]);
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glActiveTexture(GL_TEXTURE0 + FullScreenShader::RHDebug::getInstance()->TU_SHB);
|
||||
glBindTexture(GL_TEXTURE_3D, m_rtts->getRH().getRTT()[2]);
|
||||
FullScreenShader::RHDebug::setUniforms(rh_matrix, rh_extend, 0, 1, 2);
|
||||
FullScreenShader::RHDebug::getInstance()->setUniforms(rh_matrix, rh_extend);
|
||||
glDrawArrays(GL_POINTS, 0, 32 * 16 * 32);
|
||||
glDisable(GL_PROGRAM_POINT_SIZE);
|
||||
}
|
||||
|
@ -373,9 +373,7 @@ void Shaders::loadShaders()
|
||||
initCubeVBO();
|
||||
initFrustrumVBO();
|
||||
initShadowVPMUBO();
|
||||
FullScreenShader::LayerPassThroughShader::init();
|
||||
FullScreenShader::DiffuseEnvMapShader::init();
|
||||
FullScreenShader::RHDebug::init();
|
||||
MeshShader::BubbleShader::init();
|
||||
LightShader::PointLightShader::init();
|
||||
MeshShader::SkyboxShader::init();
|
||||
@ -564,6 +562,11 @@ void glUniform1fWrapper(GLuint a, float b)
|
||||
glUniform1f(a, b);
|
||||
}
|
||||
|
||||
void glUniform1iWrapper(GLuint a, int b)
|
||||
{
|
||||
glUniform1i(a, b);
|
||||
}
|
||||
|
||||
bool needsUBO()
|
||||
{
|
||||
return irr_driver->needUBOWorkaround();
|
||||
@ -1688,36 +1691,20 @@ namespace FullScreenShader
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
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()
|
||||
RHDebug::RHDebug()
|
||||
{
|
||||
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");
|
||||
AssignUniforms("RHMatrix", "extents");
|
||||
TU_SHR = 0;
|
||||
TU_SHG = 1;
|
||||
TU_SHB = 2;
|
||||
AssignTextureUnit(Program, TexUnit(TU_SHR, "SHR"), TexUnit(TU_SHG, "SHG"), TexUnit(TU_SHB, "SHB"));
|
||||
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);
|
||||
}
|
||||
|
||||
GlobalIlluminationReconstructionShader::GlobalIlluminationReconstructionShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
@ -1846,17 +1833,14 @@ namespace FullScreenShader
|
||||
vao = createVAO(Program);
|
||||
}
|
||||
|
||||
GLuint LayerPassThroughShader::Program;
|
||||
GLuint LayerPassThroughShader::uniform_texture;
|
||||
GLuint LayerPassThroughShader::uniform_layer;
|
||||
GLuint LayerPassThroughShader::vao;
|
||||
void LayerPassThroughShader::init()
|
||||
LayerPassThroughShader::LayerPassThroughShader()
|
||||
{
|
||||
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");
|
||||
TU_texture = 0;
|
||||
AssignUniforms("layer");
|
||||
AssignTextureUnit(Program, TexUnit(TU_texture, "tex"));
|
||||
vao = createVAO(Program);
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ void glUniform3fWraper(GLuint, float, float, float);
|
||||
void glUniform4iWraper(GLuint, int, int, int, int);
|
||||
void glUniform2fWraper(GLuint a, float b, float c);
|
||||
void glUniform1fWrapper(GLuint, float);
|
||||
void glUniform1iWrapper(GLuint, int);
|
||||
bool needsUBO();
|
||||
|
||||
struct UniformHelper
|
||||
@ -116,6 +117,13 @@ struct UniformHelper
|
||||
setUniformsHelper<N + 1>(uniforms, arg...);
|
||||
}
|
||||
|
||||
template<unsigned N = 0, typename... Args>
|
||||
static void setUniformsHelper(const std::vector<GLuint> &uniforms, int f, Args... arg)
|
||||
{
|
||||
glUniform1iWrapper(uniforms[N], f);
|
||||
setUniformsHelper<N + 1>(uniforms, arg...);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void bypassUBO(GLuint Program);
|
||||
@ -593,14 +601,12 @@ public:
|
||||
RadianceHintsConstructionShader();
|
||||
};
|
||||
|
||||
class RHDebug
|
||||
class RHDebug : public ShaderHelperSingleton<RHDebug, core::matrix4, core::vector3df>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_extents, uniform_SHR, uniform_SHG, uniform_SHB, uniform_RHMatrix;
|
||||
GLuint TU_SHR, TU_SHG, TU_SHB;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &RHMatrix, const core::vector3df &extents, unsigned TU_SHR, unsigned TU_SHG, unsigned TU_SHB);
|
||||
RHDebug();
|
||||
};
|
||||
|
||||
class GlobalIlluminationReconstructionShader : public ShaderHelperSingleton<GlobalIlluminationReconstructionShader, core::matrix4, core::matrix4, core::vector3df>
|
||||
@ -691,14 +697,13 @@ public:
|
||||
PassThroughShader();
|
||||
};
|
||||
|
||||
class LayerPassThroughShader
|
||||
class LayerPassThroughShader : public ShaderHelperSingleton<LayerPassThroughShader, int>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_layer, uniform_texture;
|
||||
static GLuint vao;
|
||||
GLuint TU_texture;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
LayerPassThroughShader();
|
||||
};
|
||||
|
||||
class LinearizeDepthShader : public ShaderHelperSingleton<LinearizeDepthShader, float, float>
|
||||
|
Loading…
Reference in New Issue
Block a user