Merge branch 'master' of github.com:supertuxkart/stk-code
This commit is contained in:
commit
5a67fa50a9
@ -19,22 +19,20 @@ before_install:
|
||||
# so we try to use trusty (precise which is what traiv uses a too old mesa version which doesn't link)
|
||||
- sudo apt-add-repository "deb http://archive.ubuntu.com/ubuntu trusty main restricted"
|
||||
- sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32
|
||||
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev
|
||||
- sudo apt-get -qq install g++-4.8
|
||||
script:
|
||||
# First a debug build:
|
||||
- mkdir build-debug
|
||||
- cd build-debug
|
||||
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DCHECK_ASSETS=off -DCMAKE_CXX_COMPILER=/usr/bin/g++-4.8 -DCMAKE_C_COMPILER=/usr/bin/gcc-4.8
|
||||
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DCHECK_ASSETS=off
|
||||
- make VERBOSE=1 -j 4
|
||||
|
||||
# Then a release build:
|
||||
- cd ..
|
||||
- mkdir build-release
|
||||
- cd build-release
|
||||
- cmake .. -DCMAKE_BUILD_TYPE=Release -DCHECK_ASSETS=off -DCMAKE_CXX_COMPILER=/usr/bin/g++-4.8 -DCMAKE_C_COMPILER=/usr/bin/gcc-4.8
|
||||
- cmake .. -DCMAKE_BUILD_TYPE=Release -DCHECK_ASSETS=off
|
||||
- make VERBOSE=1 -j 4
|
||||
|
||||
notifications:
|
||||
|
@ -30,6 +30,7 @@ endif()
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
option(USE_XRANDR "Use xrandr instead of vidmode" ON)
|
||||
option(USE_ASAN "Build with Leak/Address sanitizer" OFF)
|
||||
endif()
|
||||
|
||||
set(STK_SOURCE_DIR "src")
|
||||
@ -254,6 +255,11 @@ if(UNIX AND NOT APPLE)
|
||||
else()
|
||||
target_link_libraries(supertuxkart ${IRRLICHT_XF86VM_LIBRARY})
|
||||
endif()
|
||||
if(USE_ASAN)
|
||||
add_definitions("-fsanitize=address")
|
||||
add_definitions("-fno-omit-frame-pointer")
|
||||
target_link_libraries(supertuxkart "-fsanitize=address")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
|
@ -1,14 +1,15 @@
|
||||
#if __VERSION__ >= 330
|
||||
layout(location = 0) in vec2 Position;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
#else
|
||||
in vec2 Position;
|
||||
in vec2 Texcoord;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
out vec2 uv;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
#endif
|
||||
|
||||
out vec2 uv;
|
||||
|
||||
void main() {
|
||||
uv = Texcoord;
|
||||
gl_Position = vec4(Position, 0., 1.);
|
||||
void main()
|
||||
{
|
||||
uv = Texcoord;
|
||||
gl_Position = vec4(Position, 0., 1.);
|
||||
}
|
||||
|
@ -204,16 +204,20 @@ void PostProcessing::update(float dt)
|
||||
}
|
||||
} // update
|
||||
|
||||
template<typename T,typename... Args>
|
||||
static void DrawFullScreenEffect(Args...args)
|
||||
{
|
||||
glUseProgram(T::getInstance()->Program);
|
||||
glBindVertexArray(SharedObject::FullScreenQuadVAO);
|
||||
T::getInstance()->setUniforms(args...);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
}
|
||||
|
||||
static
|
||||
void renderBloom(GLuint in)
|
||||
{
|
||||
glUseProgram(FullScreenShader::BloomShader::Program);
|
||||
glBindVertexArray(FullScreenShader::BloomShader::vao);
|
||||
|
||||
setTexture(0, in, GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::BloomShader::setUniforms(0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
setTexture(FullScreenShader::BloomShader::getInstance()->TU_tex, in, GL_NEAREST, GL_NEAREST);
|
||||
DrawFullScreenEffect<FullScreenShader::BloomShader>();
|
||||
}
|
||||
|
||||
void PostProcessing::renderDiffuseEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff)
|
||||
@ -224,7 +228,7 @@ void PostProcessing::renderDiffuseEnvMap(const float *bSHCoeff, const float *gSH
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
|
||||
glUseProgram(FullScreenShader::DiffuseEnvMapShader::Program);
|
||||
glBindVertexArray(FullScreenShader::DiffuseEnvMapShader::vao);
|
||||
glBindVertexArray(SharedObject::FullScreenQuadVAO);
|
||||
|
||||
setTexture(0, irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), GL_NEAREST, GL_NEAREST);
|
||||
core::matrix4 TVM = irr_driver->getViewMatrix().getTransposed();
|
||||
@ -238,13 +242,27 @@ void PostProcessing::renderDiffuseEnvMap(const float *bSHCoeff, const float *gSH
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
|
||||
void PostProcessing::renderRHDebug(unsigned SHR, unsigned SHG, unsigned SHB, const core::matrix4 &rh_matrix, const core::vector3df &rh_extend)
|
||||
{
|
||||
glEnable(GL_PROGRAM_POINT_SIZE);
|
||||
glUseProgram(FullScreenShader::RHDebug::getInstance()->Program);
|
||||
glActiveTexture(GL_TEXTURE0 + FullScreenShader::RHDebug::getInstance()->TU_SHR);
|
||||
glBindTexture(GL_TEXTURE_3D, SHR);
|
||||
glActiveTexture(GL_TEXTURE0 + FullScreenShader::RHDebug::getInstance()->TU_SHG);
|
||||
glBindTexture(GL_TEXTURE_3D, SHG);
|
||||
glActiveTexture(GL_TEXTURE0 + FullScreenShader::RHDebug::getInstance()->TU_SHB);
|
||||
glBindTexture(GL_TEXTURE_3D, SHB);
|
||||
FullScreenShader::RHDebug::getInstance()->setUniforms(rh_matrix, rh_extend);
|
||||
glDrawArrays(GL_POINTS, 0, 32 * 16 * 32);
|
||||
glDisable(GL_PROGRAM_POINT_SIZE);
|
||||
}
|
||||
|
||||
void PostProcessing::renderGI(const core::matrix4 &RHMatrix, const core::vector3df &rh_extend, GLuint shr, GLuint shg, GLuint shb)
|
||||
{
|
||||
core::matrix4 InvRHMatrix;
|
||||
RHMatrix.getInverse(InvRHMatrix);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glUseProgram(FullScreenShader::GlobalIlluminationReconstructionShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::GlobalIlluminationReconstructionShader::getInstance()->vao);
|
||||
glActiveTexture(GL_TEXTURE0 + FullScreenShader::GlobalIlluminationReconstructionShader::getInstance()->TU_SHR);
|
||||
glBindTexture(GL_TEXTURE_3D, shr);
|
||||
{
|
||||
@ -265,8 +283,7 @@ void PostProcessing::renderGI(const core::matrix4 &RHMatrix, const core::vector3
|
||||
}
|
||||
setTexture(FullScreenShader::GlobalIlluminationReconstructionShader::getInstance()->TU_ntex, irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(FullScreenShader::GlobalIlluminationReconstructionShader::getInstance()->TU_dtex, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::GlobalIlluminationReconstructionShader::getInstance()->setUniforms(RHMatrix, InvRHMatrix, rh_extend);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::GlobalIlluminationReconstructionShader>(RHMatrix, InvRHMatrix, rh_extend);
|
||||
}
|
||||
|
||||
void PostProcessing::renderSunlight()
|
||||
@ -278,13 +295,9 @@ void PostProcessing::renderSunlight()
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
||||
glUseProgram(FullScreenShader::SunLightShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::SunLightShader::getInstance()->vao);
|
||||
setTexture(FullScreenShader::SunLightShader::getInstance()->TU_ntex, irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(FullScreenShader::SunLightShader::getInstance()->TU_dtex, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::SunLightShader::getInstance()->setUniforms(cb->getPosition(), video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
glBindVertexArray(0);
|
||||
DrawFullScreenEffect<FullScreenShader::SunLightShader>(cb->getPosition(), video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
}
|
||||
|
||||
void PostProcessing::renderShadowedSunlight(const std::vector<core::matrix4> &sun_ortho_matrix, GLuint depthtex)
|
||||
@ -307,12 +320,7 @@ void PostProcessing::renderShadowedSunlight(const std::vector<core::matrix4> &su
|
||||
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
||||
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
|
||||
|
||||
glUseProgram(FullScreenShader::ShadowedSunLightShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::ShadowedSunLightShader::getInstance()->vao);
|
||||
FullScreenShader::ShadowedSunLightShader::getInstance()->setUniforms(cb->getPosition(), video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
glBindVertexArray(0);
|
||||
DrawFullScreenEffect<FullScreenShader::ShadowedSunLightShader>(cb->getPosition(), video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
}
|
||||
|
||||
|
||||
@ -322,31 +330,19 @@ void PostProcessing::renderGaussian3Blur(FrameBuffer &in_fbo, FrameBuffer &auxil
|
||||
float inv_width = 1.0f / in_fbo.getWidth(), inv_height = 1.0f / in_fbo.getHeight();
|
||||
{
|
||||
auxiliary.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian3VBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian3VBlurShader::vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian3VBlurShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
setTexture(0, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::Gaussian3VBlurShader::getInstance()->TU_tex, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glUniform1i(FullScreenShader::Gaussian3VBlurShader::uniform_tex, 0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::Gaussian3VBlurShader>(core::vector2df(inv_width, inv_height));
|
||||
}
|
||||
{
|
||||
in_fbo.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian3HBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian3HBlurShader::vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian3HBlurShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
setTexture(0, auxiliary.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::Gaussian3HBlurShader::getInstance()->TU_tex, auxiliary.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glUniform1i(FullScreenShader::Gaussian3HBlurShader::uniform_tex, 0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::Gaussian3HBlurShader>(core::vector2df(inv_width, inv_height));
|
||||
}
|
||||
}
|
||||
|
||||
@ -356,31 +352,19 @@ void PostProcessing::renderGaussian6Blur(FrameBuffer &in_fbo, FrameBuffer &auxil
|
||||
float inv_width = 1.0f / in_fbo.getWidth(), inv_height = 1.0f / in_fbo.getHeight();
|
||||
{
|
||||
auxiliary.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian6VBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian6VBlurShader::vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian6VBlurShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
setTexture(0, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::Gaussian6VBlurShader::getInstance()->TU_tex, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glUniform1i(FullScreenShader::Gaussian6VBlurShader::uniform_tex, 0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::Gaussian6VBlurShader>(core::vector2df(inv_width, inv_height));
|
||||
}
|
||||
{
|
||||
in_fbo.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian6HBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian6HBlurShader::vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian6HBlurShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
setTexture(0, auxiliary.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::Gaussian6HBlurShader::getInstance()->TU_tex, auxiliary.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glUniform1i(FullScreenShader::Gaussian6HBlurShader::uniform_tex, 0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::Gaussian6HBlurShader>(core::vector2df(inv_width, inv_height));
|
||||
}
|
||||
}
|
||||
|
||||
@ -394,33 +378,24 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
|
||||
#endif
|
||||
{
|
||||
auxiliary.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian17TapHShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian17TapHShader::vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian17TapHShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
setTexture(0, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::Gaussian17TapHShader::getInstance()->TU_tex, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
setTexture(1, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::Gaussian17TapHShader::getInstance()->TU_depth, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glUniform1i(FullScreenShader::Gaussian17TapHShader::uniform_tex, 0);
|
||||
glUniform1i(FullScreenShader::Gaussian17TapHShader::uniform_depth, 1);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::Gaussian17TapHShader>(core::vector2df(inv_width, inv_height));
|
||||
}
|
||||
#if WIN32
|
||||
else
|
||||
{
|
||||
|
||||
glUseProgram(FullScreenShader::ComputeGaussian17TapHShader::Program);
|
||||
glBindImageTexture(0, in_fbo.getRTT()[0], 0, false, 0, GL_READ_ONLY, GL_R16F);
|
||||
glBindImageTexture(1, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], 1, false, 0, GL_READ_ONLY, GL_R32F);
|
||||
glBindImageTexture(2, auxiliary.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R16F);
|
||||
glUniform1i(FullScreenShader::ComputeGaussian17TapHShader::uniform_source, 0);
|
||||
glUniform1i(FullScreenShader::ComputeGaussian17TapHShader::uniform_depth, 1);
|
||||
glUniform1i(FullScreenShader::ComputeGaussian17TapHShader::uniform_dest, 2);
|
||||
glUseProgram(FullScreenShader::ComputeGaussian17TapHShader::getInstance()->Program);
|
||||
glBindImageTexture(FullScreenShader::ComputeGaussian17TapHShader::getInstance()->TU_source, in_fbo.getRTT()[0], 0, false, 0, GL_READ_ONLY, GL_R16F);
|
||||
glBindImageTexture(FullScreenShader::ComputeGaussian17TapHShader::getInstance()->TU_depth, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], 1, false, 0, GL_READ_ONLY, GL_R32F);
|
||||
glBindImageTexture(FullScreenShader::ComputeGaussian17TapHShader::getInstance()->TU_dest, auxiliary.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R16F);
|
||||
FullScreenShader::ComputeGaussian17TapHShader::getInstance()->setUniforms();
|
||||
glDispatchCompute(in_fbo.getWidth() / 8, in_fbo.getHeight() / 8, 1);
|
||||
}
|
||||
#endif
|
||||
@ -431,32 +406,23 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
|
||||
#endif
|
||||
{
|
||||
in_fbo.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian17TapVShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian17TapVShader::vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian17TapVShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
setTexture(0, auxiliary.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::Gaussian17TapVShader::getInstance()->TU_tex, auxiliary.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
setTexture(1, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::Gaussian17TapVShader::getInstance()->TU_depth, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glUniform1i(FullScreenShader::Gaussian17TapVShader::uniform_tex, 0);
|
||||
glUniform1i(FullScreenShader::Gaussian17TapVShader::uniform_depth, 1);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::Gaussian17TapVShader>(core::vector2df(inv_width, inv_height));
|
||||
}
|
||||
#if WIN32
|
||||
else
|
||||
{
|
||||
glUseProgram(FullScreenShader::ComputeGaussian17TapVShader::Program);
|
||||
glBindImageTexture(0, auxiliary.getRTT()[0], 0, false, 0, GL_READ_ONLY, GL_R16F);
|
||||
glBindImageTexture(1, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], 1, false, 0, GL_READ_ONLY, GL_R32F);
|
||||
glBindImageTexture(2, in_fbo.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R16F);
|
||||
glUniform1i(FullScreenShader::ComputeGaussian17TapVShader::uniform_source, 0);
|
||||
glUniform1i(FullScreenShader::ComputeGaussian17TapVShader::uniform_depth, 1);
|
||||
glUniform1i(FullScreenShader::ComputeGaussian17TapVShader::uniform_dest, 2);
|
||||
glUseProgram(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->Program);
|
||||
glBindImageTexture(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->TU_source, auxiliary.getRTT()[0], 0, false, 0, GL_READ_ONLY, GL_R16F);
|
||||
glBindImageTexture(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->TU_depth, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], 1, false, 0, GL_READ_ONLY, GL_R32F);
|
||||
glBindImageTexture(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->TU_dest, in_fbo.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R16F);
|
||||
FullScreenShader::ComputeGaussian17TapVShader::getInstance()->setUniforms();
|
||||
glDispatchCompute(in_fbo.getWidth() / 8, in_fbo.getHeight() / 8, 1);
|
||||
}
|
||||
#endif
|
||||
@ -465,48 +431,40 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
|
||||
|
||||
void PostProcessing::renderPassThrough(GLuint tex)
|
||||
{
|
||||
glUseProgram(FullScreenShader::PassThroughShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::PassThroughShader::getInstance()->vao);
|
||||
|
||||
glUseProgram(FullScreenShader::PassThroughShader::Program);
|
||||
glBindVertexArray(FullScreenShader::PassThroughShader::vao);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glUniform1i(FullScreenShader::PassThroughShader::uniform_texture, 0);
|
||||
setTexture(FullScreenShader::PassThroughShader::getInstance()->TU_tex, tex, GL_LINEAR, GL_LINEAR);
|
||||
FullScreenShader::PassThroughShader::getInstance()->setUniforms();
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void PostProcessing::renderGlow(unsigned tex)
|
||||
{
|
||||
glUseProgram(FullScreenShader::GlowShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::GlowShader::getInstance()->vao);
|
||||
|
||||
glUseProgram(FullScreenShader::GlowShader::Program);
|
||||
glBindVertexArray(FullScreenShader::GlowShader::vao);
|
||||
|
||||
setTexture(0, tex, GL_LINEAR, GL_LINEAR);
|
||||
glUniform1i(FullScreenShader::GlowShader::uniform_tex, 0);
|
||||
setTexture(FullScreenShader::GlowShader::getInstance()->TU_tex, tex, GL_LINEAR, GL_LINEAR);
|
||||
FullScreenShader::GlowShader::getInstance()->setUniforms();
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
ITexture *noise_tex = 0;
|
||||
|
||||
void PostProcessing::renderSSAO()
|
||||
{
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
@ -515,25 +473,14 @@ void PostProcessing::renderSSAO()
|
||||
|
||||
// Generate linear depth buffer
|
||||
irr_driver->getFBO(FBO_LINEAR_DEPTH).Bind();
|
||||
glUseProgram(FullScreenShader::LinearizeDepthShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::LinearizeDepthShader::getInstance()->vao);
|
||||
setTexture(FullScreenShader::LinearizeDepthShader::getInstance()->TU_tex, irr_driver->getDepthStencilTexture(), GL_LINEAR, GL_LINEAR);
|
||||
FullScreenShader::LinearizeDepthShader::getInstance()->setUniforms(irr_driver->getSceneManager()->getActiveCamera()->getNearValue(), irr_driver->getSceneManager()->getActiveCamera()->getFarValue());
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::LinearizeDepthShader>(irr_driver->getSceneManager()->getActiveCamera()->getNearValue(), irr_driver->getSceneManager()->getActiveCamera()->getFarValue());
|
||||
irr_driver->getFBO(FBO_SSAO).Bind();
|
||||
|
||||
if (!noise_tex)
|
||||
noise_tex = irr_driver->getTexture(file_manager->getAsset("textures/noise.png").c_str());
|
||||
|
||||
glUseProgram(FullScreenShader::SSAOShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::SSAOShader::getInstance()->vao);
|
||||
|
||||
setTexture(FullScreenShader::SSAOShader::getInstance()->TU_dtex, irr_driver->getRenderTargetTexture(RTT_LINEAR_DEPTH), GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
|
||||
FullScreenShader::SSAOShader::getInstance()->setUniforms(irr_driver->getSSAORadius(), irr_driver->getSSAOK(), irr_driver->getSSAOSigma());
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::SSAOShader>(irr_driver->getSSAORadius(), irr_driver->getSSAOK(), irr_driver->getSSAOSigma());
|
||||
}
|
||||
|
||||
void PostProcessing::renderFog()
|
||||
@ -557,16 +504,10 @@ void PostProcessing::renderFog()
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glUseProgram(FullScreenShader::FogShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::FogShader::getInstance()->vao);
|
||||
|
||||
setTexture(FullScreenShader::FogShader::getInstance()->TU_tex, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::FogShader::getInstance()->setUniforms(fogmax, startH, endH, start, end, col);
|
||||
DrawFullScreenEffect<FullScreenShader::FogShader>(fogmax, startH, endH, start, end, col);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
@ -592,40 +533,34 @@ void PostProcessing::renderMotionBlur(unsigned cam, FrameBuffer &in_fbo, FrameBu
|
||||
out_fbo.Bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glUseProgram(FullScreenShader::MotionBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::MotionBlurShader::vao);
|
||||
|
||||
setTexture(0, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::MotionBlurShader::getInstance()->TU_cb, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
setTexture(1, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::MotionBlurShader
|
||||
::setUniforms(cb->getBoostTime(0) * 10, // Todo : should be framerate dependent
|
||||
setTexture(FullScreenShader::MotionBlurShader::getInstance()->TU_dtex, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
DrawFullScreenEffect<FullScreenShader::MotionBlurShader>(
|
||||
// Todo : use a previousPVMatrix per cam, not global
|
||||
irr_driver->getPreviousPVMatrix(),
|
||||
cb->getCenter(cam),
|
||||
0.15f,
|
||||
0, 1);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
cb->getBoostTime(0) * 10, // Todo : should be framerate dependent
|
||||
0.15f);
|
||||
}
|
||||
|
||||
static void renderGodFade(GLuint tex, const SColor &col)
|
||||
{
|
||||
glUseProgram(FullScreenShader::GodFadeShader::Program);
|
||||
glBindVertexArray(FullScreenShader::GodFadeShader::vao);
|
||||
setTexture(0, tex, GL_LINEAR, GL_LINEAR);
|
||||
FullScreenShader::GodFadeShader::setUniforms(col, 0);
|
||||
glUseProgram(FullScreenShader::GodFadeShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::GodFadeShader::getInstance()->vao);
|
||||
setTexture(FullScreenShader::GodFadeShader::getInstance()->TU_tex, tex, GL_LINEAR, GL_LINEAR);
|
||||
FullScreenShader::GodFadeShader::getInstance()->setUniforms(col);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
static void renderGodRay(GLuint tex, const core::vector2df &sunpos)
|
||||
{
|
||||
glUseProgram(FullScreenShader::GodRayShader::Program);
|
||||
glBindVertexArray(FullScreenShader::GodRayShader::vao);
|
||||
setTexture(0, tex, GL_LINEAR, GL_LINEAR);
|
||||
FullScreenShader::GodRayShader::setUniforms(sunpos, 0);
|
||||
glUseProgram(FullScreenShader::GodRayShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::GodRayShader::getInstance()->vao);
|
||||
setTexture(FullScreenShader::GodRayShader::getInstance()->TU_tex, tex, GL_LINEAR, GL_LINEAR);
|
||||
FullScreenShader::GodRayShader::getInstance()->setUniforms(sunpos);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
@ -633,31 +568,16 @@ static void renderGodRay(GLuint tex, const core::vector2df &sunpos)
|
||||
static void toneMap(FrameBuffer &fbo, GLuint rtt)
|
||||
{
|
||||
fbo.Bind();
|
||||
glUseProgram(FullScreenShader::ToneMapShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::ToneMapShader::getInstance()->vao);
|
||||
setTexture(FullScreenShader::ToneMapShader::getInstance()->TU_tex, rtt, GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::ToneMapShader::getInstance()->setUniforms();
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::ToneMapShader>();
|
||||
}
|
||||
|
||||
static void renderDoF(FrameBuffer &fbo, GLuint rtt)
|
||||
{
|
||||
fbo.Bind();
|
||||
glUseProgram(FullScreenShader::DepthOfFieldShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::DepthOfFieldShader::getInstance()->vao);
|
||||
setTexture(FullScreenShader::DepthOfFieldShader::getInstance()->TU_tex, rtt, GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::DepthOfFieldShader::getInstance()->TU_depth, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::DepthOfFieldShader::getInstance()->setUniforms();
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
}
|
||||
|
||||
static void averageTexture(GLuint tex)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
DrawFullScreenEffect<FullScreenShader::DepthOfFieldShader>();
|
||||
}
|
||||
|
||||
void PostProcessing::applyMLAA()
|
||||
@ -672,11 +592,11 @@ void PostProcessing::applyMLAA()
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||
|
||||
// Pass 1: color edge detection
|
||||
setTexture(0, irr_driver->getRenderTargetTexture(RTT_MLAA_COLORS), GL_NEAREST, GL_NEAREST);
|
||||
glUseProgram(FullScreenShader::MLAAColorEdgeDetectionSHader::Program);
|
||||
FullScreenShader::MLAAColorEdgeDetectionSHader::setUniforms(PIXEL_SIZE, 0);
|
||||
setTexture(FullScreenShader::MLAAColorEdgeDetectionSHader::getInstance()->TU_colorMapG, irr_driver->getRenderTargetTexture(RTT_MLAA_COLORS), GL_NEAREST, GL_NEAREST);
|
||||
glUseProgram(FullScreenShader::MLAAColorEdgeDetectionSHader::getInstance()->Program);
|
||||
FullScreenShader::MLAAColorEdgeDetectionSHader::getInstance()->setUniforms(PIXEL_SIZE);
|
||||
|
||||
glBindVertexArray(FullScreenShader::MLAAColorEdgeDetectionSHader::vao);
|
||||
glBindVertexArray(FullScreenShader::MLAAColorEdgeDetectionSHader::getInstance()->vao);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
glStencilFunc(GL_EQUAL, 1, ~0);
|
||||
@ -686,12 +606,12 @@ void PostProcessing::applyMLAA()
|
||||
irr_driver->getFBO(FBO_MLAA_BLEND).Bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glUseProgram(FullScreenShader::MLAABlendWeightSHader::Program);
|
||||
setTexture(0, irr_driver->getRenderTargetTexture(RTT_MLAA_TMP), GL_LINEAR, GL_LINEAR);
|
||||
setTexture(1, getTextureGLuint(m_areamap), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::MLAABlendWeightSHader::setUniforms(PIXEL_SIZE, 0, 1);
|
||||
glUseProgram(FullScreenShader::MLAABlendWeightSHader::getInstance()->Program);
|
||||
setTexture(FullScreenShader::MLAABlendWeightSHader::getInstance()->TU_edgesMap, irr_driver->getRenderTargetTexture(RTT_MLAA_TMP), GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::MLAABlendWeightSHader::getInstance()->TU_areaMap, getTextureGLuint(m_areamap), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::MLAABlendWeightSHader::getInstance()->setUniforms(PIXEL_SIZE);
|
||||
|
||||
glBindVertexArray(FullScreenShader::MLAABlendWeightSHader::vao);
|
||||
glBindVertexArray(FullScreenShader::MLAABlendWeightSHader::getInstance()->vao);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
// Blit in to tmp1
|
||||
@ -700,12 +620,12 @@ void PostProcessing::applyMLAA()
|
||||
// Pass 3: gather
|
||||
irr_driver->getFBO(FBO_MLAA_COLORS).Bind();
|
||||
|
||||
glUseProgram(FullScreenShader::MLAAGatherSHader::Program);
|
||||
setTexture(0, irr_driver->getRenderTargetTexture(RTT_MLAA_TMP), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(1, irr_driver->getRenderTargetTexture(RTT_MLAA_BLEND), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::MLAAGatherSHader::setUniforms(PIXEL_SIZE, 0, 1);
|
||||
glUseProgram(FullScreenShader::MLAAGatherSHader::getInstance()->Program);
|
||||
setTexture(FullScreenShader::MLAAGatherSHader::getInstance()->TU_colorMap, irr_driver->getRenderTargetTexture(RTT_MLAA_TMP), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(FullScreenShader::MLAAGatherSHader::getInstance()->TU_blendMap, irr_driver->getRenderTargetTexture(RTT_MLAA_BLEND), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::MLAAGatherSHader::getInstance()->setUniforms(PIXEL_SIZE);
|
||||
|
||||
glBindVertexArray(FullScreenShader::MLAAGatherSHader::vao);
|
||||
glBindVertexArray(FullScreenShader::MLAAGatherSHader::getInstance()->vao);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
// Done.
|
||||
@ -833,13 +753,10 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode, boo
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
setTexture(0, irr_driver->getRenderTargetTexture(RTT_BLOOM_128), GL_LINEAR, GL_LINEAR);
|
||||
setTexture(1, irr_driver->getRenderTargetTexture(RTT_BLOOM_256), GL_LINEAR, GL_LINEAR);
|
||||
setTexture(2, irr_driver->getRenderTargetTexture(RTT_BLOOM_512), GL_LINEAR, GL_LINEAR);
|
||||
glUseProgram(FullScreenShader::BloomBlendShader::Program);
|
||||
FullScreenShader::BloomBlendShader::setUniforms(0, 1, 2);
|
||||
glBindVertexArray(FullScreenShader::BloomBlendShader::vao);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
setTexture(FullScreenShader::BloomBlendShader::getInstance()->TU_tex_128, irr_driver->getRenderTargetTexture(RTT_BLOOM_128), GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::BloomBlendShader::getInstance()->TU_tex_256, irr_driver->getRenderTargetTexture(RTT_BLOOM_256), GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::BloomBlendShader::getInstance()->TU_tex_512, irr_driver->getRenderTargetTexture(RTT_BLOOM_512), GL_LINEAR, GL_LINEAR);
|
||||
DrawFullScreenEffect<FullScreenShader::BloomBlendShader>();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
|
@ -81,6 +81,7 @@ public:
|
||||
void renderFog();
|
||||
void renderSSAO();
|
||||
void renderDiffuseEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff);
|
||||
void renderRHDebug(unsigned SHR, unsigned SHG, unsigned SHB, const core::matrix4 &rh_matrix, const core::vector3df &rh_extend);
|
||||
void renderGI(const core::matrix4 &RHMatrix, const core::vector3df &rh_extend, unsigned shr, unsigned shg, unsigned shb);
|
||||
|
||||
/** Blur the in texture */
|
||||
|
@ -340,18 +340,8 @@ void IrrDriver::renderScene(scene::ICameraSceneNode * const camnode, unsigned po
|
||||
|
||||
if (getRH())
|
||||
{
|
||||
glEnable(GL_PROGRAM_POINT_SIZE);
|
||||
m_rtts->getFBO(FBO_COLORS).Bind();
|
||||
glUseProgram(FullScreenShader::RHDebug::Program);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_3D, m_rtts->getRH().getRTT()[0]);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
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_matrix, rh_extend, 0, 1, 2);
|
||||
glDrawArrays(GL_POINTS, 0, 32 * 16 * 32);
|
||||
glDisable(GL_PROGRAM_POINT_SIZE);
|
||||
m_post_processing->renderRHDebug(m_rtts->getRH().getRTT()[0], m_rtts->getRH().getRTT()[1], m_rtts->getRH().getRTT()[2], rh_matrix, rh_extend);
|
||||
}
|
||||
|
||||
if (getGI())
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include "utils/tuple.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
namespace RenderGeometry
|
||||
{
|
||||
@ -79,6 +78,7 @@ namespace RenderGeometry
|
||||
}
|
||||
using namespace RenderGeometry;
|
||||
|
||||
|
||||
template<typename T, typename...uniforms>
|
||||
void draw(const T *Shader, const GLMesh *mesh, uniforms... Args)
|
||||
{
|
||||
@ -92,73 +92,37 @@ void draw(const T *Shader, const GLMesh *mesh, uniforms... Args)
|
||||
}
|
||||
|
||||
template<int...List>
|
||||
struct remap_tuple;
|
||||
struct custom_unroll_args;
|
||||
|
||||
template<>
|
||||
struct remap_tuple<>
|
||||
struct custom_unroll_args<>
|
||||
{
|
||||
template<typename...OriginalTuples, typename...Args>
|
||||
static STK::Tuple <Args...> exec(const STK::Tuple<OriginalTuples...> &oldt, Args... args)
|
||||
template<typename T, typename ...TupleTypes, typename ...Args>
|
||||
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
return STK::make_tuple(args...);
|
||||
draw<T>(Shader, STK::tuple_get<0>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<int N, int...List>
|
||||
struct remap_tuple<N, List...>
|
||||
struct custom_unroll_args<N, List...>
|
||||
{
|
||||
template<typename...OriginalTuples, typename...Args>
|
||||
static auto exec(const STK::Tuple<OriginalTuples...> &oldt, Args...args)
|
||||
-> decltype(remap_tuple<List...>::template exec(oldt, STK::tuple_get<N>(oldt), args...))
|
||||
template<typename T, typename ...TupleTypes, typename ...Args>
|
||||
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
return remap_tuple<List...>::template exec(oldt, STK::tuple_get<N>(oldt), args...);
|
||||
custom_unroll_args<List...>::template exec<T>(Shader, t, STK::tuple_get<N>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct unroll_args_impl;
|
||||
|
||||
template<>
|
||||
struct unroll_args_impl<0>
|
||||
{
|
||||
template<typename ...Args>
|
||||
static void exec(std::function<void (Args...)> f, const STK::Tuple<Args...> &t, Args... args)
|
||||
{
|
||||
f(args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct unroll_args_impl
|
||||
{
|
||||
template<typename ...TupleType, typename ...Args>
|
||||
static void exec(std::function<void (TupleType...)> f, const STK::Tuple<TupleType...> &t, Args... args)
|
||||
{
|
||||
unroll_args_impl<N - 1>::exec(f, t, STK::tuple_get<N - 1>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename...Args>
|
||||
static void unroll_args(std::function<void (Args...)> f, const STK::Tuple<Args...> &t)
|
||||
{
|
||||
unroll_args_impl<sizeof...(Args) >::exec(f, t);
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
void apply_instance(const T *Shader, const GLMesh *mesh, const STK::Tuple<Args...> &t)
|
||||
{
|
||||
std::function<void (Args...)> lambda = [&](Args...args) { draw<T>(Shader, mesh, args...); };
|
||||
unroll_args(lambda, t);
|
||||
}
|
||||
|
||||
template<typename Shader, enum E_VERTEX_TYPE VertexType, int ...List, typename... TupleType>
|
||||
void renderMeshes1stPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::Tuple<TupleType...> > &meshes)
|
||||
void renderMeshes1stPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::Tuple<TupleType...> > *meshes)
|
||||
{
|
||||
glUseProgram(Shader::getInstance()->Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < meshes.size(); i++)
|
||||
for (unsigned i = 0; i < meshes->size(); i++)
|
||||
{
|
||||
GLMesh &mesh = *(STK::tuple_get<0>(meshes[i]));
|
||||
GLMesh &mesh = *(STK::tuple_get<0>(meshes->at(i)));
|
||||
for (unsigned j = 0; j < TexUnits.size(); j++)
|
||||
{
|
||||
if (!mesh.textures[j])
|
||||
@ -173,8 +137,7 @@ void renderMeshes1stPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
auto remapped_tuple = remap_tuple<List...>::exec(meshes[i]);
|
||||
apply_instance<Shader>(Shader::getInstance(), &mesh, remapped_tuple);
|
||||
custom_unroll_args<List...>::template exec(Shader::getInstance(), meshes->at(i));
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,14 +154,14 @@ void IrrDriver::renderSolidFirstPass()
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_CULL_FACE);
|
||||
irr_driver->setPhase(SOLID_NORMAL_AND_DEPTH_PASS);
|
||||
ListMatDefault::Arguments.clear();
|
||||
ListMatAlphaRef::Arguments.clear();
|
||||
ListMatSphereMap::Arguments.clear();
|
||||
ListMatDetails::Arguments.clear();
|
||||
ListMatUnlit::Arguments.clear();
|
||||
ListMatNormalMap::Arguments.clear();
|
||||
ListMatGrass::Arguments.clear();
|
||||
ListMatSplatting::Arguments.clear();
|
||||
ListMatDefault::getInstance()->clear();
|
||||
ListMatAlphaRef::getInstance()->clear();
|
||||
ListMatSphereMap::getInstance()->clear();
|
||||
ListMatDetails::getInstance()->clear();
|
||||
ListMatUnlit::getInstance()->clear();
|
||||
ListMatNormalMap::getInstance()->clear();
|
||||
ListMatGrass::getInstance()->clear();
|
||||
ListMatSplatting::getInstance()->clear();
|
||||
m_scene_manager->drawAll(scene::ESNRP_SOLID);
|
||||
|
||||
if (!UserConfigParams::m_dynamic_lights)
|
||||
@ -208,28 +171,28 @@ void IrrDriver::renderSolidFirstPass()
|
||||
ScopedGPUTimer Timer(getGPUTimer(Q_SOLID_PASS1));
|
||||
|
||||
std::vector<TexUnit> object_pass1_texunits = TexUnits(TexUnit(MeshShader::ObjectPass1Shader::getInstance()->TU_tex, true) );
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>(object_pass1_texunits, ListMatDefault::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>(object_pass1_texunits, ListMatSphereMap::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_2TCOORDS, 2, 1>(object_pass1_texunits, ListMatDetails::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_2TCOORDS, 2, 1>(object_pass1_texunits, ListMatSplatting::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectRefPass1Shader, video::EVT_STANDARD, 3, 2, 1>(object_pass1_texunits, ListMatUnlit::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectRefPass1Shader, video::EVT_STANDARD, 3, 2, 1>(TexUnits(TexUnit(MeshShader::ObjectRefPass1Shader::getInstance()->TU_tex, true)), ListMatAlphaRef::Arguments);
|
||||
renderMeshes1stPass<MeshShader::GrassPass1Shader, video::EVT_STANDARD, 3, 2, 1>(TexUnits(TexUnit(MeshShader::GrassPass1Shader::getInstance()->TU_tex, true)), ListMatGrass::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>(object_pass1_texunits, ListMatDefault::getInstance());
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>(object_pass1_texunits, ListMatSphereMap::getInstance());
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_2TCOORDS, 2, 1>(object_pass1_texunits, ListMatDetails::getInstance());
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_2TCOORDS, 2, 1>(object_pass1_texunits, ListMatSplatting::getInstance());
|
||||
renderMeshes1stPass<MeshShader::ObjectRefPass1Shader, video::EVT_STANDARD, 3, 2, 1>(object_pass1_texunits, ListMatUnlit::getInstance());
|
||||
renderMeshes1stPass<MeshShader::ObjectRefPass1Shader, video::EVT_STANDARD, 3, 2, 1>(TexUnits(TexUnit(MeshShader::ObjectRefPass1Shader::getInstance()->TU_tex, true)), ListMatAlphaRef::getInstance());
|
||||
renderMeshes1stPass<MeshShader::GrassPass1Shader, video::EVT_STANDARD, 3, 2, 1>(TexUnits(TexUnit(MeshShader::GrassPass1Shader::getInstance()->TU_tex, true)), ListMatGrass::getInstance());
|
||||
renderMeshes1stPass<MeshShader::NormalMapShader, video::EVT_TANGENTS, 2, 1>(TexUnits(
|
||||
TexUnit(MeshShader::NormalMapShader::getInstance()->TU_glossy, true),
|
||||
TexUnit(MeshShader::NormalMapShader::getInstance()->TU_normalmap, false)
|
||||
), ListMatNormalMap::Arguments);
|
||||
), ListMatNormalMap::getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Shader, enum E_VERTEX_TYPE VertexType, int...List, typename... TupleType>
|
||||
void renderMeshes2ndPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::Tuple<TupleType...> > &meshes)
|
||||
void renderMeshes2ndPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::Tuple<TupleType...> > *meshes)
|
||||
{
|
||||
glUseProgram(Shader::getInstance()->Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < meshes.size(); i++)
|
||||
for (unsigned i = 0; i < meshes->size(); i++)
|
||||
{
|
||||
GLMesh &mesh = *(STK::tuple_get<0>(meshes[i]));
|
||||
GLMesh &mesh = *(STK::tuple_get<0>(meshes->at(i)));
|
||||
for (unsigned j = 0; j < TexUnits.size(); j++)
|
||||
{
|
||||
if (!mesh.textures[j])
|
||||
@ -255,8 +218,7 @@ void renderMeshes2ndPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
auto remapped_tuple = remap_tuple<List...>::exec(meshes[i]);
|
||||
apply_instance<Shader>(Shader::getInstance(), &mesh, remapped_tuple);
|
||||
custom_unroll_args<List...>::template exec(Shader::getInstance(), meshes->at(i));
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,28 +255,28 @@ void IrrDriver::renderSolidSecondPass()
|
||||
|
||||
renderMeshes2ndPass<MeshShader::ObjectPass2Shader, video::EVT_STANDARD, 3, 1>(TexUnits(
|
||||
TexUnit(MeshShader::ObjectPass2Shader::getInstance()->TU_Albedo, true)
|
||||
), ListMatDefault::Arguments);
|
||||
), ListMatDefault::getInstance());
|
||||
|
||||
renderMeshes2ndPass<MeshShader::ObjectRefPass2Shader, video::EVT_STANDARD, 3, 1 >(TexUnits(
|
||||
TexUnit(MeshShader::ObjectRefPass2Shader::getInstance()->TU_Albedo, true)
|
||||
), ListMatAlphaRef::Arguments);
|
||||
), ListMatAlphaRef::getInstance());
|
||||
|
||||
renderMeshes2ndPass<MeshShader::SphereMapShader, video::EVT_STANDARD, 2, 1>(TexUnits(
|
||||
TexUnit(MeshShader::SphereMapShader::getInstance()->TU_tex, true)
|
||||
), ListMatSphereMap::Arguments);
|
||||
), ListMatSphereMap::getInstance());
|
||||
|
||||
renderMeshes2ndPass<MeshShader::DetailledObjectPass2Shader, video::EVT_2TCOORDS, 1>(TexUnits(
|
||||
TexUnit(MeshShader::DetailledObjectPass2Shader::getInstance()->TU_Albedo, true),
|
||||
TexUnit(MeshShader::DetailledObjectPass2Shader::getInstance()->TU_detail, true)
|
||||
), ListMatDetails::Arguments);
|
||||
), ListMatDetails::getInstance());
|
||||
|
||||
renderMeshes2ndPass<MeshShader::GrassPass2Shader, video::EVT_STANDARD, 3, 1>(TexUnits(
|
||||
TexUnit(MeshShader::GrassPass2Shader::getInstance()->TU_Albedo, true)
|
||||
), ListMatGrass::Arguments);
|
||||
), ListMatGrass::getInstance());
|
||||
|
||||
renderMeshes2ndPass<MeshShader::ObjectUnlitShader, video::EVT_STANDARD, 1>(TexUnits(
|
||||
TexUnit(MeshShader::ObjectUnlitShader::getInstance()->TU_tex, true)
|
||||
), ListMatUnlit::Arguments);
|
||||
), ListMatUnlit::getInstance());
|
||||
|
||||
renderMeshes2ndPass<MeshShader::SplattingShader, video::EVT_2TCOORDS, 1>(TexUnits(
|
||||
TexUnit(8, true),
|
||||
@ -323,22 +285,22 @@ void IrrDriver::renderSolidSecondPass()
|
||||
TexUnit(MeshShader::SplattingShader::getInstance()->TU_tex_detail1, true),
|
||||
TexUnit(MeshShader::SplattingShader::getInstance()->TU_tex_detail2, true),
|
||||
TexUnit(MeshShader::SplattingShader::getInstance()->TU_tex_detail3, true)
|
||||
), ListMatSplatting::Arguments);
|
||||
), ListMatSplatting::getInstance());
|
||||
|
||||
renderMeshes2ndPass<MeshShader::ObjectPass2Shader, video::EVT_TANGENTS, 3, 1>(TexUnits(
|
||||
TexUnit(MeshShader::ObjectPass2Shader::getInstance()->TU_Albedo, true)
|
||||
), ListMatNormalMap::Arguments);
|
||||
), ListMatNormalMap::getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
template<enum E_VERTEX_TYPE VertexType, typename... TupleType>
|
||||
static void renderMeshNormals(std::vector<STK::Tuple<TupleType...> > &meshes)
|
||||
static void renderMeshNormals(std::vector<STK::Tuple<TupleType...> > *meshes)
|
||||
{
|
||||
glUseProgram(MeshShader::NormalVisualizer::getInstance()->Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < meshes.size(); i++)
|
||||
for (unsigned i = 0; i < meshes->size(); i++)
|
||||
{
|
||||
GLMesh &mesh = *(STK::tuple_get<0>(meshes[i]));
|
||||
GLMesh &mesh = *(STK::tuple_get<0>(meshes->at(i)));
|
||||
|
||||
if (mesh.VAOType != VertexType)
|
||||
{
|
||||
@ -347,20 +309,20 @@ static void renderMeshNormals(std::vector<STK::Tuple<TupleType...> > &meshes)
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
draw(MeshShader::NormalVisualizer::getInstance(), STK::tuple_get<0>(meshes[i]), STK::tuple_get<1>(meshes[i]), STK::tuple_get<2>(meshes[i]), video::SColor(255, 0, 255, 0));
|
||||
draw(MeshShader::NormalVisualizer::getInstance(), STK::tuple_get<0>(meshes->at(i)), STK::tuple_get<1>(meshes->at(i)), STK::tuple_get<2>(meshes->at(i)), video::SColor(255, 0, 255, 0));
|
||||
}
|
||||
}
|
||||
|
||||
void IrrDriver::renderNormalsVisualisation()
|
||||
{
|
||||
renderMeshNormals<video::EVT_STANDARD>(ListMatDefault::Arguments);
|
||||
renderMeshNormals<video::EVT_STANDARD>(ListMatAlphaRef::Arguments);
|
||||
renderMeshNormals<video::EVT_STANDARD>(ListMatSphereMap::Arguments);
|
||||
// renderMeshNormals<video::EVT_STANDARD>(ListMatGrass::Arguments);
|
||||
renderMeshNormals<video::EVT_2TCOORDS>(ListMatDetails::Arguments);
|
||||
renderMeshNormals<video::EVT_STANDARD>(ListMatUnlit::Arguments);
|
||||
renderMeshNormals<video::EVT_2TCOORDS>(ListMatSplatting::Arguments);
|
||||
renderMeshNormals<video::EVT_TANGENTS>(ListMatNormalMap::Arguments);
|
||||
renderMeshNormals<video::EVT_STANDARD>(ListMatDefault::getInstance());
|
||||
renderMeshNormals<video::EVT_STANDARD>(ListMatAlphaRef::getInstance());
|
||||
renderMeshNormals<video::EVT_STANDARD>(ListMatSphereMap::getInstance());
|
||||
// renderMeshNormals<video::EVT_STANDARD>(ListMatGrass::getInstance());
|
||||
renderMeshNormals<video::EVT_2TCOORDS>(ListMatDetails::getInstance());
|
||||
renderMeshNormals<video::EVT_STANDARD>(ListMatUnlit::getInstance());
|
||||
renderMeshNormals<video::EVT_2TCOORDS>(ListMatSplatting::getInstance());
|
||||
renderMeshNormals<video::EVT_TANGENTS>(ListMatNormalMap::getInstance());
|
||||
|
||||
}
|
||||
|
||||
@ -377,11 +339,11 @@ void IrrDriver::renderTransparent()
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glDisable(GL_CULL_FACE);
|
||||
ListBlendTransparent::Arguments.clear();
|
||||
ListAdditiveTransparent::Arguments.clear();
|
||||
ListBlendTransparentFog::Arguments.clear();
|
||||
ListAdditiveTransparentFog::Arguments.clear();
|
||||
ListDisplacement::Arguments.clear();
|
||||
ListBlendTransparent::getInstance()->clear();
|
||||
ListAdditiveTransparent::getInstance()->clear();
|
||||
ListBlendTransparentFog::getInstance()->clear();
|
||||
ListAdditiveTransparentFog::getInstance()->clear();
|
||||
ListDisplacement::getInstance()->clear();
|
||||
m_scene_manager->drawAll(scene::ESNRP_TRANSPARENT);
|
||||
|
||||
glBindVertexArray(getVAO(EVT_STANDARD));
|
||||
@ -391,22 +353,22 @@ void IrrDriver::renderTransparent()
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
renderMeshes2ndPass<MeshShader::TransparentFogShader, video::EVT_STANDARD, 8, 7, 6, 5, 4, 3, 2, 1>(TexUnits(
|
||||
TexUnit(MeshShader::TransparentFogShader::getInstance()->TU_tex, true)
|
||||
), ListBlendTransparentFog::Arguments);
|
||||
), ListBlendTransparentFog::getInstance());
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
renderMeshes2ndPass<MeshShader::TransparentFogShader, video::EVT_STANDARD, 8, 7, 6, 5, 4, 3, 2, 1>(TexUnits(
|
||||
TexUnit(MeshShader::TransparentFogShader::getInstance()->TU_tex, true)
|
||||
), ListAdditiveTransparentFog::Arguments);
|
||||
), ListAdditiveTransparentFog::getInstance());
|
||||
}
|
||||
else
|
||||
{
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
renderMeshes2ndPass<MeshShader::TransparentShader, video::EVT_STANDARD, 2, 1>(TexUnits(
|
||||
TexUnit(MeshShader::TransparentShader::getInstance()->TU_tex, true)
|
||||
), ListBlendTransparent::Arguments);
|
||||
), ListBlendTransparent::getInstance());
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
renderMeshes2ndPass<MeshShader::TransparentShader, video::EVT_STANDARD, 2, 1>(TexUnits(
|
||||
TexUnit(MeshShader::TransparentShader::getInstance()->TU_tex, true)
|
||||
), ListAdditiveTransparent::Arguments);
|
||||
), ListAdditiveTransparent::getInstance());
|
||||
}
|
||||
|
||||
if (!UserConfigParams::m_dynamic_lights)
|
||||
@ -434,10 +396,10 @@ void IrrDriver::renderTransparent()
|
||||
// Generate displace mask
|
||||
// Use RTT_TMP4 as displace mask
|
||||
irr_driver->getFBO(FBO_TMP1_WITH_DS).Bind();
|
||||
for (unsigned i = 0; i < ListDisplacement::Arguments.size(); i++)
|
||||
for (unsigned i = 0; i < ListDisplacement::getInstance()->size(); i++)
|
||||
{
|
||||
const GLMesh &mesh = *(STK::tuple_get<0>(ListDisplacement::Arguments[i]));
|
||||
const core::matrix4 &AbsoluteTransformation = STK::tuple_get<1>(ListDisplacement::Arguments[i]);
|
||||
const GLMesh &mesh = *(STK::tuple_get<0>(ListDisplacement::getInstance()->at(i)));
|
||||
const core::matrix4 &AbsoluteTransformation = STK::tuple_get<1>(ListDisplacement::getInstance()->at(i));
|
||||
if (mesh.VAOType != video::EVT_2TCOORDS)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
@ -458,10 +420,10 @@ void IrrDriver::renderTransparent()
|
||||
irr_driver->getFBO(FBO_DISPLACE).Bind();
|
||||
if (!displaceTex)
|
||||
displaceTex = irr_driver->getTexture(FileManager::TEXTURE, "displace.png");
|
||||
for (unsigned i = 0; i < ListDisplacement::Arguments.size(); i++)
|
||||
for (unsigned i = 0; i < ListDisplacement::getInstance()->size(); i++)
|
||||
{
|
||||
const GLMesh &mesh = *(STK::tuple_get<0>(ListDisplacement::Arguments[i]));
|
||||
const core::matrix4 &AbsoluteTransformation = STK::tuple_get<1>(ListDisplacement::Arguments[i]);
|
||||
const GLMesh &mesh = *(STK::tuple_get<0>(ListDisplacement::getInstance()->at(i)));
|
||||
const core::matrix4 &AbsoluteTransformation = STK::tuple_get<1>(ListDisplacement::getInstance()->at(i));
|
||||
if (mesh.VAOType != video::EVT_2TCOORDS)
|
||||
continue;
|
||||
|
||||
@ -500,48 +462,81 @@ void drawShadow(const T *Shader, const GLMesh *mesh, uniforms... Args)
|
||||
glDrawElementsInstancedBaseVertex(ptype, count, itype, (GLvoid *)mesh->vaoOffset, 4, mesh->vaoBaseVertex);
|
||||
}
|
||||
|
||||
template<int...List>
|
||||
struct shadow_custom_unroll_args;
|
||||
|
||||
template<typename T, typename...Args>
|
||||
void drawShadowTuple(const T *Shader, const GLMesh *mesh, const STK::Tuple<Args...> &t)
|
||||
template<>
|
||||
struct shadow_custom_unroll_args<>
|
||||
{
|
||||
std::function<void (Args...)> lambda = [&](Args...args) { drawShadow<T>(Shader, mesh, args...); };
|
||||
unroll_args(lambda, t);
|
||||
}
|
||||
template<typename T, typename ...TupleTypes, typename ...Args>
|
||||
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
drawShadow<T>(Shader, STK::tuple_get<0>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<int N, int...List>
|
||||
struct shadow_custom_unroll_args<N, List...>
|
||||
{
|
||||
template<typename T, typename ...TupleTypes, typename ...Args>
|
||||
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
shadow_custom_unroll_args<List...>::template exec<T>(Shader, t, STK::tuple_get<N>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, enum E_VERTEX_TYPE VertexType, int...List, typename... Args>
|
||||
void renderShadow(const std::vector<GLuint> TextureUnits, const std::vector<STK::Tuple<GLMesh *, core::matrix4, Args...> >&t)
|
||||
void renderShadow(const std::vector<GLuint> TextureUnits, const std::vector<STK::Tuple<GLMesh *, core::matrix4, Args...> > *t)
|
||||
{
|
||||
glUseProgram(T::getInstance()->Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < t.size(); i++)
|
||||
for (unsigned i = 0; i < t->size(); i++)
|
||||
{
|
||||
const GLMesh *mesh = STK::tuple_get<0>(t[i]);
|
||||
const GLMesh *mesh = STK::tuple_get<0>(t->at(i));
|
||||
for (unsigned j = 0; j < TextureUnits.size(); j++)
|
||||
{
|
||||
compressTexture(mesh->textures[j], true);
|
||||
setTexture(TextureUnits[j], getTextureGLuint(mesh->textures[j]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
}
|
||||
|
||||
auto remapped_tuple = remap_tuple<List...>::exec(t[i]);
|
||||
drawShadowTuple<T>(T::getInstance(), mesh, remapped_tuple);
|
||||
shadow_custom_unroll_args<List...>::template exec<T>(T::getInstance(), t->at(i));
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
void drawRSMTuple(const core::matrix4 &rsm_matrix, const GLMesh *mesh, const STK::Tuple<Args...> &t)
|
||||
template<int...List>
|
||||
struct rsm_custom_unroll_args;
|
||||
|
||||
template<>
|
||||
struct rsm_custom_unroll_args<>
|
||||
{
|
||||
std::function<void (Args...)> lambda = [&](Args...args) {draw<T>(T::getInstance(), mesh, rsm_matrix, args...); };
|
||||
unroll_args(lambda, t);
|
||||
}
|
||||
template<typename T, typename ...TupleTypes, typename ...Args>
|
||||
static void exec(const core::matrix4 &rsm_matrix, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
draw<T>(T::getInstance(), STK::tuple_get<0>(t), rsm_matrix, args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<int N, int...List>
|
||||
struct rsm_custom_unroll_args<N, List...>
|
||||
{
|
||||
template<typename T, typename ...TupleTypes, typename ...Args>
|
||||
static void exec(const core::matrix4 &rsm_matrix, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
rsm_custom_unroll_args<List...>::template exec<T>(rsm_matrix, t, STK::tuple_get<N>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, enum E_VERTEX_TYPE VertexType, int... Selector, typename... Args>
|
||||
void drawRSM(const core::matrix4 & rsm_matrix, const std::vector<GLuint> TextureUnits, const std::vector<STK::Tuple<GLMesh *, core::matrix4, Args...> >&t)
|
||||
void drawRSM(const core::matrix4 & rsm_matrix, const std::vector<GLuint> TextureUnits, const std::vector<STK::Tuple<GLMesh *, core::matrix4, Args...> > *t)
|
||||
{
|
||||
glUseProgram(T::getInstance()->Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < t.size(); i++)
|
||||
for (unsigned i = 0; i < t->size(); i++)
|
||||
{
|
||||
GLMesh *mesh = STK::tuple_get<0>(t[i]);
|
||||
GLMesh *mesh = STK::tuple_get<0>(t->at(i));
|
||||
for (unsigned j = 0; j < TextureUnits.size(); j++)
|
||||
{
|
||||
if (!mesh->textures[j])
|
||||
@ -549,8 +544,7 @@ void drawRSM(const core::matrix4 & rsm_matrix, const std::vector<GLuint> Texture
|
||||
compressTexture(mesh->textures[j], true);
|
||||
setTexture(TextureUnits[j], getTextureGLuint(mesh->textures[j]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
}
|
||||
auto remapped_tuple = remap_tuple<Selector...>::template exec(t[i]);
|
||||
drawRSMTuple<T>(rsm_matrix, mesh, remapped_tuple);
|
||||
rsm_custom_unroll_args<Selector...>::template exec<T>(rsm_matrix, t->at(i));
|
||||
}
|
||||
}
|
||||
|
||||
@ -568,25 +562,25 @@ void IrrDriver::renderShadows()
|
||||
glDrawBuffer(GL_NONE);
|
||||
|
||||
irr_driver->setPhase(SHADOW_PASS);
|
||||
ListMatDefault::Arguments.clear();
|
||||
ListMatAlphaRef::Arguments.clear();
|
||||
ListMatSphereMap::Arguments.clear();
|
||||
ListMatDetails::Arguments.clear();
|
||||
ListMatUnlit::Arguments.clear();
|
||||
ListMatNormalMap::Arguments.clear();
|
||||
ListMatGrass::Arguments.clear();
|
||||
ListMatSplatting::Arguments.clear();
|
||||
ListMatDefault::getInstance()->clear();
|
||||
ListMatAlphaRef::getInstance()->clear();
|
||||
ListMatSphereMap::getInstance()->clear();
|
||||
ListMatDetails::getInstance()->clear();
|
||||
ListMatUnlit::getInstance()->clear();
|
||||
ListMatNormalMap::getInstance()->clear();
|
||||
ListMatGrass::getInstance()->clear();
|
||||
ListMatSplatting::getInstance()->clear();
|
||||
m_scene_manager->drawAll(scene::ESNRP_SOLID);
|
||||
|
||||
std::vector<GLuint> noTexUnits;
|
||||
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(noTexUnits, ListMatDefault::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(noTexUnits, ListMatSphereMap::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_2TCOORDS, 1>(noTexUnits, ListMatDetails::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_2TCOORDS, 1>(noTexUnits, ListMatSplatting::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_TANGENTS, 1>(noTexUnits, ListMatNormalMap::Arguments);
|
||||
renderShadow<MeshShader::RefShadowShader, EVT_STANDARD, 1>(std::vector<GLuint>{ MeshShader::RefShadowShader::getInstance()->TU_tex }, ListMatAlphaRef::Arguments);
|
||||
renderShadow<MeshShader::RefShadowShader, EVT_STANDARD, 1>(std::vector<GLuint>{ MeshShader::RefShadowShader::getInstance()->TU_tex }, ListMatUnlit::Arguments);
|
||||
renderShadow<MeshShader::GrassShadowShader, EVT_STANDARD, 3, 1>(std::vector<GLuint>{ MeshShader::GrassShadowShader::getInstance()->TU_tex }, ListMatGrass::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(noTexUnits, ListMatDefault::getInstance());
|
||||
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(noTexUnits, ListMatSphereMap::getInstance());
|
||||
renderShadow<MeshShader::ShadowShader, EVT_2TCOORDS, 1>(noTexUnits, ListMatDetails::getInstance());
|
||||
renderShadow<MeshShader::ShadowShader, EVT_2TCOORDS, 1>(noTexUnits, ListMatSplatting::getInstance());
|
||||
renderShadow<MeshShader::ShadowShader, EVT_TANGENTS, 1>(noTexUnits, ListMatNormalMap::getInstance());
|
||||
renderShadow<MeshShader::RefShadowShader, EVT_STANDARD, 1>(std::vector<GLuint>{ MeshShader::RefShadowShader::getInstance()->TU_tex }, ListMatAlphaRef::getInstance());
|
||||
renderShadow<MeshShader::RefShadowShader, EVT_STANDARD, 1>(std::vector<GLuint>{ MeshShader::RefShadowShader::getInstance()->TU_tex }, ListMatUnlit::getInstance());
|
||||
renderShadow<MeshShader::GrassShadowShader, EVT_STANDARD, 3, 1>(std::vector<GLuint>{ MeshShader::GrassShadowShader::getInstance()->TU_tex }, ListMatGrass::getInstance());
|
||||
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
@ -596,11 +590,11 @@ void IrrDriver::renderShadows()
|
||||
m_rtts->getRSM().Bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
drawRSM<MeshShader::RSMShader, EVT_STANDARD, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatDefault::Arguments);
|
||||
drawRSM<MeshShader::RSMShader, EVT_STANDARD, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatAlphaRef::Arguments);
|
||||
// drawRSM<EVT_STANDARD, 2, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatSphereMap::Arguments);
|
||||
drawRSM<MeshShader::RSMShader, EVT_STANDARD, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatUnlit::Arguments);
|
||||
drawRSM<MeshShader::RSMShader, EVT_2TCOORDS, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatDetails::Arguments);
|
||||
drawRSM<MeshShader::RSMShader, EVT_STANDARD, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatDefault::getInstance());
|
||||
drawRSM<MeshShader::RSMShader, EVT_STANDARD, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatAlphaRef::getInstance());
|
||||
// drawRSM<EVT_STANDARD, 2, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatSphereMap::getInstance());
|
||||
drawRSM<MeshShader::RSMShader, EVT_STANDARD, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatUnlit::getInstance());
|
||||
drawRSM<MeshShader::RSMShader, EVT_2TCOORDS, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatDetails::getInstance());
|
||||
drawRSM<MeshShader::SplattingRSMShader, EVT_2TCOORDS, 1>(rsm_matrix,
|
||||
std::vector<GLuint>{
|
||||
8,
|
||||
@ -609,5 +603,5 @@ void IrrDriver::renderShadows()
|
||||
MeshShader::SplattingRSMShader::getInstance()->TU_detail1,
|
||||
MeshShader::SplattingRSMShader::getInstance()->TU_detail2,
|
||||
MeshShader::SplattingRSMShader::getInstance()->TU_detail3},
|
||||
ListMatSplatting::Arguments);
|
||||
ListMatSplatting::getInstance());
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ void IrrDriver::renderLights(unsigned pointlightcount)
|
||||
glDisable(GL_BLEND);
|
||||
m_rtts->getRH().Bind();
|
||||
glUseProgram(FullScreenShader::RadianceHintsConstructionShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::RadianceHintsConstructionShader::getInstance()->vao);
|
||||
glBindVertexArray(SharedObject::FullScreenQuadVAO);
|
||||
setTexture(FullScreenShader::RadianceHintsConstructionShader::getInstance()->TU_ctex, m_rtts->getRSM().getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::RadianceHintsConstructionShader::getInstance()->TU_ntex, m_rtts->getRSM().getRTT()[1], GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::RadianceHintsConstructionShader::getInstance()->TU_dtex, m_rtts->getRSM().getDepthTexture(), GL_LINEAR, GL_LINEAR);
|
||||
|
@ -132,6 +132,8 @@ Shaders::Shaders()
|
||||
|
||||
GLuint quad_vbo, tri_vbo;
|
||||
|
||||
GLuint SharedObject::FullScreenQuadVAO = 0;
|
||||
|
||||
static void initQuadVBO()
|
||||
{
|
||||
const float quad_vertex[] = {
|
||||
@ -154,6 +156,13 @@ static void initQuadVBO()
|
||||
glBindBuffer(GL_ARRAY_BUFFER, tri_vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, 6 * sizeof(float), tri_vertex, GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
glGenVertexArrays(1, &SharedObject::FullScreenQuadVAO);
|
||||
glBindVertexArray(SharedObject::FullScreenQuadVAO);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, tri_vbo);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), 0);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
// It should be possible to merge it with previous one...
|
||||
@ -373,27 +382,7 @@ void Shaders::loadShaders()
|
||||
initCubeVBO();
|
||||
initFrustrumVBO();
|
||||
initShadowVPMUBO();
|
||||
FullScreenShader::BloomBlendShader::init();
|
||||
FullScreenShader::BloomShader::init();
|
||||
FullScreenShader::Gaussian17TapHShader::init();
|
||||
FullScreenShader::ComputeGaussian17TapHShader::init();
|
||||
FullScreenShader::Gaussian3HBlurShader::init();
|
||||
FullScreenShader::Gaussian3VBlurShader::init();
|
||||
FullScreenShader::Gaussian17TapVShader::init();
|
||||
FullScreenShader::ComputeGaussian17TapVShader::init();
|
||||
FullScreenShader::Gaussian6HBlurShader::init();
|
||||
FullScreenShader::Gaussian6VBlurShader::init();
|
||||
FullScreenShader::GlowShader::init();
|
||||
FullScreenShader::PassThroughShader::init();
|
||||
FullScreenShader::LayerPassThroughShader::init();
|
||||
FullScreenShader::DiffuseEnvMapShader::init();
|
||||
FullScreenShader::RHDebug::init();
|
||||
FullScreenShader::MotionBlurShader::init();
|
||||
FullScreenShader::GodFadeShader::init();
|
||||
FullScreenShader::GodRayShader::init();
|
||||
FullScreenShader::MLAAColorEdgeDetectionSHader::init();
|
||||
FullScreenShader::MLAABlendWeightSHader::init();
|
||||
FullScreenShader::MLAAGatherSHader::init();
|
||||
MeshShader::BubbleShader::init();
|
||||
LightShader::PointLightShader::init();
|
||||
MeshShader::SkyboxShader::init();
|
||||
@ -582,6 +571,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();
|
||||
@ -1529,19 +1523,6 @@ namespace ParticleShader
|
||||
}
|
||||
}
|
||||
|
||||
static GLuint createFullScreenVAO(GLuint Program)
|
||||
{
|
||||
GLuint vao;
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
GLuint attrib_position = glGetAttribLocation(Program, "Position");
|
||||
glBindBuffer(GL_ARRAY_BUFFER, tri_vbo);
|
||||
glEnableVertexAttribArray(attrib_position);
|
||||
glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), 0);
|
||||
glBindVertexArray(0);
|
||||
return vao;
|
||||
}
|
||||
|
||||
static GLuint createVAO(GLuint Program)
|
||||
{
|
||||
GLuint vao;
|
||||
@ -1560,46 +1541,27 @@ static GLuint createVAO(GLuint Program)
|
||||
|
||||
namespace FullScreenShader
|
||||
{
|
||||
GLuint BloomShader::Program;
|
||||
GLuint BloomShader::uniform_texture;
|
||||
GLuint BloomShader::vao;
|
||||
void BloomShader::init()
|
||||
BloomShader::BloomShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getCIEXYZ.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/bloom.frag").c_str());
|
||||
uniform_texture = glGetUniformLocation(Program, "tex");
|
||||
vao = createFullScreenVAO(Program);
|
||||
AssignUniforms();
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
void BloomShader::setUniforms(unsigned TU_tex)
|
||||
{
|
||||
glUniform1i(FullScreenShader::BloomShader::uniform_texture, TU_tex);
|
||||
}
|
||||
|
||||
GLuint BloomBlendShader::Program;
|
||||
GLuint BloomBlendShader::uniform_tex_128;
|
||||
GLuint BloomBlendShader::uniform_tex_256;
|
||||
GLuint BloomBlendShader::uniform_tex_512;
|
||||
GLuint BloomBlendShader::vao;
|
||||
|
||||
void BloomBlendShader::init()
|
||||
BloomBlendShader::BloomBlendShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/bloomblend.frag").c_str());
|
||||
uniform_tex_128 = glGetUniformLocation(Program, "tex_128");
|
||||
uniform_tex_256 = glGetUniformLocation(Program, "tex_256");
|
||||
uniform_tex_512 = glGetUniformLocation(Program, "tex_512");
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
void BloomBlendShader::setUniforms(unsigned TU_tex_128, unsigned TU_tex_256, unsigned TU_tex_512)
|
||||
{
|
||||
glUniform1i(uniform_tex_128, TU_tex_128);
|
||||
glUniform1i(uniform_tex_256, TU_tex_256);
|
||||
glUniform1i(uniform_tex_512, TU_tex_512);
|
||||
AssignUniforms();
|
||||
TU_tex_128 = 0;
|
||||
TU_tex_256 = 1;
|
||||
TU_tex_512 = 2;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex_128, "tex_128"), TexUnit(TU_tex_256, "tex_256"), TexUnit(TU_tex_512, "tex_512"));
|
||||
}
|
||||
|
||||
ToneMapShader::ToneMapShader()
|
||||
@ -1612,7 +1574,6 @@ namespace FullScreenShader
|
||||
AssignUniforms();
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "text"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
DepthOfFieldShader::DepthOfFieldShader()
|
||||
@ -1624,7 +1585,7 @@ namespace FullScreenShader
|
||||
TU_depth = 1;
|
||||
AssignUniforms();
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"), TexUnit(TU_depth, "dtex"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
@ -1641,7 +1602,6 @@ namespace FullScreenShader
|
||||
TU_dtex = 1;
|
||||
AssignTextureUnit(Program, TexUnit(TU_ntex, "ntex"), TexUnit(TU_dtex, "dtex"));
|
||||
AssignUniforms("direction", "col");
|
||||
vao = createFullScreenVAO(Program);
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
@ -1653,7 +1613,6 @@ namespace FullScreenShader
|
||||
GLuint DiffuseEnvMapShader::uniform_greenLmn;
|
||||
GLuint DiffuseEnvMapShader::uniform_redLmn;
|
||||
GLuint DiffuseEnvMapShader::uniform_TVM;
|
||||
GLuint DiffuseEnvMapShader::vao;
|
||||
|
||||
void DiffuseEnvMapShader::init()
|
||||
{
|
||||
@ -1666,7 +1625,6 @@ namespace FullScreenShader
|
||||
uniform_greenLmn = glGetUniformLocation(Program, "greenLmn[0]");
|
||||
uniform_redLmn = glGetUniformLocation(Program, "redLmn[0]");
|
||||
uniform_TVM = glGetUniformLocation(Program, "TransposeViewMatrix");
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
void DiffuseEnvMapShader::setUniforms(const core::matrix4 &TransposeViewMatrix, const float *blueSHCoeff, const float *greenSHCoeff, const float *redSHCoeff, unsigned TU_ntex)
|
||||
@ -1691,7 +1649,6 @@ namespace FullScreenShader
|
||||
TU_shadowtex = 2;
|
||||
AssignTextureUnit(Program, TexUnit(TU_ntex, "ntex"), TexUnit(TU_dtex, "dtex"), TexUnit(TU_shadowtex, "shadowtex"));
|
||||
AssignUniforms("direction", "col");
|
||||
vao = createFullScreenVAO(Program);
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
@ -1720,39 +1677,22 @@ namespace FullScreenShader
|
||||
TU_ntex = 1;
|
||||
TU_dtex = 2;
|
||||
AssignTextureUnit(Program, TexUnit(TU_ctex, "ctex"), TexUnit(TU_ntex, "ntex"), TexUnit(TU_dtex, "dtex"));
|
||||
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(
|
||||
@ -1768,156 +1708,120 @@ namespace FullScreenShader
|
||||
TU_SHG = 3;
|
||||
TU_SHB = 4;
|
||||
AssignTextureUnit(Program, TexUnit(TU_ntex, "ntex"), TexUnit(TU_dtex, "dtex"), TexUnit(TU_SHR, "SHR"), TexUnit(TU_SHG, "SHG"), TexUnit(TU_SHB, "SHB"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint Gaussian17TapHShader::Program;
|
||||
GLuint Gaussian17TapHShader::uniform_tex;
|
||||
GLuint Gaussian17TapHShader::uniform_depth;
|
||||
GLuint Gaussian17TapHShader::uniform_pixel;
|
||||
GLuint Gaussian17TapHShader::vao;
|
||||
void Gaussian17TapHShader::init()
|
||||
Gaussian17TapHShader::Gaussian17TapHShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/bilateralH.frag").c_str());
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_pixel = glGetUniformLocation(Program, "pixel");
|
||||
uniform_depth = glGetUniformLocation(Program, "depth");
|
||||
vao = createFullScreenVAO(Program);
|
||||
AssignUniforms("pixel");
|
||||
TU_tex = 0;
|
||||
TU_depth = 1;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"), TexUnit(TU_depth, "depth"));
|
||||
}
|
||||
|
||||
GLuint ComputeGaussian17TapHShader::Program;
|
||||
GLuint ComputeGaussian17TapHShader::uniform_source;
|
||||
GLuint ComputeGaussian17TapHShader::uniform_depth;
|
||||
GLuint ComputeGaussian17TapHShader::uniform_dest;
|
||||
void ComputeGaussian17TapHShader::init()
|
||||
ComputeGaussian17TapHShader::ComputeGaussian17TapHShader()
|
||||
{
|
||||
#if WIN32
|
||||
if (irr_driver->getGLSLVersion() < 420)
|
||||
return;
|
||||
Program = LoadProgram(
|
||||
GL_COMPUTE_SHADER, file_manager->getAsset("shaders/bilateralH.comp").c_str());
|
||||
uniform_source = glGetUniformLocation(Program, "source");
|
||||
uniform_depth = glGetUniformLocation(Program, "depth");
|
||||
uniform_dest = glGetUniformLocation(Program, "dest");
|
||||
TU_source = 0;
|
||||
TU_depth = 1;
|
||||
TU_dest = 2;
|
||||
AssignUniforms();
|
||||
AssignTextureUnit(Program, TexUnit(TU_source, "source"), TexUnit(TU_depth, "depth"), TexUnit(TU_dest, "dest"));
|
||||
#endif
|
||||
}
|
||||
|
||||
GLuint Gaussian6HBlurShader::Program;
|
||||
GLuint Gaussian6HBlurShader::uniform_tex;
|
||||
GLuint Gaussian6HBlurShader::uniform_pixel;
|
||||
GLuint Gaussian6HBlurShader::vao;
|
||||
void Gaussian6HBlurShader::init()
|
||||
Gaussian6HBlurShader::Gaussian6HBlurShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/gaussian6h.frag").c_str());
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_pixel = glGetUniformLocation(Program, "pixel");
|
||||
vao = createFullScreenVAO(Program);
|
||||
AssignUniforms("pixel");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
GLuint Gaussian3HBlurShader::Program;
|
||||
GLuint Gaussian3HBlurShader::uniform_tex;
|
||||
GLuint Gaussian3HBlurShader::uniform_pixel;
|
||||
GLuint Gaussian3HBlurShader::vao;
|
||||
void Gaussian3HBlurShader::init()
|
||||
Gaussian3HBlurShader::Gaussian3HBlurShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/gaussian3h.frag").c_str());
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_pixel = glGetUniformLocation(Program, "pixel");
|
||||
vao = createFullScreenVAO(Program);
|
||||
AssignUniforms("pixel");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
GLuint Gaussian17TapVShader::Program;
|
||||
GLuint Gaussian17TapVShader::uniform_tex;
|
||||
GLuint Gaussian17TapVShader::uniform_depth;
|
||||
GLuint Gaussian17TapVShader::uniform_pixel;
|
||||
GLuint Gaussian17TapVShader::vao;
|
||||
void Gaussian17TapVShader::init()
|
||||
Gaussian17TapVShader::Gaussian17TapVShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/bilateralV.frag").c_str());
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_pixel = glGetUniformLocation(Program, "pixel");
|
||||
uniform_depth = glGetUniformLocation(Program, "depth");
|
||||
vao = createFullScreenVAO(Program);
|
||||
AssignUniforms("pixel");
|
||||
TU_tex = 0;
|
||||
TU_depth = 1;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"), TexUnit(TU_depth, "depth"));
|
||||
}
|
||||
|
||||
GLuint ComputeGaussian17TapVShader::Program;
|
||||
GLuint ComputeGaussian17TapVShader::uniform_source;
|
||||
GLuint ComputeGaussian17TapVShader::uniform_depth;
|
||||
GLuint ComputeGaussian17TapVShader::uniform_dest;
|
||||
void ComputeGaussian17TapVShader::init()
|
||||
ComputeGaussian17TapVShader::ComputeGaussian17TapVShader()
|
||||
{
|
||||
#if WIN32
|
||||
if (irr_driver->getGLSLVersion() < 420)
|
||||
return;
|
||||
Program = LoadProgram(
|
||||
GL_COMPUTE_SHADER, file_manager->getAsset("shaders/bilateralV.comp").c_str());
|
||||
uniform_source = glGetUniformLocation(Program, "source");
|
||||
uniform_depth = glGetUniformLocation(Program, "depth");
|
||||
uniform_dest = glGetUniformLocation(Program, "dest");
|
||||
TU_source = 0;
|
||||
TU_depth = 1;
|
||||
TU_dest = 2;
|
||||
AssignTextureUnit(Program, TexUnit(TU_source, "source"), TexUnit(TU_depth, "depth"), TexUnit(TU_dest, "dest"));
|
||||
#endif
|
||||
}
|
||||
|
||||
GLuint Gaussian6VBlurShader::Program;
|
||||
GLuint Gaussian6VBlurShader::uniform_tex;
|
||||
GLuint Gaussian6VBlurShader::uniform_pixel;
|
||||
GLuint Gaussian6VBlurShader::vao;
|
||||
void Gaussian6VBlurShader::init()
|
||||
Gaussian6VBlurShader::Gaussian6VBlurShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/gaussian6v.frag").c_str());
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_pixel = glGetUniformLocation(Program, "pixel");
|
||||
vao = createFullScreenVAO(Program);
|
||||
AssignUniforms("pixel");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
GLuint Gaussian3VBlurShader::Program;
|
||||
GLuint Gaussian3VBlurShader::uniform_tex;
|
||||
GLuint Gaussian3VBlurShader::uniform_pixel;
|
||||
GLuint Gaussian3VBlurShader::vao;
|
||||
void Gaussian3VBlurShader::init()
|
||||
Gaussian3VBlurShader::Gaussian3VBlurShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/gaussian3v.frag").c_str());
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_pixel = glGetUniformLocation(Program, "pixel");
|
||||
vao = createFullScreenVAO(Program);
|
||||
AssignUniforms("pixel");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
GLuint PassThroughShader::Program;
|
||||
GLuint PassThroughShader::uniform_texture;
|
||||
GLuint PassThroughShader::vao;
|
||||
void PassThroughShader::init()
|
||||
PassThroughShader::PassThroughShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/texturedquad.frag").c_str());
|
||||
uniform_texture = glGetUniformLocation(Program, "texture");
|
||||
TU_tex = 0;
|
||||
AssignUniforms();
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "texture"));
|
||||
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);
|
||||
}
|
||||
|
||||
@ -1929,18 +1833,16 @@ namespace FullScreenShader
|
||||
AssignUniforms("zn", "zf");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "texture"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
GLuint GlowShader::Program;
|
||||
GLuint GlowShader::uniform_tex;
|
||||
GLuint GlowShader::vao;
|
||||
void GlowShader::init()
|
||||
GlowShader::GlowShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/glow.frag").c_str());
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
AssignUniforms();
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
vao = createVAO(Program);
|
||||
}
|
||||
|
||||
@ -1954,7 +1856,6 @@ namespace FullScreenShader
|
||||
TU_dtex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_dtex, "dtex"));
|
||||
AssignUniforms("radius", "k", "sigma");
|
||||
vao = createFullScreenVAO(Program);
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
@ -1969,156 +1870,79 @@ namespace FullScreenShader
|
||||
TU_tex = 0;
|
||||
AssignUniforms("fogmax", "startH", "endH", "start", "end", "col");
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint MotionBlurShader::Program;
|
||||
GLuint MotionBlurShader::uniform_boost_amount;
|
||||
GLuint MotionBlurShader::uniform_center;
|
||||
GLuint MotionBlurShader::uniform_color_buffer;
|
||||
GLuint MotionBlurShader::uniform_dtex;
|
||||
GLuint MotionBlurShader::uniform_previous_viewproj;
|
||||
GLuint MotionBlurShader::uniform_mask_radius;
|
||||
GLuint MotionBlurShader::vao;
|
||||
|
||||
void MotionBlurShader::init()
|
||||
MotionBlurShader::MotionBlurShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/motion_blur.frag").c_str());
|
||||
uniform_boost_amount = glGetUniformLocation(Program, "boost_amount");
|
||||
uniform_center = glGetUniformLocation(Program, "center");
|
||||
uniform_color_buffer = glGetUniformLocation(Program, "color_buffer");
|
||||
uniform_mask_radius = glGetUniformLocation(Program, "mask_radius");
|
||||
uniform_dtex = glGetUniformLocation(Program, "dtex");
|
||||
uniform_previous_viewproj = glGetUniformLocation(Program, "previous_viewproj");
|
||||
vao = createFullScreenVAO(Program);
|
||||
AssignUniforms("previous_viewproj", "center", "boost_amount", "mask_radius");
|
||||
TU_cb = 0;
|
||||
TU_dtex = 1;
|
||||
AssignTextureUnit(Program, TexUnit(TU_dtex, "dtex"), TexUnit(TU_cb, "color_buffer"));
|
||||
}
|
||||
|
||||
void MotionBlurShader::setUniforms(float boost_amount, const core::matrix4 &previousVP, const core::vector2df ¢er, float mask_radius, unsigned TU_cb, unsigned TU_dtex)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_previous_viewproj, 1, GL_FALSE, previousVP.pointer());
|
||||
glUniform1f(uniform_boost_amount, boost_amount);
|
||||
glUniform2f(uniform_center, center.X, center.Y);
|
||||
glUniform1f(uniform_mask_radius, mask_radius);
|
||||
glUniform1i(uniform_color_buffer, TU_cb);
|
||||
glUniform1i(uniform_dtex, TU_dtex);
|
||||
}
|
||||
|
||||
GLuint GodFadeShader::Program;
|
||||
GLuint GodFadeShader::uniform_tex;
|
||||
GLuint GodFadeShader::uniform_col;
|
||||
GLuint GodFadeShader::vao;
|
||||
|
||||
void GodFadeShader::init()
|
||||
GodFadeShader::GodFadeShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/godfade.frag").c_str());
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_col = glGetUniformLocation(Program, "col");
|
||||
AssignUniforms("col");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
vao = createVAO(Program);
|
||||
}
|
||||
|
||||
void GodFadeShader::setUniforms(const SColor &col, unsigned TU_tex)
|
||||
{
|
||||
glUniform3f(uniform_col, col.getRed() / 255.f, col.getGreen() / 255.f, col.getBlue() / 255.f);
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
}
|
||||
|
||||
GLuint GodRayShader::Program;
|
||||
GLuint GodRayShader::uniform_tex;
|
||||
GLuint GodRayShader::uniform_sunpos;
|
||||
GLuint GodRayShader::vao;
|
||||
|
||||
void GodRayShader::init()
|
||||
GodRayShader::GodRayShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/godray.frag").c_str());
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_sunpos = glGetUniformLocation(Program, "sunpos");
|
||||
TU_tex = 0;
|
||||
AssignUniforms("sunpos");
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
vao = createVAO(Program);
|
||||
}
|
||||
|
||||
void GodRayShader::setUniforms(const core::vector2df &sunpos, unsigned TU_tex)
|
||||
{
|
||||
glUniform2f(uniform_sunpos, sunpos.X, sunpos.Y);
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
}
|
||||
|
||||
GLuint MLAAColorEdgeDetectionSHader::Program;
|
||||
GLuint MLAAColorEdgeDetectionSHader::uniform_colorMapG;
|
||||
GLuint MLAAColorEdgeDetectionSHader::uniform_PIXEL_SIZE;
|
||||
GLuint MLAAColorEdgeDetectionSHader::vao;
|
||||
|
||||
void MLAAColorEdgeDetectionSHader::init()
|
||||
MLAAColorEdgeDetectionSHader::MLAAColorEdgeDetectionSHader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/mlaa_offset.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/mlaa_color1.frag").c_str());
|
||||
uniform_colorMapG = glGetUniformLocation(Program, "colorMapG");
|
||||
uniform_PIXEL_SIZE = glGetUniformLocation(Program, "PIXEL_SIZE");
|
||||
AssignUniforms("PIXEL_SIZE");
|
||||
TU_colorMapG = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_colorMapG, "colorMapG"));
|
||||
vao = createVAO(Program);
|
||||
}
|
||||
|
||||
void MLAAColorEdgeDetectionSHader::setUniforms(const core::vector2df &PIXEL_SIZE, unsigned TU_colorMapG)
|
||||
{
|
||||
glUniform1i(uniform_colorMapG, TU_colorMapG);
|
||||
glUniform2f(uniform_PIXEL_SIZE, PIXEL_SIZE.X, PIXEL_SIZE.Y);
|
||||
}
|
||||
|
||||
GLuint MLAABlendWeightSHader::Program;
|
||||
GLuint MLAABlendWeightSHader::uniform_edgesMap;
|
||||
GLuint MLAABlendWeightSHader::uniform_areaMap;
|
||||
GLuint MLAABlendWeightSHader::uniform_PIXEL_SIZE;
|
||||
GLuint MLAABlendWeightSHader::vao;
|
||||
|
||||
void MLAABlendWeightSHader::init()
|
||||
MLAABlendWeightSHader::MLAABlendWeightSHader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/mlaa_blend2.frag").c_str());
|
||||
uniform_edgesMap = glGetUniformLocation(Program, "edgesMap");
|
||||
uniform_areaMap = glGetUniformLocation(Program, "areaMap");
|
||||
uniform_PIXEL_SIZE = glGetUniformLocation(Program, "PIXEL_SIZE");
|
||||
AssignUniforms("PIXEL_SIZE");
|
||||
TU_edgesMap = 0;
|
||||
TU_areaMap = 1;
|
||||
AssignTextureUnit(Program, TexUnit(TU_edgesMap, "edgesMap"), TexUnit(TU_areaMap, "areaMap"));
|
||||
vao = createVAO(Program);
|
||||
}
|
||||
|
||||
void MLAABlendWeightSHader::setUniforms(const core::vector2df &PIXEL_SIZE, unsigned TU_edgesMap, unsigned TU_areaMap)
|
||||
{
|
||||
glUniform1i(uniform_edgesMap, TU_edgesMap);
|
||||
glUniform1i(uniform_areaMap, TU_areaMap);
|
||||
glUniform2f(uniform_PIXEL_SIZE, PIXEL_SIZE.X, PIXEL_SIZE.Y);
|
||||
}
|
||||
|
||||
GLuint MLAAGatherSHader::Program;
|
||||
GLuint MLAAGatherSHader::uniform_colorMap;
|
||||
GLuint MLAAGatherSHader::uniform_blendMap;
|
||||
GLuint MLAAGatherSHader::uniform_PIXEL_SIZE;
|
||||
GLuint MLAAGatherSHader::vao;
|
||||
|
||||
void MLAAGatherSHader::init()
|
||||
MLAAGatherSHader::MLAAGatherSHader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/mlaa_offset.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/mlaa_neigh3.frag").c_str());
|
||||
uniform_colorMap = glGetUniformLocation(Program, "colorMap");
|
||||
uniform_blendMap = glGetUniformLocation(Program, "blendMap");
|
||||
uniform_PIXEL_SIZE = glGetUniformLocation(Program, "PIXEL_SIZE");
|
||||
AssignUniforms("PIXEL_SIZE");
|
||||
TU_blendMap = 0;
|
||||
TU_colorMap = 1;
|
||||
AssignTextureUnit(Program, TexUnit(TU_blendMap, "blendMap"), TexUnit(TU_colorMap, "colorMap"));
|
||||
vao = createVAO(Program);
|
||||
}
|
||||
|
||||
void MLAAGatherSHader::setUniforms(const core::vector2df &PIXEL_SIZE, unsigned TU_colormap, unsigned TU_blendmap)
|
||||
{
|
||||
glUniform1i(uniform_colorMap, TU_colormap);
|
||||
glUniform1i(uniform_blendMap, TU_blendmap);
|
||||
glUniform2f(uniform_PIXEL_SIZE, PIXEL_SIZE.X, PIXEL_SIZE.Y);
|
||||
}
|
||||
}
|
||||
|
||||
namespace UIShader
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
static GLuint billboardvbo;
|
||||
static GLuint cubevbo, cubeindexes, frustrumvbo, frustrumindexes;
|
||||
static GLuint ViewProjectionMatrixesUBO;
|
||||
static GLuint FullScreenQuadVAO;
|
||||
};
|
||||
|
||||
namespace UtilShader
|
||||
@ -54,6 +55,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 +118,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);
|
||||
@ -146,7 +155,6 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
friend class Singleton<class ObjectPass1Shader>;
|
||||
GLuint Program;
|
||||
|
||||
void setUniforms(const Args & ... args) const
|
||||
@ -520,33 +528,26 @@ public:
|
||||
namespace FullScreenShader
|
||||
{
|
||||
|
||||
class BloomShader
|
||||
class BloomShader : public ShaderHelperSingleton<BloomShader>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_texture;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(unsigned TU_tex);
|
||||
BloomShader();
|
||||
};
|
||||
|
||||
class BloomBlendShader
|
||||
class BloomBlendShader : public ShaderHelperSingleton<BloomBlendShader>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex_128, uniform_tex_256, uniform_tex_512;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex_128, TU_tex_256, TU_tex_512;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(unsigned TU_tex_128, unsigned TU_tex_256, unsigned TU_tex_512);
|
||||
BloomBlendShader();
|
||||
};
|
||||
|
||||
class ToneMapShader : public ShaderHelperSingleton<ToneMapShader>
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
ToneMapShader();
|
||||
};
|
||||
@ -555,7 +556,6 @@ class DepthOfFieldShader : public ShaderHelperSingleton<DepthOfFieldShader>
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex, TU_depth;
|
||||
GLuint vao;
|
||||
|
||||
DepthOfFieldShader();
|
||||
};
|
||||
@ -564,7 +564,6 @@ class SunLightShader : public ShaderHelperSingleton<SunLightShader, core::vector
|
||||
{
|
||||
public:
|
||||
GLuint TU_ntex, TU_dtex;
|
||||
GLuint vao;
|
||||
|
||||
SunLightShader();
|
||||
};
|
||||
@ -574,7 +573,6 @@ class DiffuseEnvMapShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_ntex, uniform_TVM, uniform_blueLmn, uniform_greenLmn, uniform_redLmn;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &TransposeViewMatrix, const float *blueSHCoeff, const float *greenSHCoeff, const float *redSHCoeff, unsigned TU_ntex);
|
||||
@ -584,7 +582,6 @@ class ShadowedSunLightShader : public ShaderHelperSingleton<ShadowedSunLightShad
|
||||
{
|
||||
public:
|
||||
GLuint TU_ntex, TU_dtex, TU_shadowtex;
|
||||
GLuint vao;
|
||||
|
||||
ShadowedSunLightShader();
|
||||
};
|
||||
@ -593,153 +590,129 @@ class RadianceHintsConstructionShader : public ShaderHelperSingleton<RadianceHin
|
||||
{
|
||||
public:
|
||||
GLuint TU_ctex, TU_ntex, TU_dtex;
|
||||
GLuint vao;
|
||||
|
||||
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>
|
||||
{
|
||||
public:
|
||||
GLuint TU_ntex, TU_dtex, TU_SHR, TU_SHG, TU_SHB, uniform_RHMatrix;
|
||||
GLuint vao;
|
||||
|
||||
GlobalIlluminationReconstructionShader();
|
||||
};
|
||||
|
||||
class Gaussian17TapHShader
|
||||
class Gaussian17TapHShader : public ShaderHelperSingleton<Gaussian17TapHShader, core::vector2df>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_depth, uniform_pixel;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex, TU_depth;
|
||||
|
||||
static void init();
|
||||
Gaussian17TapHShader();
|
||||
};
|
||||
|
||||
class ComputeGaussian17TapHShader
|
||||
class ComputeGaussian17TapHShader : public ShaderHelperSingleton<ComputeGaussian17TapHShader>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_source, uniform_depth, uniform_dest;
|
||||
|
||||
static void init();
|
||||
GLuint TU_source, TU_dest, TU_depth;
|
||||
ComputeGaussian17TapHShader();
|
||||
};
|
||||
|
||||
class Gaussian6HBlurShader
|
||||
class Gaussian6HBlurShader : public ShaderHelperSingleton<Gaussian6HBlurShader, core::vector2df>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_pixel;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex;
|
||||
|
||||
static void init();
|
||||
Gaussian6HBlurShader();
|
||||
};
|
||||
|
||||
class Gaussian3HBlurShader
|
||||
class Gaussian3HBlurShader : public ShaderHelperSingleton<Gaussian3HBlurShader, core::vector2df>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_pixel;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex;
|
||||
|
||||
static void init();
|
||||
Gaussian3HBlurShader();
|
||||
};
|
||||
|
||||
class Gaussian17TapVShader
|
||||
class Gaussian17TapVShader : public ShaderHelperSingleton<Gaussian17TapVShader, core::vector2df>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_depth, uniform_pixel;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex, TU_depth;
|
||||
|
||||
static void init();
|
||||
Gaussian17TapVShader();
|
||||
};
|
||||
|
||||
class ComputeGaussian17TapVShader
|
||||
class ComputeGaussian17TapVShader : public ShaderHelperSingleton<ComputeGaussian17TapVShader>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_source, uniform_depth, uniform_dest;
|
||||
GLuint TU_source, TU_depth, TU_dest;
|
||||
|
||||
static void init();
|
||||
ComputeGaussian17TapVShader();
|
||||
};
|
||||
|
||||
|
||||
class Gaussian6VBlurShader
|
||||
class Gaussian6VBlurShader : public ShaderHelperSingleton<Gaussian6VBlurShader, core::vector2df>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_pixel;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex;
|
||||
|
||||
static void init();
|
||||
Gaussian6VBlurShader();
|
||||
};
|
||||
|
||||
class Gaussian3VBlurShader
|
||||
class Gaussian3VBlurShader : public ShaderHelperSingleton<Gaussian3VBlurShader, core::vector2df>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_pixel;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex;
|
||||
|
||||
static void init();
|
||||
Gaussian3VBlurShader();
|
||||
};
|
||||
|
||||
class PassThroughShader
|
||||
class PassThroughShader : public ShaderHelperSingleton<PassThroughShader>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_texture;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
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>
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
LinearizeDepthShader();
|
||||
};
|
||||
|
||||
class GlowShader
|
||||
class GlowShader : public ShaderHelperSingleton<GlowShader>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
GlowShader();
|
||||
};
|
||||
|
||||
class SSAOShader : public ShaderHelperSingleton<SSAOShader, float, float, float>
|
||||
{
|
||||
public:
|
||||
GLuint TU_dtex;
|
||||
GLuint vao;
|
||||
|
||||
SSAOShader();
|
||||
};
|
||||
@ -748,77 +721,61 @@ class FogShader : public ShaderHelperSingleton<FogShader, float, float, float, f
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
FogShader();
|
||||
};
|
||||
|
||||
class MotionBlurShader
|
||||
class MotionBlurShader : public ShaderHelperSingleton<MotionBlurShader, core::matrix4, core::vector2df, float, float>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_boost_amount, uniform_color_buffer, uniform_dtex, uniform_previous_viewproj, uniform_center, uniform_mask_radius;
|
||||
static GLuint vao;
|
||||
GLuint TU_cb, TU_dtex;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(float boost_amount, const core::matrix4 &previousVP, const core::vector2df ¢er, float mask_radius, unsigned TU_cb, unsigned TU_dtex);
|
||||
MotionBlurShader();
|
||||
};
|
||||
|
||||
class GodFadeShader
|
||||
class GodFadeShader : public ShaderHelperSingleton<GodFadeShader, video::SColorf>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_col;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const video::SColor &col, unsigned TU_tex);
|
||||
GodFadeShader();
|
||||
};
|
||||
|
||||
class GodRayShader
|
||||
class GodRayShader : public ShaderHelperSingleton<GodRayShader, core::vector2df>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_sunpos;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::vector2df &sunpos, unsigned TU_tex);
|
||||
GodRayShader();
|
||||
};
|
||||
|
||||
class MLAAColorEdgeDetectionSHader
|
||||
class MLAAColorEdgeDetectionSHader : public ShaderHelperSingleton<MLAAColorEdgeDetectionSHader, core::vector2df>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_colorMapG, uniform_PIXEL_SIZE;
|
||||
static GLuint vao;
|
||||
GLuint TU_colorMapG;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::vector2df &PIXEL_SIZE, unsigned TU_colorMapG);
|
||||
MLAAColorEdgeDetectionSHader();
|
||||
};
|
||||
|
||||
class MLAABlendWeightSHader
|
||||
class MLAABlendWeightSHader : public ShaderHelperSingleton<MLAABlendWeightSHader, core::vector2df>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_PIXEL_SIZE, uniform_edgesMap, uniform_areaMap;
|
||||
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::vector2df &PIXEL_SIZE, unsigned TU_edgesMap, unsigned TU_areaMap);
|
||||
GLuint TU_edgesMap, TU_areaMap;
|
||||
GLuint vao;
|
||||
|
||||
MLAABlendWeightSHader();
|
||||
};
|
||||
|
||||
class MLAAGatherSHader
|
||||
class MLAAGatherSHader : public ShaderHelperSingleton<MLAAGatherSHader, core::vector2df>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_PIXEL_SIZE, uniform_colorMap, uniform_blendMap;
|
||||
static GLuint vao;
|
||||
GLuint TU_colorMap, TU_blendMap;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::vector2df &PIXEL_SIZE, unsigned TU_colormap, unsigned TU_blendmap);
|
||||
MLAAGatherSHader();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -142,16 +142,16 @@ void STKAnimatedMesh::render()
|
||||
|
||||
GLMesh* mesh;
|
||||
for_in(mesh, MeshSolidMaterial[MAT_DEFAULT])
|
||||
pushVector(ListMatDefault::Arguments, mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
pushVector(ListMatDefault::getInstance(), mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
|
||||
for_in(mesh, MeshSolidMaterial[MAT_ALPHA_REF])
|
||||
pushVector(ListMatAlphaRef::Arguments, mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
pushVector(ListMatAlphaRef::getInstance(), mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
|
||||
for_in(mesh, MeshSolidMaterial[MAT_DETAIL])
|
||||
pushVector(ListMatDetails::Arguments, mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
pushVector(ListMatDetails::getInstance(), mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
|
||||
for_in(mesh, MeshSolidMaterial[MAT_UNLIT])
|
||||
pushVector(ListMatUnlit::Arguments, mesh, AbsoluteTransformation, core::matrix4::EM4CONST_IDENTITY, mesh->TextureMatrix);
|
||||
pushVector(ListMatUnlit::getInstance(), mesh, AbsoluteTransformation, core::matrix4::EM4CONST_IDENTITY, mesh->TextureMatrix);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -181,21 +181,21 @@ void STKAnimatedMesh::render()
|
||||
tmpcol.getBlue() / 255.0f);
|
||||
|
||||
for_in(mesh, TransparentMesh[TM_DEFAULT])
|
||||
ListBlendTransparentFog::Arguments.push_back(
|
||||
ListBlendTransparentFog::getInstance()->push_back(
|
||||
STK::make_tuple(mesh, AbsoluteTransformation, mesh->TextureMatrix,
|
||||
fogmax, startH, endH, start, end, col));
|
||||
for_in(mesh, TransparentMesh[TM_ADDITIVE])
|
||||
ListAdditiveTransparentFog::Arguments.push_back(
|
||||
ListAdditiveTransparentFog::getInstance()->push_back(
|
||||
STK::make_tuple(mesh, AbsoluteTransformation, mesh->TextureMatrix,
|
||||
fogmax, startH, endH, start, end, col));
|
||||
}
|
||||
else
|
||||
{
|
||||
for_in(mesh, TransparentMesh[TM_DEFAULT])
|
||||
pushVector(ListBlendTransparent::Arguments, mesh, AbsoluteTransformation, mesh->TextureMatrix);
|
||||
pushVector(ListBlendTransparent::getInstance(), mesh, AbsoluteTransformation, mesh->TextureMatrix);
|
||||
|
||||
for_in(mesh, TransparentMesh[TM_ADDITIVE])
|
||||
pushVector(ListAdditiveTransparent::Arguments, mesh, AbsoluteTransformation, mesh->TextureMatrix);
|
||||
pushVector(ListAdditiveTransparent::getInstance(), mesh, AbsoluteTransformation, mesh->TextureMatrix);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -291,19 +291,4 @@ bool isObject(video::E_MATERIAL_TYPE type)
|
||||
if (type == video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > ListMatDefault::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > ListMatAlphaRef::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > ListMatSphereMap::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > ListMatDetails::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::vector3df> > ListMatGrass::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > ListMatUnlit::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > ListMatSplatting::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > ListMatNormalMap::Arguments;
|
||||
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > ListBlendTransparent::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > ListAdditiveTransparent::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > ListBlendTransparentFog::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > ListAdditiveTransparentFog::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4> > ListDisplacement::Arguments;
|
||||
}
|
@ -58,85 +58,49 @@ bool isObject(video::E_MATERIAL_TYPE type);
|
||||
|
||||
core::vector3df getWind();
|
||||
|
||||
// Pass 1 shader (ie shaders that outputs normals and depth)
|
||||
class ListMatDefault
|
||||
{
|
||||
public:
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > Arguments;
|
||||
};
|
||||
template<typename T, typename... Args>
|
||||
class MeshList : public Singleton<T>, public std::vector<STK::Tuple<Args...> >
|
||||
{};
|
||||
|
||||
class ListMatAlphaRef
|
||||
{
|
||||
public:
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > Arguments;
|
||||
};
|
||||
class ListMatDefault : public MeshList<ListMatDefault, GLMesh *, core::matrix4, core::matrix4, core::matrix4>
|
||||
{};
|
||||
|
||||
class ListMatNormalMap
|
||||
{
|
||||
public:
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > Arguments;
|
||||
};
|
||||
class ListMatAlphaRef : public MeshList<ListMatAlphaRef, GLMesh *, core::matrix4, core::matrix4, core::matrix4>
|
||||
{};
|
||||
|
||||
class ListMatGrass
|
||||
{
|
||||
public:
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::vector3df> > Arguments;
|
||||
};
|
||||
class ListMatNormalMap : public MeshList<ListMatNormalMap, GLMesh *, core::matrix4, core::matrix4, core::matrix4>
|
||||
{};
|
||||
|
||||
class ListMatSphereMap
|
||||
{
|
||||
public:
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > Arguments;
|
||||
};
|
||||
class ListMatGrass : public MeshList<ListMatGrass, GLMesh *, core::matrix4, core::matrix4, core::vector3df>
|
||||
{};
|
||||
|
||||
class ListMatSplatting
|
||||
{
|
||||
public:
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
|
||||
};
|
||||
class ListMatSphereMap : public MeshList<ListMatSphereMap, GLMesh *, core::matrix4, core::matrix4, core::matrix4>
|
||||
{};
|
||||
|
||||
class ListMatUnlit
|
||||
{
|
||||
public:
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > Arguments;
|
||||
};
|
||||
class ListMatSplatting : public MeshList<ListMatSplatting, GLMesh *, core::matrix4, core::matrix4>
|
||||
{};
|
||||
|
||||
class ListMatDetails
|
||||
{
|
||||
public:
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4> > Arguments;
|
||||
};
|
||||
class ListMatUnlit : public MeshList<ListMatUnlit, GLMesh *, core::matrix4, core::matrix4, core::matrix4>
|
||||
{};
|
||||
|
||||
class ListMatDetails : public MeshList<ListMatDetails, GLMesh *, core::matrix4, core::matrix4, core::matrix4>
|
||||
{};
|
||||
|
||||
|
||||
class ListBlendTransparent
|
||||
{
|
||||
public:
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
|
||||
};
|
||||
class ListBlendTransparent : public MeshList<ListBlendTransparent, GLMesh *, core::matrix4, core::matrix4>
|
||||
{};
|
||||
|
||||
class ListAdditiveTransparent
|
||||
{
|
||||
public:
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
|
||||
};
|
||||
class ListAdditiveTransparent : public MeshList<ListAdditiveTransparent, GLMesh *, core::matrix4, core::matrix4>
|
||||
{};
|
||||
|
||||
class ListBlendTransparentFog
|
||||
{
|
||||
public:
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > Arguments;
|
||||
};
|
||||
class ListBlendTransparentFog : public MeshList<ListBlendTransparentFog, GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf>
|
||||
{};
|
||||
|
||||
class ListAdditiveTransparentFog
|
||||
{
|
||||
public:
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > Arguments;
|
||||
};
|
||||
class ListAdditiveTransparentFog : public MeshList<ListAdditiveTransparentFog, GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf>
|
||||
{};
|
||||
|
||||
class ListDisplacement
|
||||
{
|
||||
public:
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4> > Arguments;
|
||||
};
|
||||
class ListDisplacement : public MeshList<ListDisplacement, GLMesh *, core::matrix4>
|
||||
{};
|
||||
|
||||
// Forward pass (for transparents meshes)
|
||||
void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
|
||||
|
@ -249,29 +249,29 @@ void STKMeshSceneNode::render()
|
||||
|
||||
GLMesh* mesh;
|
||||
for_in(mesh, MeshSolidMaterials[MAT_DEFAULT])
|
||||
pushVector(ListMatDefault::Arguments, mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
pushVector(ListMatDefault::getInstance(), mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
|
||||
for_in(mesh, MeshSolidMaterials[MAT_ALPHA_REF])
|
||||
pushVector(ListMatAlphaRef::Arguments, mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
pushVector(ListMatAlphaRef::getInstance(), mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
|
||||
for_in(mesh, MeshSolidMaterials[MAT_SPHEREMAP])
|
||||
pushVector(ListMatSphereMap::Arguments, mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
pushVector(ListMatSphereMap::getInstance(), mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
|
||||
for_in(mesh, MeshSolidMaterials[MAT_DETAIL])
|
||||
pushVector(ListMatDetails::Arguments, mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
pushVector(ListMatDetails::getInstance(), mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
|
||||
windDir = getWind();
|
||||
for_in(mesh, MeshSolidMaterials[MAT_GRASS])
|
||||
pushVector(ListMatGrass::Arguments, mesh, AbsoluteTransformation, invmodel, windDir);
|
||||
pushVector(ListMatGrass::getInstance(), mesh, AbsoluteTransformation, invmodel, windDir);
|
||||
|
||||
for_in(mesh, MeshSolidMaterials[MAT_UNLIT])
|
||||
pushVector(ListMatUnlit::Arguments, mesh, AbsoluteTransformation, core::matrix4::EM4CONST_IDENTITY, mesh->TextureMatrix);
|
||||
pushVector(ListMatUnlit::getInstance(), mesh, AbsoluteTransformation, core::matrix4::EM4CONST_IDENTITY, mesh->TextureMatrix);
|
||||
|
||||
for_in(mesh, MeshSolidMaterials[MAT_SPLATTING])
|
||||
pushVector(ListMatSplatting::Arguments, mesh, AbsoluteTransformation, invmodel);
|
||||
pushVector(ListMatSplatting::getInstance(), mesh, AbsoluteTransformation, invmodel);
|
||||
|
||||
for_in(mesh, MeshSolidMaterials[MAT_NORMAL_MAP])
|
||||
pushVector( ListMatNormalMap::Arguments, mesh, AbsoluteTransformation, invmodel, core::matrix4::EM4CONST_IDENTITY);
|
||||
pushVector(ListMatNormalMap::getInstance(), mesh, AbsoluteTransformation, invmodel, core::matrix4::EM4CONST_IDENTITY);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -411,23 +411,23 @@ void STKMeshSceneNode::render()
|
||||
tmpcol.getBlue() / 255.0f);
|
||||
|
||||
for_in(mesh, TransparentMesh[TM_DEFAULT])
|
||||
pushVector(ListBlendTransparentFog::Arguments, mesh, AbsoluteTransformation, mesh->TextureMatrix,
|
||||
pushVector(ListBlendTransparentFog::getInstance(), mesh, AbsoluteTransformation, mesh->TextureMatrix,
|
||||
fogmax, startH, endH, start, end, col);
|
||||
for_in(mesh, TransparentMesh[TM_ADDITIVE])
|
||||
pushVector(ListAdditiveTransparentFog::Arguments, mesh, AbsoluteTransformation, mesh->TextureMatrix,
|
||||
pushVector(ListAdditiveTransparentFog::getInstance(), mesh, AbsoluteTransformation, mesh->TextureMatrix,
|
||||
fogmax, startH, endH, start, end, col);
|
||||
}
|
||||
else
|
||||
{
|
||||
for_in(mesh, TransparentMesh[TM_DEFAULT])
|
||||
pushVector(ListBlendTransparent::Arguments, mesh, AbsoluteTransformation, mesh->TextureMatrix);
|
||||
pushVector(ListBlendTransparent::getInstance(), mesh, AbsoluteTransformation, mesh->TextureMatrix);
|
||||
|
||||
for_in(mesh, TransparentMesh[TM_ADDITIVE])
|
||||
pushVector(ListAdditiveTransparent::Arguments, mesh, AbsoluteTransformation, mesh->TextureMatrix);
|
||||
pushVector(ListAdditiveTransparent::getInstance(), mesh, AbsoluteTransformation, mesh->TextureMatrix);
|
||||
}
|
||||
|
||||
for_in(mesh, TransparentMesh[TM_DISPLACEMENT])
|
||||
pushVector(ListDisplacement::Arguments, mesh, AbsoluteTransformation);
|
||||
pushVector(ListDisplacement::getInstance(), mesh, AbsoluteTransformation);
|
||||
|
||||
if (!TransparentMesh[TM_BUBBLE].empty())
|
||||
glUseProgram(MeshShader::BubbleShader::Program);
|
||||
|
@ -83,7 +83,7 @@ void CustomVideoSettingsDialog::beforeAddingWidgets()
|
||||
shadows->addLabel( _("Disabled") ); // 0
|
||||
shadows->addLabel( _("low") ); // 1
|
||||
shadows->addLabel( _("high") ); // 2
|
||||
if (irr_driver->needUBOWorkaround())
|
||||
if (!irr_driver->needUBOWorkaround())
|
||||
shadows->setValue(UserConfigParams::m_shadows);
|
||||
else
|
||||
shadows->setValue(0);
|
||||
|
@ -19,12 +19,12 @@
|
||||
|
||||
|
||||
template<typename T, typename... Args>
|
||||
void pushVector(std::vector<T> &vec, Args ...args)
|
||||
void pushVector(std::vector<T> *vec, Args ...args)
|
||||
{
|
||||
#ifdef STDCPP2003
|
||||
vec.push_back(T(args...));
|
||||
vec->push_back(T(args...));
|
||||
#else
|
||||
vec.emplace_back(args...);
|
||||
vec->emplace_back(args...);
|
||||
#endif
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user