Use template defined SetTexture argument sets instead of vector

This commit is contained in:
Vincent Lejeune 2014-10-19 00:25:56 +02:00
parent 9ca4d7e3e6
commit d0b996ab4a
10 changed files with 417 additions and 277 deletions

View File

@ -21,7 +21,7 @@ static void drawTexColoredQuad(const video::ITexture *texture, const video::SCol
glUseProgram(UIShader::ColoredTextureRectShader::getInstance()->Program); glUseProgram(UIShader::ColoredTextureRectShader::getInstance()->Program);
glBindVertexArray(UIShader::ColoredTextureRectShader::getInstance()->vao); glBindVertexArray(UIShader::ColoredTextureRectShader::getInstance()->vao);
UIShader::ColoredTextureRectShader::getInstance()->SetTextureUnits(createVector<GLuint>(static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName())); UIShader::ColoredTextureRectShader::getInstance()->SetTextureUnits(static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName());
UIShader::ColoredTextureRectShader::getInstance()->setUniforms( UIShader::ColoredTextureRectShader::getInstance()->setUniforms(
core::vector2df(center_pos_x, center_pos_y), core::vector2df(width, height), core::vector2df(center_pos_x, center_pos_y), core::vector2df(width, height),
core::vector2df(tex_center_pos_x, tex_center_pos_y), core::vector2df(tex_width, tex_height)); core::vector2df(tex_center_pos_x, tex_center_pos_y), core::vector2df(tex_width, tex_height));
@ -41,7 +41,7 @@ float tex_width, float tex_height)
glUseProgram(UIShader::TextureRectShader::getInstance()->Program); glUseProgram(UIShader::TextureRectShader::getInstance()->Program);
glBindVertexArray(SharedObject::UIVAO); glBindVertexArray(SharedObject::UIVAO);
UIShader::TextureRectShader::getInstance()->SetTextureUnits(createVector<GLuint>(texture)); UIShader::TextureRectShader::getInstance()->SetTextureUnits(texture);
UIShader::TextureRectShader::getInstance()->setUniforms( UIShader::TextureRectShader::getInstance()->setUniforms(
core::vector2df(center_pos_x, center_pos_y), core::vector2df(width, height), core::vector2df(center_pos_x, center_pos_y), core::vector2df(width, height),
core::vector2df(tex_center_pos_x, tex_center_pos_y), core::vector2df(tex_center_pos_x, tex_center_pos_y),
@ -144,7 +144,7 @@ void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect
glUseProgram(UIShader::UniformColoredTextureRectShader::getInstance()->Program); glUseProgram(UIShader::UniformColoredTextureRectShader::getInstance()->Program);
glBindVertexArray(SharedObject::UIVAO); glBindVertexArray(SharedObject::UIVAO);
UIShader::UniformColoredTextureRectShader::getInstance()->SetTextureUnits(createVector<GLuint>(static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName())); UIShader::UniformColoredTextureRectShader::getInstance()->SetTextureUnits(static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName());
UIShader::UniformColoredTextureRectShader::getInstance()->setUniforms( UIShader::UniformColoredTextureRectShader::getInstance()->setUniforms(
core::vector2df(center_pos_x, center_pos_y), core::vector2df(width, height), core::vector2df(tex_center_pos_x, tex_center_pos_y), core::vector2df(tex_width, tex_height), colors); core::vector2df(center_pos_x, center_pos_y), core::vector2df(width, height), core::vector2df(tex_center_pos_x, tex_center_pos_y), core::vector2df(tex_width, tex_height), colors);
@ -180,7 +180,7 @@ void draw2DImageFromRTT(GLuint texture, size_t texture_w, size_t texture_h,
glUseProgram(UIShader::UniformColoredTextureRectShader::getInstance()->Program); glUseProgram(UIShader::UniformColoredTextureRectShader::getInstance()->Program);
glBindVertexArray(SharedObject::UIVAO); glBindVertexArray(SharedObject::UIVAO);
UIShader::UniformColoredTextureRectShader::getInstance()->SetTextureUnits(createVector<GLuint>(texture)); UIShader::UniformColoredTextureRectShader::getInstance()->SetTextureUnits(texture);
UIShader::UniformColoredTextureRectShader::getInstance()->setUniforms( UIShader::UniformColoredTextureRectShader::getInstance()->setUniforms(
core::vector2df(center_pos_x, center_pos_y), core::vector2df(width, height), core::vector2df(center_pos_x, center_pos_y), core::vector2df(width, height),
core::vector2df(tex_center_pos_x, tex_center_pos_y), core::vector2df(tex_width, tex_height), core::vector2df(tex_center_pos_x, tex_center_pos_y), core::vector2df(tex_width, tex_height),
@ -268,7 +268,7 @@ void draw2DVertexPrimitiveList(video::ITexture *tex, const void* vertices,
UIShader::Primitive2DList::getInstance()->setUniforms(); UIShader::Primitive2DList::getInstance()->setUniforms();
const video::SOverrideMaterial &m = irr_driver->getVideoDriver()->getOverrideMaterial(); const video::SOverrideMaterial &m = irr_driver->getVideoDriver()->getOverrideMaterial();
compressTexture(tex, false); compressTexture(tex, false);
UIShader::Primitive2DList::getInstance()->SetTextureUnits({ getTextureGLuint(tex) }); UIShader::Primitive2DList::getInstance()->SetTextureUnits(getTextureGLuint(tex));
glDrawElements(GL_TRIANGLE_FAN, primitiveCount, GL_UNSIGNED_SHORT, 0); glDrawElements(GL_TRIANGLE_FAN, primitiveCount, GL_UNSIGNED_SHORT, 0);
glDeleteVertexArrays(1, &tmpvao); glDeleteVertexArrays(1, &tmpvao);

View File

@ -350,7 +350,7 @@ void ParticleSystemProxy::drawFlip()
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
glUseProgram(ParticleShader::FlipParticleRender::getInstance()->Program); glUseProgram(ParticleShader::FlipParticleRender::getInstance()->Program);
ParticleShader::FlipParticleRender::getInstance()->SetTextureUnits(std::vector<GLuint>{ texture, irr_driver->getDepthStencilTexture() }); ParticleShader::FlipParticleRender::getInstance()->SetTextureUnits(texture, irr_driver->getDepthStencilTexture());
ParticleShader::FlipParticleRender::getInstance()->setUniforms(); ParticleShader::FlipParticleRender::getInstance()->setUniforms();
glBindVertexArray(current_rendering_vao); glBindVertexArray(current_rendering_vao);
@ -365,7 +365,7 @@ void ParticleSystemProxy::drawNotFlip()
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glUseProgram(ParticleShader::SimpleParticleRender::getInstance()->Program); glUseProgram(ParticleShader::SimpleParticleRender::getInstance()->Program);
ParticleShader::SimpleParticleRender::getInstance()->SetTextureUnits(std::vector<GLuint>{ texture, irr_driver->getDepthStencilTexture() }); ParticleShader::SimpleParticleRender::getInstance()->SetTextureUnits(texture, irr_driver->getDepthStencilTexture());
video::SColorf ColorFrom = video::SColorf(getColorFrom()[0], getColorFrom()[1], getColorFrom()[2]); video::SColorf ColorFrom = video::SColorf(getColorFrom()[0], getColorFrom()[1], getColorFrom()[2]);
video::SColorf ColorTo = video::SColorf(getColorTo()[0], getColorTo()[1], getColorTo()[2]); video::SColorf ColorTo = video::SColorf(getColorTo()[0], getColorTo()[1], getColorTo()[2]);

View File

@ -217,7 +217,7 @@ static void DrawFullScreenEffect(Args...args)
static static
void renderBloom(GLuint in) void renderBloom(GLuint in)
{ {
FullScreenShader::BloomShader::getInstance()->SetTextureUnits(createVector<GLuint>(in)); FullScreenShader::BloomShader::getInstance()->SetTextureUnits(in);
DrawFullScreenEffect<FullScreenShader::BloomShader>(); DrawFullScreenEffect<FullScreenShader::BloomShader>();
} }
@ -231,7 +231,7 @@ void PostProcessing::renderEnvMap(const float *bSHCoeff, const float *gSHCoeff,
glUseProgram(FullScreenShader::EnvMapShader::getInstance()->Program); glUseProgram(FullScreenShader::EnvMapShader::getInstance()->Program);
glBindVertexArray(SharedObject::FullScreenQuadVAO); glBindVertexArray(SharedObject::FullScreenQuadVAO);
FullScreenShader::EnvMapShader::getInstance()->SetTextureUnits(createVector<GLuint>(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture(), skybox)); FullScreenShader::EnvMapShader::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture(), skybox);
core::matrix4 TVM = irr_driver->getViewMatrix().getTransposed(); core::matrix4 TVM = irr_driver->getViewMatrix().getTransposed();
FullScreenShader::EnvMapShader::getInstance()->setUniforms(TVM, std::vector<float>(bSHCoeff, bSHCoeff + 9), std::vector<float>(gSHCoeff, gSHCoeff + 9), std::vector<float>(rSHCoeff, rSHCoeff + 9)); FullScreenShader::EnvMapShader::getInstance()->setUniforms(TVM, std::vector<float>(bSHCoeff, bSHCoeff + 9), std::vector<float>(gSHCoeff, gSHCoeff + 9), std::vector<float>(rSHCoeff, rSHCoeff + 9));
@ -264,8 +264,8 @@ void PostProcessing::renderGI(const core::matrix4 &RHMatrix, const core::vector3
core::matrix4 InvRHMatrix; core::matrix4 InvRHMatrix;
RHMatrix.getInverse(InvRHMatrix); RHMatrix.getInverse(InvRHMatrix);
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
FullScreenShader::GlobalIlluminationReconstructionShader::getInstance()->SetTextureUnits(createVector<GLuint>( FullScreenShader::GlobalIlluminationReconstructionShader::getInstance()->SetTextureUnits(
irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture(), shr, shg, shb)); irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture(), shr, shg, shb);
DrawFullScreenEffect<FullScreenShader::GlobalIlluminationReconstructionShader>(RHMatrix, InvRHMatrix, rh_extend); DrawFullScreenEffect<FullScreenShader::GlobalIlluminationReconstructionShader>(RHMatrix, InvRHMatrix, rh_extend);
} }
@ -278,7 +278,7 @@ void PostProcessing::renderSunlight()
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
glBlendEquation(GL_FUNC_ADD); glBlendEquation(GL_FUNC_ADD);
FullScreenShader::SunLightShader::getInstance()->SetTextureUnits(createVector<GLuint>(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture())); FullScreenShader::SunLightShader::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture());
DrawFullScreenEffect<FullScreenShader::SunLightShader>(cb->getPosition(), video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue())); DrawFullScreenEffect<FullScreenShader::SunLightShader>(cb->getPosition(), video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
} }
@ -291,7 +291,7 @@ void PostProcessing::renderShadowedSunlight(const std::vector<core::matrix4> &su
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
glBlendEquation(GL_FUNC_ADD); glBlendEquation(GL_FUNC_ADD);
FullScreenShader::ShadowedSunLightShader::getInstance()->SetTextureUnits(createVector<GLuint>( irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture(), depthtex )); FullScreenShader::ShadowedSunLightShader::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture(), depthtex);
DrawFullScreenEffect<FullScreenShader::ShadowedSunLightShader>(cb->getPosition(), video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue())); DrawFullScreenEffect<FullScreenShader::ShadowedSunLightShader>(cb->getPosition(), video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
} }
@ -303,13 +303,13 @@ void PostProcessing::renderGaussian3Blur(FrameBuffer &in_fbo, FrameBuffer &auxil
{ {
auxiliary.Bind(); auxiliary.Bind();
FullScreenShader::Gaussian3VBlurShader::getInstance()->SetTextureUnits(createVector<GLuint>(in_fbo.getRTT()[0])); FullScreenShader::Gaussian3VBlurShader::getInstance()->SetTextureUnits(in_fbo.getRTT()[0]);
DrawFullScreenEffect<FullScreenShader::Gaussian3VBlurShader>(core::vector2df(inv_width, inv_height)); DrawFullScreenEffect<FullScreenShader::Gaussian3VBlurShader>(core::vector2df(inv_width, inv_height));
} }
{ {
in_fbo.Bind(); in_fbo.Bind();
FullScreenShader::Gaussian3HBlurShader::getInstance()->SetTextureUnits(createVector<GLuint>(auxiliary.getRTT()[0])); FullScreenShader::Gaussian3HBlurShader::getInstance()->SetTextureUnits(auxiliary.getRTT()[0]);
DrawFullScreenEffect<FullScreenShader::Gaussian3HBlurShader>(core::vector2df(inv_width, inv_height)); DrawFullScreenEffect<FullScreenShader::Gaussian3HBlurShader>(core::vector2df(inv_width, inv_height));
} }
} }
@ -321,13 +321,13 @@ void PostProcessing::renderGaussian6Blur(FrameBuffer &in_fbo, FrameBuffer &auxil
{ {
auxiliary.Bind(); auxiliary.Bind();
FullScreenShader::Gaussian6VBlurShader::getInstance()->SetTextureUnits(createVector<GLuint>(in_fbo.getRTT()[0])); FullScreenShader::Gaussian6VBlurShader::getInstance()->SetTextureUnits(in_fbo.getRTT()[0]);
DrawFullScreenEffect<FullScreenShader::Gaussian6VBlurShader>(core::vector2df(inv_width, inv_height)); DrawFullScreenEffect<FullScreenShader::Gaussian6VBlurShader>(core::vector2df(inv_width, inv_height));
} }
{ {
in_fbo.Bind(); in_fbo.Bind();
FullScreenShader::Gaussian6HBlurShader::getInstance()->SetTextureUnits(createVector<GLuint>(auxiliary.getRTT()[0])); FullScreenShader::Gaussian6HBlurShader::getInstance()->SetTextureUnits(auxiliary.getRTT()[0]);
DrawFullScreenEffect<FullScreenShader::Gaussian6HBlurShader>(core::vector2df(inv_width, inv_height)); DrawFullScreenEffect<FullScreenShader::Gaussian6HBlurShader>(core::vector2df(inv_width, inv_height));
} }
} }
@ -342,14 +342,14 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
if (!irr_driver->hasARBComputeShaders()) if (!irr_driver->hasARBComputeShaders())
{ {
auxiliary.Bind(); auxiliary.Bind();
FullScreenShader::Gaussian17TapHShader::getInstance()->SetTextureUnits(createVector<GLuint>(in_fbo.getRTT()[0], irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0])); FullScreenShader::Gaussian17TapHShader::getInstance()->SetTextureUnits(in_fbo.getRTT()[0], irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0]);
DrawFullScreenEffect<FullScreenShader::Gaussian17TapHShader>(core::vector2df(inv_width, inv_height)); DrawFullScreenEffect<FullScreenShader::Gaussian17TapHShader>(core::vector2df(inv_width, inv_height));
} }
else else
{ {
glUseProgram(FullScreenShader::ComputeGaussian17TapHShader::getInstance()->Program); glUseProgram(FullScreenShader::ComputeGaussian17TapHShader::getInstance()->Program);
glBindSampler(FullScreenShader::ComputeGaussian17TapHShader::getInstance()->TU_dest, 0); glBindSampler(FullScreenShader::ComputeGaussian17TapHShader::getInstance()->TU_dest, 0);
FullScreenShader::ComputeGaussian17TapHShader::getInstance()->SetTextureUnits({ in_fbo.getRTT()[0], irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0] }); FullScreenShader::ComputeGaussian17TapHShader::getInstance()->SetTextureUnits(in_fbo.getRTT()[0], irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0]);
glBindImageTexture(FullScreenShader::ComputeGaussian17TapHShader::getInstance()->TU_dest, auxiliary.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R16F); glBindImageTexture(FullScreenShader::ComputeGaussian17TapHShader::getInstance()->TU_dest, auxiliary.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R16F);
FullScreenShader::ComputeGaussian17TapHShader::getInstance()->setUniforms(core::vector2df(inv_width, inv_height)); FullScreenShader::ComputeGaussian17TapHShader::getInstance()->setUniforms(core::vector2df(inv_width, inv_height));
glDispatchCompute((int)in_fbo.getWidth() / 8 + 1, (int)in_fbo.getHeight() / 8 + 1, 1); glDispatchCompute((int)in_fbo.getWidth() / 8 + 1, (int)in_fbo.getHeight() / 8 + 1, 1);
@ -362,14 +362,14 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
{ {
in_fbo.Bind(); in_fbo.Bind();
FullScreenShader::Gaussian17TapVShader::getInstance()->SetTextureUnits(createVector<GLuint>(auxiliary.getRTT()[0], irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0])); FullScreenShader::Gaussian17TapVShader::getInstance()->SetTextureUnits(auxiliary.getRTT()[0], irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0]);
DrawFullScreenEffect<FullScreenShader::Gaussian17TapVShader>(core::vector2df(inv_width, inv_height)); DrawFullScreenEffect<FullScreenShader::Gaussian17TapVShader>(core::vector2df(inv_width, inv_height));
} }
else else
{ {
glUseProgram(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->Program); glUseProgram(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->Program);
glBindSampler(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->TU_dest, 0); glBindSampler(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->TU_dest, 0);
FullScreenShader::ComputeGaussian17TapVShader::getInstance()->SetTextureUnits({ auxiliary.getRTT()[0], irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0] }); FullScreenShader::ComputeGaussian17TapVShader::getInstance()->SetTextureUnits(auxiliary.getRTT()[0], irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0]);
glBindImageTexture(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->TU_dest, in_fbo.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R16F); glBindImageTexture(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->TU_dest, in_fbo.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R16F);
FullScreenShader::ComputeGaussian17TapVShader::getInstance()->setUniforms(core::vector2df(inv_width, inv_height)); FullScreenShader::ComputeGaussian17TapVShader::getInstance()->setUniforms(core::vector2df(inv_width, inv_height));
glDispatchCompute((int)in_fbo.getWidth() / 8 + 1, (int)in_fbo.getHeight() / 8 + 1, 1); glDispatchCompute((int)in_fbo.getWidth() / 8 + 1, (int)in_fbo.getHeight() / 8 + 1, 1);
@ -384,7 +384,7 @@ void PostProcessing::renderPassThrough(GLuint tex)
glUseProgram(FullScreenShader::PassThroughShader::getInstance()->Program); glUseProgram(FullScreenShader::PassThroughShader::getInstance()->Program);
glBindVertexArray(FullScreenShader::PassThroughShader::getInstance()->vao); glBindVertexArray(FullScreenShader::PassThroughShader::getInstance()->vao);
FullScreenShader::PassThroughShader::getInstance()->SetTextureUnits(createVector<GLuint>(tex)); FullScreenShader::PassThroughShader::getInstance()->SetTextureUnits(tex);
FullScreenShader::PassThroughShader::getInstance()->setUniforms(); FullScreenShader::PassThroughShader::getInstance()->setUniforms();
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
@ -409,7 +409,7 @@ void PostProcessing::renderGlow(unsigned tex)
glUseProgram(FullScreenShader::GlowShader::getInstance()->Program); glUseProgram(FullScreenShader::GlowShader::getInstance()->Program);
glBindVertexArray(FullScreenShader::GlowShader::getInstance()->vao); glBindVertexArray(FullScreenShader::GlowShader::getInstance()->vao);
FullScreenShader::GlowShader::getInstance()->SetTextureUnits(createVector<GLuint>(tex)); FullScreenShader::GlowShader::getInstance()->SetTextureUnits(tex);
FullScreenShader::GlowShader::getInstance()->setUniforms(); FullScreenShader::GlowShader::getInstance()->setUniforms();
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
@ -422,11 +422,11 @@ void PostProcessing::renderSSAO()
// Generate linear depth buffer // Generate linear depth buffer
irr_driver->getFBO(FBO_LINEAR_DEPTH).Bind(); irr_driver->getFBO(FBO_LINEAR_DEPTH).Bind();
FullScreenShader::LinearizeDepthShader::getInstance()->SetTextureUnits(createVector<GLuint>(irr_driver->getDepthStencilTexture())); FullScreenShader::LinearizeDepthShader::getInstance()->SetTextureUnits(irr_driver->getDepthStencilTexture());
DrawFullScreenEffect<FullScreenShader::LinearizeDepthShader>(irr_driver->getSceneManager()->getActiveCamera()->getNearValue(), irr_driver->getSceneManager()->getActiveCamera()->getFarValue()); DrawFullScreenEffect<FullScreenShader::LinearizeDepthShader>(irr_driver->getSceneManager()->getActiveCamera()->getNearValue(), irr_driver->getSceneManager()->getActiveCamera()->getFarValue());
irr_driver->getFBO(FBO_SSAO).Bind(); irr_driver->getFBO(FBO_SSAO).Bind();
FullScreenShader::SSAOShader::getInstance()->SetTextureUnits(createVector<GLuint>(irr_driver->getRenderTargetTexture(RTT_LINEAR_DEPTH))); FullScreenShader::SSAOShader::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_LINEAR_DEPTH));
glGenerateMipmap(GL_TEXTURE_2D); glGenerateMipmap(GL_TEXTURE_2D);
DrawFullScreenEffect<FullScreenShader::SSAOShader>(irr_driver->getSSAORadius(), irr_driver->getSSAOK(), irr_driver->getSSAOSigma()); DrawFullScreenEffect<FullScreenShader::SSAOShader>(irr_driver->getSSAORadius(), irr_driver->getSSAOK(), irr_driver->getSSAOSigma());
@ -454,7 +454,7 @@ void PostProcessing::renderFog()
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
FullScreenShader::FogShader::getInstance()->SetTextureUnits(createVector<GLuint>(irr_driver->getDepthStencilTexture())); FullScreenShader::FogShader::getInstance()->SetTextureUnits(irr_driver->getDepthStencilTexture());
DrawFullScreenEffect<FullScreenShader::FogShader>(fogmax, startH, endH, start, end, col); DrawFullScreenEffect<FullScreenShader::FogShader>(fogmax, startH, endH, start, end, col);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
@ -487,7 +487,7 @@ void PostProcessing::renderMotionBlur(unsigned cam, FrameBuffer &in_fbo, FrameBu
out_fbo.Bind(); out_fbo.Bind();
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
FullScreenShader::MotionBlurShader::getInstance()->SetTextureUnits(createVector<GLuint>(in_fbo.getRTT()[0], irr_driver->getDepthStencilTexture())); FullScreenShader::MotionBlurShader::getInstance()->SetTextureUnits(in_fbo.getRTT()[0], irr_driver->getDepthStencilTexture());
DrawFullScreenEffect<FullScreenShader::MotionBlurShader>( DrawFullScreenEffect<FullScreenShader::MotionBlurShader>(
// Todo : use a previousPVMatrix per cam, not global // Todo : use a previousPVMatrix per cam, not global
irr_driver->getPreviousPVMatrix(), irr_driver->getPreviousPVMatrix(),
@ -500,7 +500,7 @@ static void renderGodFade(GLuint tex, const SColor &col)
{ {
glUseProgram(FullScreenShader::GodFadeShader::getInstance()->Program); glUseProgram(FullScreenShader::GodFadeShader::getInstance()->Program);
glBindVertexArray(FullScreenShader::GodFadeShader::getInstance()->vao); glBindVertexArray(FullScreenShader::GodFadeShader::getInstance()->vao);
FullScreenShader::GodFadeShader::getInstance()->SetTextureUnits(createVector<GLuint>(tex)); FullScreenShader::GodFadeShader::getInstance()->SetTextureUnits(tex);
FullScreenShader::GodFadeShader::getInstance()->setUniforms(col); FullScreenShader::GodFadeShader::getInstance()->setUniforms(col);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
@ -510,7 +510,7 @@ static void renderGodRay(GLuint tex, const core::vector2df &sunpos)
{ {
glUseProgram(FullScreenShader::GodRayShader::getInstance()->Program); glUseProgram(FullScreenShader::GodRayShader::getInstance()->Program);
glBindVertexArray(FullScreenShader::GodRayShader::getInstance()->vao); glBindVertexArray(FullScreenShader::GodRayShader::getInstance()->vao);
FullScreenShader::GodRayShader::getInstance()->SetTextureUnits(createVector<GLuint>(tex)); FullScreenShader::GodRayShader::getInstance()->SetTextureUnits(tex);
FullScreenShader::GodRayShader::getInstance()->setUniforms(sunpos); FullScreenShader::GodRayShader::getInstance()->setUniforms(sunpos);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
@ -519,14 +519,14 @@ static void renderGodRay(GLuint tex, const core::vector2df &sunpos)
static void toneMap(FrameBuffer &fbo, GLuint rtt) static void toneMap(FrameBuffer &fbo, GLuint rtt)
{ {
fbo.Bind(); fbo.Bind();
FullScreenShader::ToneMapShader::getInstance()->SetTextureUnits(createVector<GLuint>(rtt)); FullScreenShader::ToneMapShader::getInstance()->SetTextureUnits(rtt);
DrawFullScreenEffect<FullScreenShader::ToneMapShader>(); DrawFullScreenEffect<FullScreenShader::ToneMapShader>();
} }
static void renderDoF(FrameBuffer &fbo, GLuint rtt) static void renderDoF(FrameBuffer &fbo, GLuint rtt)
{ {
fbo.Bind(); fbo.Bind();
FullScreenShader::DepthOfFieldShader::getInstance()->SetTextureUnits(createVector<GLuint>(rtt, irr_driver->getDepthStencilTexture())); FullScreenShader::DepthOfFieldShader::getInstance()->SetTextureUnits(rtt, irr_driver->getDepthStencilTexture());
DrawFullScreenEffect<FullScreenShader::DepthOfFieldShader>(); DrawFullScreenEffect<FullScreenShader::DepthOfFieldShader>();
} }
@ -543,7 +543,7 @@ void PostProcessing::applyMLAA()
// Pass 1: color edge detection // Pass 1: color edge detection
glUseProgram(FullScreenShader::MLAAColorEdgeDetectionSHader::getInstance()->Program); glUseProgram(FullScreenShader::MLAAColorEdgeDetectionSHader::getInstance()->Program);
FullScreenShader::MLAAColorEdgeDetectionSHader::getInstance()->SetTextureUnits(createVector<GLuint>(irr_driver->getRenderTargetTexture(RTT_MLAA_COLORS))); FullScreenShader::MLAAColorEdgeDetectionSHader::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_MLAA_COLORS));
FullScreenShader::MLAAColorEdgeDetectionSHader::getInstance()->setUniforms(PIXEL_SIZE); FullScreenShader::MLAAColorEdgeDetectionSHader::getInstance()->setUniforms(PIXEL_SIZE);
glBindVertexArray(FullScreenShader::MLAAColorEdgeDetectionSHader::getInstance()->vao); glBindVertexArray(FullScreenShader::MLAAColorEdgeDetectionSHader::getInstance()->vao);
@ -557,7 +557,7 @@ void PostProcessing::applyMLAA()
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(FullScreenShader::MLAABlendWeightSHader::getInstance()->Program); glUseProgram(FullScreenShader::MLAABlendWeightSHader::getInstance()->Program);
FullScreenShader::MLAABlendWeightSHader::getInstance()->SetTextureUnits(createVector<GLuint>(irr_driver->getRenderTargetTexture(RTT_MLAA_TMP), getTextureGLuint(m_areamap))); FullScreenShader::MLAABlendWeightSHader::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_MLAA_TMP), getTextureGLuint(m_areamap));
FullScreenShader::MLAABlendWeightSHader::getInstance()->setUniforms(PIXEL_SIZE); FullScreenShader::MLAABlendWeightSHader::getInstance()->setUniforms(PIXEL_SIZE);
glBindVertexArray(FullScreenShader::MLAABlendWeightSHader::getInstance()->vao); glBindVertexArray(FullScreenShader::MLAABlendWeightSHader::getInstance()->vao);
@ -570,7 +570,7 @@ void PostProcessing::applyMLAA()
irr_driver->getFBO(FBO_MLAA_COLORS).Bind(); irr_driver->getFBO(FBO_MLAA_COLORS).Bind();
glUseProgram(FullScreenShader::MLAAGatherSHader::getInstance()->Program); glUseProgram(FullScreenShader::MLAAGatherSHader::getInstance()->Program);
FullScreenShader::MLAAGatherSHader::getInstance()->SetTextureUnits(createVector<GLuint>(irr_driver->getRenderTargetTexture(RTT_MLAA_BLEND), irr_driver->getRenderTargetTexture(RTT_MLAA_TMP))); FullScreenShader::MLAAGatherSHader::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_MLAA_BLEND), irr_driver->getRenderTargetTexture(RTT_MLAA_TMP));
FullScreenShader::MLAAGatherSHader::getInstance()->setUniforms(PIXEL_SIZE); FullScreenShader::MLAAGatherSHader::getInstance()->setUniforms(PIXEL_SIZE);
glBindVertexArray(FullScreenShader::MLAAGatherSHader::getInstance()->vao); glBindVertexArray(FullScreenShader::MLAAGatherSHader::getInstance()->vao);
@ -704,8 +704,8 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode, boo
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
glBlendEquation(GL_FUNC_ADD); glBlendEquation(GL_FUNC_ADD);
FullScreenShader::BloomBlendShader::getInstance()->SetTextureUnits(createVector<GLuint>( FullScreenShader::BloomBlendShader::getInstance()->SetTextureUnits(
irr_driver->getRenderTargetTexture(RTT_BLOOM_128), irr_driver->getRenderTargetTexture(RTT_BLOOM_256), irr_driver->getRenderTargetTexture(RTT_BLOOM_512) )); irr_driver->getRenderTargetTexture(RTT_BLOOM_128), irr_driver->getRenderTargetTexture(RTT_BLOOM_256), irr_driver->getRenderTargetTexture(RTT_BLOOM_512));
DrawFullScreenEffect<FullScreenShader::BloomBlendShader>(); DrawFullScreenEffect<FullScreenShader::BloomBlendShader>();
glDisable(GL_BLEND); glDisable(GL_BLEND);

View File

@ -63,140 +63,202 @@ struct DefaultMaterial
{ {
typedef MeshShader::InstancedObjectPass1Shader InstancedFirstPassShader; typedef MeshShader::InstancedObjectPass1Shader InstancedFirstPassShader;
typedef MeshShader::InstancedObjectPass2Shader InstancedSecondPassShader; typedef MeshShader::InstancedObjectPass2Shader InstancedSecondPassShader;
typedef MeshShader::InstancedShadowShader InstancedShadowPassShader;
typedef MeshShader::InstancedRSMShader InstancedRSMShader;
typedef ListInstancedMatDefault InstancedList; typedef ListInstancedMatDefault InstancedList;
typedef MeshShader::ObjectPass1Shader FirstPassShader; typedef MeshShader::ObjectPass1Shader FirstPassShader;
typedef MeshShader::ObjectPass2Shader SecondPassShader; typedef MeshShader::ObjectPass2Shader SecondPassShader;
typedef MeshShader::ShadowShader ShadowPassShader;
typedef MeshShader::RSMShader RSMShader;
typedef ListMatDefault List; typedef ListMatDefault List;
static const enum video::E_VERTEX_TYPE VertexType = video::EVT_STANDARD; static const enum video::E_VERTEX_TYPE VertexType = video::EVT_STANDARD;
static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_SOLID; static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_SOLID;
static const enum InstanceType Instance = InstanceTypeDualTex; static const enum InstanceType Instance = InstanceTypeDualTex;
static const std::vector<size_t> FirstPassTextures; static const STK::Tuple<size_t> FirstPassTextures;
static const std::vector<size_t> SecondPassTextures; static const STK::Tuple<size_t, size_t> SecondPassTextures;
static const STK::Tuple<> ShadowTextures;
static const STK::Tuple<size_t> RSMTextures;
}; };
const std::vector<size_t> DefaultMaterial::FirstPassTextures = { 1 }; const STK::Tuple<size_t> DefaultMaterial::FirstPassTextures = STK::Tuple<size_t>(1);
const std::vector<size_t> DefaultMaterial::SecondPassTextures = { 0, 1 }; const STK::Tuple<size_t, size_t> DefaultMaterial::SecondPassTextures = STK::Tuple<size_t, size_t>(0, 1);
const STK::Tuple<> DefaultMaterial::ShadowTextures;
const STK::Tuple<size_t> DefaultMaterial::RSMTextures = STK::Tuple<size_t>(0);
struct AlphaRef struct AlphaRef
{ {
typedef MeshShader::InstancedObjectRefPass1Shader InstancedFirstPassShader; typedef MeshShader::InstancedObjectRefPass1Shader InstancedFirstPassShader;
typedef MeshShader::InstancedObjectRefPass2Shader InstancedSecondPassShader; typedef MeshShader::InstancedObjectRefPass2Shader InstancedSecondPassShader;
typedef MeshShader::InstancedRefShadowShader InstancedShadowPassShader;
typedef MeshShader::InstancedRSMShader InstancedRSMShader;
typedef ListInstancedMatAlphaRef InstancedList; typedef ListInstancedMatAlphaRef InstancedList;
typedef MeshShader::ObjectRefPass1Shader FirstPassShader; typedef MeshShader::ObjectRefPass1Shader FirstPassShader;
typedef MeshShader::ObjectRefPass2Shader SecondPassShader; typedef MeshShader::ObjectRefPass2Shader SecondPassShader;
typedef MeshShader::RefShadowShader ShadowPassShader;
typedef MeshShader::RSMShader RSMShader;
typedef ListMatAlphaRef List; typedef ListMatAlphaRef List;
static const enum video::E_VERTEX_TYPE VertexType = video::EVT_STANDARD; static const enum video::E_VERTEX_TYPE VertexType = video::EVT_STANDARD;
static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_ALPHA_TEST; static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_ALPHA_TEST;
static const enum InstanceType Instance = InstanceTypeDualTex; static const enum InstanceType Instance = InstanceTypeDualTex;
static const std::vector<size_t> FirstPassTextures; static const STK::Tuple<size_t, size_t> FirstPassTextures;
static const std::vector<size_t> SecondPassTextures; static const STK::Tuple<size_t, size_t> SecondPassTextures;
static const STK::Tuple<size_t> ShadowTextures;
static const STK::Tuple<size_t> RSMTextures;
}; };
const std::vector<size_t> AlphaRef::FirstPassTextures = { 0, 1 }; const STK::Tuple<size_t, size_t> AlphaRef::FirstPassTextures = STK::Tuple<size_t, size_t>(0, 1);
const std::vector<size_t> AlphaRef::SecondPassTextures = { 0, 1 }; const STK::Tuple<size_t, size_t> AlphaRef::SecondPassTextures = STK::Tuple<size_t, size_t>(0, 1);
const STK::Tuple<size_t> AlphaRef::ShadowTextures = STK::Tuple<size_t>(0);
const STK::Tuple<size_t> AlphaRef::RSMTextures = STK::Tuple<size_t>(0);
struct SphereMap struct SphereMap
{ {
typedef MeshShader::InstancedObjectPass1Shader InstancedFirstPassShader; typedef MeshShader::InstancedObjectPass1Shader InstancedFirstPassShader;
typedef MeshShader::InstancedSphereMapShader InstancedSecondPassShader; typedef MeshShader::InstancedSphereMapShader InstancedSecondPassShader;
typedef MeshShader::InstancedShadowShader InstancedShadowPassShader;
typedef MeshShader::InstancedRSMShader InstancedRSMShader;
typedef ListInstancedMatSphereMap InstancedList; typedef ListInstancedMatSphereMap InstancedList;
typedef MeshShader::ObjectPass1Shader FirstPassShader; typedef MeshShader::ObjectPass1Shader FirstPassShader;
typedef MeshShader::SphereMapShader SecondPassShader; typedef MeshShader::SphereMapShader SecondPassShader;
typedef MeshShader::ShadowShader ShadowPassShader;
typedef MeshShader::RSMShader RSMShader;
typedef ListMatSphereMap List; typedef ListMatSphereMap List;
static const enum video::E_VERTEX_TYPE VertexType = video::EVT_STANDARD; static const enum video::E_VERTEX_TYPE VertexType = video::EVT_STANDARD;
static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_SPHERE_MAP; static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_SPHERE_MAP;
static const enum InstanceType Instance = InstanceTypeDualTex; static const enum InstanceType Instance = InstanceTypeDualTex;
static const std::vector<size_t> FirstPassTextures; static const STK::Tuple<size_t> FirstPassTextures;
static const std::vector<size_t> SecondPassTextures; static const STK::Tuple<size_t> SecondPassTextures;
static const STK::Tuple<> ShadowTextures;
static const STK::Tuple<size_t> RSMTextures;
}; };
const std::vector<size_t> SphereMap::FirstPassTextures = { 1 }; const STK::Tuple<size_t> SphereMap::FirstPassTextures = STK::Tuple<size_t>(1);
const std::vector<size_t> SphereMap::SecondPassTextures = { 0 }; const STK::Tuple<size_t> SphereMap::SecondPassTextures = STK::Tuple<size_t>(0);
const STK::Tuple<> SphereMap::ShadowTextures;
const STK::Tuple<size_t> SphereMap::RSMTextures = STK::Tuple<size_t>(0);
struct UnlitMat struct UnlitMat
{ {
typedef MeshShader::InstancedObjectRefPass1Shader InstancedFirstPassShader; typedef MeshShader::InstancedObjectRefPass1Shader InstancedFirstPassShader;
typedef MeshShader::InstancedObjectUnlitShader InstancedSecondPassShader; typedef MeshShader::InstancedObjectUnlitShader InstancedSecondPassShader;
typedef MeshShader::InstancedRefShadowShader InstancedShadowPassShader;
typedef MeshShader::InstancedRSMShader InstancedRSMShader;
typedef ListInstancedMatUnlit InstancedList; typedef ListInstancedMatUnlit InstancedList;
typedef MeshShader::ObjectRefPass1Shader FirstPassShader; typedef MeshShader::ObjectRefPass1Shader FirstPassShader;
typedef MeshShader::ObjectUnlitShader SecondPassShader; typedef MeshShader::ObjectUnlitShader SecondPassShader;
typedef MeshShader::RefShadowShader ShadowPassShader;
typedef MeshShader::RSMShader RSMShader;
typedef ListMatUnlit List; typedef ListMatUnlit List;
static const enum video::E_VERTEX_TYPE VertexType = video::EVT_STANDARD; static const enum video::E_VERTEX_TYPE VertexType = video::EVT_STANDARD;
static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_SOLID_UNLIT; static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_SOLID_UNLIT;
static const enum InstanceType Instance = InstanceTypeDualTex; static const enum InstanceType Instance = InstanceTypeDualTex;
static const std::vector<size_t> FirstPassTextures; static const STK::Tuple<size_t, size_t> FirstPassTextures;
static const std::vector<size_t> SecondPassTextures; static const STK::Tuple<size_t> SecondPassTextures;
static const STK::Tuple<size_t> ShadowTextures;
static const STK::Tuple<size_t> RSMTextures;
}; };
const std::vector<size_t> UnlitMat::FirstPassTextures = { 0, 1 }; const STK::Tuple<size_t, size_t> UnlitMat::FirstPassTextures = STK::Tuple<size_t, size_t>(0, 1);
const std::vector<size_t> UnlitMat::SecondPassTextures = { 0 }; const STK::Tuple<size_t> UnlitMat::SecondPassTextures = STK::Tuple<size_t>(0);
const STK::Tuple<size_t> UnlitMat::ShadowTextures = STK::Tuple<size_t>(0);
const STK::Tuple<size_t> UnlitMat::RSMTextures = STK::Tuple<size_t>(0);
struct GrassMat struct GrassMat
{ {
typedef MeshShader::InstancedGrassPass1Shader InstancedFirstPassShader; typedef MeshShader::InstancedGrassPass1Shader InstancedFirstPassShader;
typedef MeshShader::InstancedGrassPass2Shader InstancedSecondPassShader; typedef MeshShader::InstancedGrassPass2Shader InstancedSecondPassShader;
typedef MeshShader::InstancedGrassShadowShader InstancedShadowPassShader;
typedef MeshShader::InstancedRSMShader InstancedRSMShader;
typedef ListInstancedMatGrass InstancedList; typedef ListInstancedMatGrass InstancedList;
typedef MeshShader::GrassPass1Shader FirstPassShader; typedef MeshShader::GrassPass1Shader FirstPassShader;
typedef MeshShader::GrassPass2Shader SecondPassShader; typedef MeshShader::GrassPass2Shader SecondPassShader;
typedef MeshShader::GrassShadowShader ShadowPassShader;
typedef MeshShader::RSMShader RSMShader;
typedef ListMatGrass List; typedef ListMatGrass List;
static const enum video::E_VERTEX_TYPE VertexType = video::EVT_STANDARD; static const enum video::E_VERTEX_TYPE VertexType = video::EVT_STANDARD;
static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_VEGETATION; static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_VEGETATION;
static const enum InstanceType Instance = InstanceTypeDualTex; static const enum InstanceType Instance = InstanceTypeDualTex;
static const std::vector<size_t> FirstPassTextures; static const STK::Tuple<size_t, size_t> FirstPassTextures;
static const std::vector<size_t> SecondPassTextures; static const STK::Tuple<size_t, size_t> SecondPassTextures;
static const STK::Tuple<size_t> ShadowTextures;
static const STK::Tuple<size_t> RSMTextures;
}; };
const std::vector<size_t> GrassMat::FirstPassTextures = { 0, 1 }; const STK::Tuple<size_t, size_t> GrassMat::FirstPassTextures = STK::Tuple<size_t, size_t>(0, 1);
const std::vector<size_t> GrassMat::SecondPassTextures = { 0, 1 }; const STK::Tuple<size_t, size_t> GrassMat::SecondPassTextures = STK::Tuple<size_t, size_t>(0, 1);
const STK::Tuple<size_t> GrassMat::ShadowTextures = STK::Tuple<size_t>(0);
const STK::Tuple<size_t> GrassMat::RSMTextures = STK::Tuple<size_t>(0);
struct NormalMat struct NormalMat
{ {
typedef MeshShader::InstancedNormalMapShader InstancedFirstPassShader; typedef MeshShader::InstancedNormalMapShader InstancedFirstPassShader;
typedef MeshShader::InstancedObjectPass2Shader InstancedSecondPassShader; typedef MeshShader::InstancedObjectPass2Shader InstancedSecondPassShader;
typedef MeshShader::InstancedShadowShader InstancedShadowPassShader;
typedef MeshShader::InstancedRSMShader InstancedRSMShader;
typedef ListInstancedMatNormalMap InstancedList; typedef ListInstancedMatNormalMap InstancedList;
typedef MeshShader::NormalMapShader FirstPassShader; typedef MeshShader::NormalMapShader FirstPassShader;
typedef MeshShader::ObjectPass2Shader SecondPassShader; typedef MeshShader::ObjectPass2Shader SecondPassShader;
typedef MeshShader::ShadowShader ShadowPassShader;
typedef MeshShader::RSMShader RSMShader;
typedef ListMatNormalMap List; typedef ListMatNormalMap List;
static const enum video::E_VERTEX_TYPE VertexType = video::EVT_TANGENTS; static const enum video::E_VERTEX_TYPE VertexType = video::EVT_TANGENTS;
static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_NORMAL_MAP; static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_NORMAL_MAP;
static const enum InstanceType Instance = InstanceTypeThreeTex; static const enum InstanceType Instance = InstanceTypeThreeTex;
static const std::vector<size_t> FirstPassTextures; static const STK::Tuple<size_t, size_t> FirstPassTextures;
static const std::vector<size_t> SecondPassTextures; static const STK::Tuple<size_t, size_t> SecondPassTextures;
static const STK::Tuple<> ShadowTextures;
static const STK::Tuple<size_t> RSMTextures;
}; };
const std::vector<size_t> NormalMat::FirstPassTextures = { 2, 1 }; const STK::Tuple<size_t, size_t> NormalMat::FirstPassTextures = STK::Tuple<size_t, size_t>(2, 1);
const std::vector<size_t> NormalMat::SecondPassTextures = { 0, 1 }; const STK::Tuple<size_t, size_t> NormalMat::SecondPassTextures = STK::Tuple<size_t, size_t>(0, 1);
const STK::Tuple<> NormalMat::ShadowTextures;
const STK::Tuple<size_t> NormalMat::RSMTextures = STK::Tuple<size_t>(0);
struct DetailMat struct DetailMat
{ {
typedef MeshShader::InstancedObjectPass1Shader InstancedFirstPassShader; typedef MeshShader::InstancedObjectPass1Shader InstancedFirstPassShader;
typedef MeshShader::InstancedDetailledObjectPass2Shader InstancedSecondPassShader; typedef MeshShader::InstancedDetailledObjectPass2Shader InstancedSecondPassShader;
typedef MeshShader::InstancedShadowShader InstancedShadowPassShader;
typedef MeshShader::InstancedRSMShader InstancedRSMShader;
typedef ListInstancedMatDetails InstancedList; typedef ListInstancedMatDetails InstancedList;
typedef MeshShader::ObjectPass1Shader FirstPassShader; typedef MeshShader::ObjectPass1Shader FirstPassShader;
typedef MeshShader::DetailledObjectPass2Shader SecondPassShader; typedef MeshShader::DetailledObjectPass2Shader SecondPassShader;
typedef MeshShader::ShadowShader ShadowPassShader;
typedef MeshShader::RSMShader RSMShader;
typedef ListMatDetails List; typedef ListMatDetails List;
static const enum video::E_VERTEX_TYPE VertexType = video::EVT_2TCOORDS; static const enum video::E_VERTEX_TYPE VertexType = video::EVT_2TCOORDS;
static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_DETAIL_MAP; static const enum Material::ShaderType MaterialType = Material::SHADERTYPE_DETAIL_MAP;
static const enum InstanceType Instance = InstanceTypeThreeTex; static const enum InstanceType Instance = InstanceTypeThreeTex;
static const std::vector<size_t> FirstPassTextures; static const STK::Tuple<size_t> FirstPassTextures;
static const std::vector<size_t> SecondPassTextures; static const STK::Tuple<size_t, size_t, size_t> SecondPassTextures;
static const STK::Tuple<> ShadowTextures;
static const STK::Tuple<size_t> RSMTextures;
}; };
const std::vector<size_t> DetailMat::FirstPassTextures = { 1 }; const STK::Tuple<size_t> DetailMat::FirstPassTextures = STK::Tuple<size_t>(1);
const std::vector<size_t> DetailMat::SecondPassTextures = { 0, 2, 1 }; const STK::Tuple<size_t, size_t, size_t> DetailMat::SecondPassTextures = STK::Tuple<size_t, size_t, size_t>(0, 2, 1);
const STK::Tuple<> DetailMat::ShadowTextures;
const STK::Tuple<size_t> DetailMat::RSMTextures = STK::Tuple<size_t>(0);
struct SplattingMat struct SplattingMat
{ {
typedef MeshShader::ObjectPass1Shader FirstPassShader; typedef MeshShader::ObjectPass1Shader FirstPassShader;
typedef MeshShader::SplattingShader SecondPassShader; typedef MeshShader::SplattingShader SecondPassShader;
typedef MeshShader::ShadowShader ShadowPassShader;
typedef MeshShader::SplattingRSMShader RSMShader;
typedef ListMatSplatting List; typedef ListMatSplatting List;
static const enum video::E_VERTEX_TYPE VertexType = video::EVT_2TCOORDS; static const enum video::E_VERTEX_TYPE VertexType = video::EVT_2TCOORDS;
static const std::vector<size_t> FirstPassTextures; static const STK::Tuple<size_t> FirstPassTextures;
static const std::vector<size_t> SecondPassTextures; static const STK::Tuple<size_t, size_t, size_t, size_t, size_t> SecondPassTextures;
static const STK::Tuple<> ShadowTextures;
static const STK::Tuple<size_t, size_t, size_t, size_t, size_t> RSMTextures;
}; };
const std::vector<size_t> SplattingMat::FirstPassTextures = { 6 }; const STK::Tuple<size_t> SplattingMat::FirstPassTextures = STK::Tuple<size_t>(6);
const std::vector<size_t> SplattingMat::SecondPassTextures = { 1, 2, 3, 4, 5 }; const STK::Tuple<size_t, size_t, size_t, size_t, size_t> SplattingMat::SecondPassTextures = STK::Tuple<size_t, size_t, size_t, size_t, size_t>(1, 2, 3, 4, 5);
const STK::Tuple<> SplattingMat::ShadowTextures;
const STK::Tuple<size_t, size_t, size_t, size_t, size_t> SplattingMat::RSMTextures = STK::Tuple<size_t, size_t, size_t, size_t, size_t>(1, 2, 3, 4, 5);
namespace RenderGeometry namespace RenderGeometry
{ {
@ -280,11 +342,72 @@ struct custom_unroll_args<N, List...>
} }
}; };
template<typename T, int N>
struct TexExpander_impl
{
template<typename...TupleArgs, typename... Args>
static void ExpandTex(GLMesh &mesh, const STK::Tuple<TupleArgs...> &TexSwizzle, Args... args)
{
size_t idx = STK::tuple_get<sizeof...(TupleArgs) - N>(TexSwizzle);
TexExpander_impl<T, N - 1>::template ExpandTex(mesh, TexSwizzle, args..., getTextureGLuint(mesh.textures[idx]));
}
};
template<typename T>
struct TexExpander_impl<T, 0>
{
template<typename...TupleArgs, typename... Args>
static void ExpandTex(GLMesh &mesh, const STK::Tuple<TupleArgs...> &TexSwizzle, Args... args)
{
T::getInstance()->SetTextureUnits(args...);
}
};
template<typename T>
struct TexExpander
{
template<typename...TupleArgs, typename... Args>
static void ExpandTex(GLMesh &mesh, const STK::Tuple<TupleArgs...> &TexSwizzle, Args... args)
{
TexExpander_impl<T, sizeof...(TupleArgs)>::ExpandTex(mesh, TexSwizzle, args...);
}
};
template<typename T, int N>
struct HandleExpander_impl
{
template<typename...TupleArgs, typename... Args>
static void Expand(uint64_t *TextureHandles, const STK::Tuple<TupleArgs...> &TexSwizzle, Args... args)
{
size_t idx = STK::tuple_get<sizeof...(TupleArgs)-N>(TexSwizzle);
HandleExpander_impl<T, N - 1>::template Expand(TextureHandles, TexSwizzle, args..., TextureHandles[idx]);
}
};
template<typename T>
struct HandleExpander_impl<T, 0>
{
template<typename...TupleArgs, typename... Args>
static void Expand(uint64_t *TextureHandles, const STK::Tuple<TupleArgs...> &TexSwizzle, Args... args)
{
T::getInstance()->SetTextureHandles(args...);
}
};
template<typename T>
struct HandleExpander
{
template<typename...TupleArgs, typename... Args>
static void Expand(uint64_t *TextureHandles, const STK::Tuple<TupleArgs...> &TexSwizzle, Args... args)
{
HandleExpander_impl<T, sizeof...(TupleArgs)>::Expand(TextureHandles, TexSwizzle, args...);
}
};
template<typename T, int ...List> template<typename T, int ...List>
void renderMeshes1stPass() void renderMeshes1stPass()
{ {
const std::vector<size_t> &TexUnits = T::FirstPassTextures;
auto &meshes = T::List::getInstance()->SolidPass; auto &meshes = T::List::getInstance()->SolidPass;
glUseProgram(T::FirstPassShader::getInstance()->Program); glUseProgram(T::FirstPassShader::getInstance()->Program);
if (irr_driver->hasARB_base_instance()) if (irr_driver->hasARB_base_instance())
@ -296,13 +419,6 @@ void renderMeshes1stPass()
GLMesh &mesh = *(STK::tuple_get<0>(meshes.at(i))); GLMesh &mesh = *(STK::tuple_get<0>(meshes.at(i)));
if (!irr_driver->hasARB_base_instance()) if (!irr_driver->hasARB_base_instance())
glBindVertexArray(mesh.vao); glBindVertexArray(mesh.vao);
for (unsigned j = 0; j < TexUnits.size(); j++)
{
if (UserConfigParams::m_azdo)
Handles.push_back(mesh.TextureHandles[TexUnits[j]]);
else
Textures.push_back(getTextureGLuint(mesh.textures[TexUnits[j]]));
}
if (mesh.VAOType != T::VertexType) if (mesh.VAOType != T::VertexType)
{ {
#ifdef DEBUG #ifdef DEBUG
@ -312,9 +428,9 @@ void renderMeshes1stPass()
} }
if (UserConfigParams::m_azdo) if (UserConfigParams::m_azdo)
T::FirstPassShader::getInstance()->SetTextureHandles(Handles); HandleExpander<typename T::FirstPassShader>::template Expand(mesh.TextureHandles, T::FirstPassTextures);
else else
T::FirstPassShader::getInstance()->SetTextureUnits(Textures); TexExpander<typename T::FirstPassShader>::template ExpandTex(mesh, T::FirstPassTextures);
custom_unroll_args<List...>::template exec(T::FirstPassShader::getInstance(), meshes.at(i)); custom_unroll_args<List...>::template exec(T::FirstPassShader::getInstance(), meshes.at(i));
} }
} }
@ -322,7 +438,6 @@ void renderMeshes1stPass()
template<typename T, typename...Args> template<typename T, typename...Args>
void renderInstancedMeshes1stPass(Args...args) void renderInstancedMeshes1stPass(Args...args)
{ {
const std::vector<size_t> &TexUnits = T::FirstPassTextures;
std::vector<GLMesh *> &meshes = T::InstancedList::getInstance()->SolidPass; std::vector<GLMesh *> &meshes = T::InstancedList::getInstance()->SolidPass;
glUseProgram(T::InstancedFirstPassShader::getInstance()->Program); glUseProgram(T::InstancedFirstPassShader::getInstance()->Program);
glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(T::VertexType, T::Instance)); glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(T::VertexType, T::Instance));
@ -335,9 +450,7 @@ void renderInstancedMeshes1stPass(Args...args)
Log::error("RenderGeometry", "Wrong instanced vertex format (hint : %s)", Log::error("RenderGeometry", "Wrong instanced vertex format (hint : %s)",
mesh->textures[0]->getName().getPath().c_str()); mesh->textures[0]->getName().getPath().c_str());
#endif #endif
for (unsigned j = 0; j < TexUnits.size(); j++) TexExpander<typename T::InstancedFirstPassShader>::template ExpandTex(*mesh, T::FirstPassTextures);
Textures.push_back(getTextureGLuint(mesh->textures[TexUnits[j]]));
T::InstancedFirstPassShader::getInstance()->SetTextureUnits(Textures);
T::InstancedFirstPassShader::getInstance()->setUniforms(args...); T::InstancedFirstPassShader::getInstance()->setUniforms(args...);
glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (const void*)((SolidPassCmd::getInstance()->Offset[T::MaterialType] + i) * sizeof(DrawElementsIndirectCommand))); glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (const void*)((SolidPassCmd::getInstance()->Offset[T::MaterialType] + i) * sizeof(DrawElementsIndirectCommand)));
@ -412,25 +525,15 @@ template<typename T, int...List>
void renderMeshes2ndPass( const std::vector<uint64_t> &Prefilled_Handle, void renderMeshes2ndPass( const std::vector<uint64_t> &Prefilled_Handle,
const std::vector<GLuint> &Prefilled_Tex) const std::vector<GLuint> &Prefilled_Tex)
{ {
const std::vector<size_t> &TexUnits = T::SecondPassTextures;
auto &meshes = T::List::getInstance()->SolidPass; auto &meshes = T::List::getInstance()->SolidPass;
glUseProgram(T::SecondPassShader::getInstance()->Program); glUseProgram(T::SecondPassShader::getInstance()->Program);
if (irr_driver->hasARB_base_instance()) if (irr_driver->hasARB_base_instance())
glBindVertexArray(VAOManager::getInstance()->getVAO(T::VertexType)); glBindVertexArray(VAOManager::getInstance()->getVAO(T::VertexType));
for (unsigned i = 0; i < meshes.size(); i++) for (unsigned i = 0; i < meshes.size(); i++)
{ {
std::vector<uint64_t> Handles(Prefilled_Handle);
std::vector<GLuint> Textures(Prefilled_Tex);
GLMesh &mesh = *(STK::tuple_get<0>(meshes.at(i))); GLMesh &mesh = *(STK::tuple_get<0>(meshes.at(i)));
if (!irr_driver->hasARB_base_instance()) if (!irr_driver->hasARB_base_instance())
glBindVertexArray(mesh.vao); glBindVertexArray(mesh.vao);
for (unsigned j = 0; j < TexUnits.size(); j++)
{
if (UserConfigParams::m_azdo)
Handles.push_back(mesh.TextureHandles[TexUnits[j]]);
else
Textures.push_back(getTextureGLuint(mesh.textures[TexUnits[j]]));
}
if (mesh.VAOType != T::VertexType) if (mesh.VAOType != T::VertexType)
{ {
@ -441,9 +544,9 @@ void renderMeshes2ndPass( const std::vector<uint64_t> &Prefilled_Handle,
} }
if (UserConfigParams::m_azdo) if (UserConfigParams::m_azdo)
T::SecondPassShader::getInstance()->SetTextureHandles(Handles); HandleExpander<typename T::SecondPassShader>::template Expand(mesh.TextureHandles, T::SecondPassTextures, Prefilled_Handle[0], Prefilled_Handle[1], Prefilled_Handle[2]);
else else
T::SecondPassShader::getInstance()->SetTextureUnits(Textures); TexExpander<typename T::SecondPassShader>::template ExpandTex(mesh, T::SecondPassTextures, Prefilled_Tex[0], Prefilled_Tex[1], Prefilled_Tex[2]);
custom_unroll_args<List...>::template exec(T::SecondPassShader::getInstance(), meshes.at(i)); custom_unroll_args<List...>::template exec(T::SecondPassShader::getInstance(), meshes.at(i));
} }
} }
@ -452,29 +555,27 @@ template<typename T, typename...Args>
void renderInstancedMeshes2ndPass(const std::vector<GLuint> &Prefilled_tex, Args...args) void renderInstancedMeshes2ndPass(const std::vector<GLuint> &Prefilled_tex, Args...args)
{ {
std::vector<GLMesh *> &meshes = T::InstancedList::getInstance()->SolidPass; std::vector<GLMesh *> &meshes = T::InstancedList::getInstance()->SolidPass;
const std::vector<size_t> &TexUnits = T::SecondPassTextures;
glUseProgram(T::InstancedSecondPassShader::getInstance()->Program); glUseProgram(T::InstancedSecondPassShader::getInstance()->Program);
glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(T::VertexType, T::Instance)); glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(T::VertexType, T::Instance));
for (unsigned i = 0; i < meshes.size(); i++) for (unsigned i = 0; i < meshes.size(); i++)
{ {
GLMesh *mesh = meshes[i]; GLMesh *mesh = meshes[i];
std::vector<GLuint> Textures(Prefilled_tex); TexExpander<typename T::InstancedSecondPassShader>::template ExpandTex(*mesh, T::SecondPassTextures, Prefilled_tex[0], Prefilled_tex[1], Prefilled_tex[2]);
for (unsigned j = 0; j < TexUnits.size(); j++)
Textures.push_back(getTextureGLuint(mesh->textures[TexUnits[j]]));
T::InstancedSecondPassShader::getInstance()->SetTextureUnits(Textures);
T::InstancedSecondPassShader::getInstance()->setUniforms(args...); T::InstancedSecondPassShader::getInstance()->setUniforms(args...);
glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (const void*)((SolidPassCmd::getInstance()->Offset[T::MaterialType] + i) * sizeof(DrawElementsIndirectCommand))); glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (const void*)((SolidPassCmd::getInstance()->Offset[T::MaterialType] + i) * sizeof(DrawElementsIndirectCommand)));
} }
} }
template<typename T, typename...Args> template<typename T, typename...Args>
void multidraw2ndPass(const std::vector<uint64_t> &Handles, Args... args) void multidraw2ndPass(const std::vector<uint64_t> &Handles, Args... args)
{ {
glUseProgram(T::InstancedSecondPassShader::getInstance()->Program); glUseProgram(T::InstancedSecondPassShader::getInstance()->Program);
glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(T::VertexType, T::Instance)); glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(T::VertexType, T::Instance));
uint64_t nulltex[10] = {};
if (SolidPassCmd::getInstance()->Size[T::MaterialType]) if (SolidPassCmd::getInstance()->Size[T::MaterialType])
{ {
T::InstancedSecondPassShader::getInstance()->SetTextureHandles(Handles); HandleExpander<typename T::InstancedSecondPassShader>::template Expand(nulltex, T::SecondPassTextures, Handles[0], Handles[1], Handles[2]);
T::InstancedSecondPassShader::getInstance()->setUniforms(args...); T::InstancedSecondPassShader::getInstance()->setUniforms(args...);
glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT,
(const void*)(SolidPassCmd::getInstance()->Offset[T::MaterialType] * sizeof(DrawElementsIndirectCommand)), (const void*)(SolidPassCmd::getInstance()->Offset[T::MaterialType] * sizeof(DrawElementsIndirectCommand)),
@ -535,11 +636,25 @@ void IrrDriver::renderSolidSecondPass()
multidraw2ndPass<AlphaRef>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0)); multidraw2ndPass<AlphaRef>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0));
multidraw2ndPass<SphereMap>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0)); multidraw2ndPass<SphereMap>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0));
multidraw2ndPass<UnlitMat>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0)); multidraw2ndPass<UnlitMat>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0));
SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT);
multidraw2ndPass<GrassMat>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, DepthHandle, 0, 0), windDir, cb->getPosition());
multidraw2ndPass<NormalMat>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0)); multidraw2ndPass<NormalMat>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0));
multidraw2ndPass<DetailMat>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0, 0)); multidraw2ndPass<DetailMat>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0, 0));
// template does not work with template due to extra depth texture
{
SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT);
glUseProgram(GrassMat::InstancedSecondPassShader::getInstance()->Program);
glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(GrassMat::VertexType, GrassMat::Instance));
uint64_t nulltex[10] = {};
if (SolidPassCmd::getInstance()->Size[GrassMat::MaterialType])
{
HandleExpander<GrassMat::InstancedSecondPassShader>::Expand(nulltex, GrassMat::SecondPassTextures, DiffuseHandle, SpecularHandle, SSAOHandle, DepthHandle);
GrassMat::InstancedSecondPassShader::getInstance()->setUniforms(windDir, cb->getPosition());
glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT,
(const void*)(SolidPassCmd::getInstance()->Offset[GrassMat::MaterialType] * sizeof(DrawElementsIndirectCommand)),
(int)SolidPassCmd::getInstance()->Size[GrassMat::MaterialType],
(int)sizeof(DrawElementsIndirectCommand));
}
}
} }
else if (irr_driver->hasARB_draw_indirect()) else if (irr_driver->hasARB_draw_indirect())
{ {
@ -547,12 +662,23 @@ void IrrDriver::renderSolidSecondPass()
renderInstancedMeshes2ndPass<AlphaRef>(DiffSpecSSAOTex); renderInstancedMeshes2ndPass<AlphaRef>(DiffSpecSSAOTex);
renderInstancedMeshes2ndPass<UnlitMat>(DiffSpecSSAOTex); renderInstancedMeshes2ndPass<UnlitMat>(DiffSpecSSAOTex);
renderInstancedMeshes2ndPass<SphereMap>(DiffSpecSSAOTex); renderInstancedMeshes2ndPass<SphereMap>(DiffSpecSSAOTex);
SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT);
DiffSpecSSAOTex.push_back(irr_driver->getDepthStencilTexture());
renderInstancedMeshes2ndPass<GrassMat>(DiffSpecSSAOTex, windDir, cb->getPosition());
DiffSpecSSAOTex.pop_back();
renderInstancedMeshes2ndPass<DetailMat>(DiffSpecSSAOTex); renderInstancedMeshes2ndPass<DetailMat>(DiffSpecSSAOTex);
renderInstancedMeshes2ndPass<NormalMat>(DiffSpecSSAOTex); renderInstancedMeshes2ndPass<NormalMat>(DiffSpecSSAOTex);
// template does not work with template due to extra depth texture
{
SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT);
std::vector<GLMesh *> &meshes = GrassMat::InstancedList::getInstance()->SolidPass;
glUseProgram(GrassMat::InstancedSecondPassShader::getInstance()->Program);
glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(GrassMat::VertexType, GrassMat::Instance));
for (unsigned i = 0; i < meshes.size(); i++)
{
GLMesh *mesh = meshes[i];
TexExpander<GrassMat::InstancedSecondPassShader>::ExpandTex(*mesh, GrassMat::SecondPassTextures, DiffSpecSSAOTex[0], DiffSpecSSAOTex[1], DiffSpecSSAOTex[2], irr_driver->getDepthStencilTexture());
GrassMat::InstancedSecondPassShader::getInstance()->setUniforms(windDir, cb->getPosition());
glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (const void*)((SolidPassCmd::getInstance()->Offset[GrassMat::MaterialType] + i) * sizeof(DrawElementsIndirectCommand)));
}
}
} }
} }
} }
@ -598,7 +724,6 @@ void renderTransparenPass(const std::vector<TexUnit> &TexUnits, std::vector<STK:
for (unsigned i = 0; i < meshes->size(); i++) for (unsigned i = 0; i < meshes->size(); i++)
{ {
std::vector<uint64_t> Handles; std::vector<uint64_t> Handles;
std::vector<GLuint> Textures;
GLMesh &mesh = *(STK::tuple_get<0>(meshes->at(i))); GLMesh &mesh = *(STK::tuple_get<0>(meshes->at(i)));
if (!irr_driver->hasARB_base_instance()) if (!irr_driver->hasARB_base_instance())
glBindVertexArray(mesh.vao); glBindVertexArray(mesh.vao);
@ -615,8 +740,6 @@ void renderTransparenPass(const std::vector<TexUnit> &TexUnits, std::vector<STK:
glMakeTextureHandleResidentARB(mesh.TextureHandles[TexUnits[j].m_id]); glMakeTextureHandleResidentARB(mesh.TextureHandles[TexUnits[j].m_id]);
Handles.push_back(mesh.TextureHandles[TexUnits[j].m_id]); Handles.push_back(mesh.TextureHandles[TexUnits[j].m_id]);
} }
else
Textures.push_back(getTextureGLuint(mesh.textures[TexUnits[j].m_id]));
} }
if (mesh.VAOType != VertexType) if (mesh.VAOType != VertexType)
@ -628,9 +751,9 @@ void renderTransparenPass(const std::vector<TexUnit> &TexUnits, std::vector<STK:
} }
if (UserConfigParams::m_azdo) if (UserConfigParams::m_azdo)
Shader::getInstance()->SetTextureHandles(Handles); Shader::getInstance()->SetTextureHandles(Handles[0]);
else else
Shader::getInstance()->SetTextureUnits(Textures); Shader::getInstance()->SetTextureUnits(getTextureGLuint(mesh.textures[0]));
custom_unroll_args<List...>::template exec(Shader::getInstance(), meshes->at(i)); custom_unroll_args<List...>::template exec(Shader::getInstance(), meshes->at(i));
} }
} }
@ -741,10 +864,10 @@ void IrrDriver::renderTransparent()
size_t count = mesh.IndexCount; size_t count = mesh.IndexCount;
// Render the effect // Render the effect
MeshShader::DisplaceShader::getInstance()->SetTextureUnits( MeshShader::DisplaceShader::getInstance()->SetTextureUnits(
createVector<GLuint>(getTextureGLuint(displaceTex), getTextureGLuint(displaceTex),
irr_driver->getRenderTargetTexture(RTT_COLOR), irr_driver->getRenderTargetTexture(RTT_COLOR),
irr_driver->getRenderTargetTexture(RTT_TMP1), irr_driver->getRenderTargetTexture(RTT_TMP1),
getTextureGLuint(mesh.textures[0]))); getTextureGLuint(mesh.textures[0]));
glUseProgram(MeshShader::DisplaceShader::getInstance()->Program); glUseProgram(MeshShader::DisplaceShader::getInstance()->Program);
MeshShader::DisplaceShader::getInstance()->setUniforms(AbsoluteTransformation, MeshShader::DisplaceShader::getInstance()->setUniforms(AbsoluteTransformation,
core::vector2df(cb->getDirX(), cb->getDirY()), core::vector2df(cb->getDirX(), cb->getDirY()),
@ -795,67 +918,55 @@ struct shadow_custom_unroll_args<N, List...>
} }
}; };
template<typename T, enum video::E_VERTEX_TYPE VertexType, int...List, typename... Args> template<typename T, int...List>
void renderShadow(const std::vector<GLuint> TextureUnits, unsigned cascade, const std::vector<STK::Tuple<Args...> > &t) void renderShadow(unsigned cascade)
{ {
glUseProgram(T::getInstance()->Program); auto &t = T::List::getInstance()->Shadows[cascade];
glUseProgram(T::ShadowPassShader::getInstance()->Program);
if (irr_driver->hasARB_base_instance()) if (irr_driver->hasARB_base_instance())
glBindVertexArray(VAOManager::getInstance()->getVAO(VertexType)); glBindVertexArray(VAOManager::getInstance()->getVAO(T::VertexType));
for (unsigned i = 0; i < t.size(); i++) for (unsigned i = 0; i < t.size(); i++)
{ {
std::vector<uint64_t> Handles;
std::vector<GLuint> Textures;
GLMesh *mesh = STK::tuple_get<0>(t.at(i)); GLMesh *mesh = STK::tuple_get<0>(t.at(i));
if (!irr_driver->hasARB_base_instance()) if (!irr_driver->hasARB_base_instance())
glBindVertexArray(mesh->vao); glBindVertexArray(mesh->vao);
for (unsigned j = 0; j < TextureUnits.size(); j++)
{
compressTexture(mesh->textures[TextureUnits[j]], true);
if (UserConfigParams::m_azdo)
Handles.push_back(mesh->TextureHandles[TextureUnits[j]]);
else
Textures.push_back(getTextureGLuint(mesh->textures[TextureUnits[j]]));
}
if (UserConfigParams::m_azdo) if (UserConfigParams::m_azdo)
T::getInstance()->SetTextureHandles(Handles); HandleExpander<typename T::ShadowPassShader>::template Expand(mesh->TextureHandles, T::ShadowTextures);
else else
T::getInstance()->SetTextureUnits(Textures); TexExpander<typename T::ShadowPassShader>::template ExpandTex(*mesh, T::ShadowTextures);
shadow_custom_unroll_args<List...>::template exec<T>(T::getInstance(), cascade, t.at(i)); shadow_custom_unroll_args<List...>::template exec<typename T::ShadowPassShader>(T::ShadowPassShader::getInstance(), cascade, t.at(i));
} }
} }
template<typename Shader, Material::ShaderType Mat, video::E_VERTEX_TYPE VT, typename...Args> template<typename T, typename...Args>
void renderInstancedShadow(const std::vector<GLuint> TextureUnits, unsigned cascade, const std::vector<GLMesh *> &t, Args ...args) void renderInstancedShadow(unsigned cascade, Args ...args)
{ {
glUseProgram(Shader::getInstance()->Program); glUseProgram(T::InstancedShadowPassShader::getInstance()->Program);
glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(VT, InstanceTypeShadow)); glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(T::VertexType, InstanceTypeShadow));
std::vector<GLMesh *> &t = T::InstancedList::getInstance()->Shadows[cascade];
for (unsigned i = 0; i < t.size(); i++) for (unsigned i = 0; i < t.size(); i++)
{ {
std::vector<uint64_t> Handles;
std::vector<GLuint> Textures;
GLMesh *mesh = t[i]; GLMesh *mesh = t[i];
for (unsigned j = 0; j < TextureUnits.size(); j++) TexExpander<typename T::InstancedShadowPassShader>::template ExpandTex(*mesh, T::ShadowTextures);
Textures.push_back(getTextureGLuint(mesh->textures[TextureUnits[j]])); T::InstancedShadowPassShader::getInstance()->setUniforms(cascade, args...);
size_t tmp = ShadowPassCmd::getInstance()->Offset[cascade][T::MaterialType] + i;
Shader::getInstance()->SetTextureUnits(Textures);
Shader::getInstance()->setUniforms(cascade, args...);
size_t tmp = ShadowPassCmd::getInstance()->Offset[cascade][Mat] + i;
glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (const void*)((tmp) * sizeof(DrawElementsIndirectCommand))); glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (const void*)((tmp) * sizeof(DrawElementsIndirectCommand)));
} }
} }
template<typename Shader, Material::ShaderType Mat, video::E_VERTEX_TYPE VT, typename...Args> template<typename T, typename...Args>
static void multidrawShadow(unsigned i, Args ...args) static void multidrawShadow(unsigned i, Args ...args)
{ {
glUseProgram(Shader::getInstance()->Program); glUseProgram(T::InstancedShadowPassShader::getInstance()->Program);
glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(VT, InstanceTypeShadow)); glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(T::VertexType, InstanceTypeShadow));
if (ShadowPassCmd::getInstance()->Size[i][Mat]) if (ShadowPassCmd::getInstance()->Size[i][T::MaterialType])
{ {
Shader::getInstance()->setUniforms(i, args...); T::InstancedShadowPassShader::getInstance()->setUniforms(i, args...);
glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT,
(const void*)(ShadowPassCmd::getInstance()->Offset[i][Mat] * sizeof(DrawElementsIndirectCommand)), (const void*)(ShadowPassCmd::getInstance()->Offset[i][T::MaterialType] * sizeof(DrawElementsIndirectCommand)),
(int)ShadowPassCmd::getInstance()->Size[i][Mat], sizeof(DrawElementsIndirectCommand)); (int)ShadowPassCmd::getInstance()->Size[i][T::MaterialType], sizeof(DrawElementsIndirectCommand));
} }
} }
@ -875,37 +986,36 @@ void IrrDriver::renderShadows()
for (unsigned cascade = 0; cascade < 4; cascade++) for (unsigned cascade = 0; cascade < 4; cascade++)
{ {
ScopedGPUTimer Timer(getGPUTimer(Q_SHADOWS_CASCADE0 + cascade)); ScopedGPUTimer Timer(getGPUTimer(Q_SHADOWS_CASCADE0 + cascade));
std::vector<GLuint> noTexUnits;
renderShadow<MeshShader::ShadowShader, video::EVT_STANDARD, 1>(noTexUnits, cascade, ListMatDefault::getInstance()->Shadows[cascade]); renderShadow<DefaultMaterial, 1>(cascade);
renderShadow<MeshShader::ShadowShader, video::EVT_STANDARD, 1>(noTexUnits, cascade, ListMatSphereMap::getInstance()->Shadows[cascade]); renderShadow<SphereMap, 1>(cascade);
renderShadow<MeshShader::ShadowShader, video::EVT_2TCOORDS, 1>(noTexUnits, cascade, ListMatDetails::getInstance()->Shadows[cascade]); renderShadow<DetailMat, 1>(cascade);
renderShadow<MeshShader::ShadowShader, video::EVT_2TCOORDS, 1>(noTexUnits, cascade, ListMatSplatting::getInstance()->Shadows[cascade]); renderShadow<SplattingMat, 1>(cascade);
renderShadow<MeshShader::ShadowShader, video::EVT_TANGENTS, 1>(noTexUnits, cascade, ListMatNormalMap::getInstance()->Shadows[cascade]); renderShadow<NormalMat, 1>(cascade);
renderShadow<MeshShader::RefShadowShader, video::EVT_STANDARD, 1>(std::vector<GLuint>{ 0 }, cascade, ListMatAlphaRef::getInstance()->Shadows[cascade]); renderShadow<AlphaRef, 1>(cascade);
renderShadow<MeshShader::RefShadowShader, video::EVT_STANDARD, 1>(std::vector<GLuint>{ 0 }, cascade, ListMatUnlit::getInstance()->Shadows[cascade]); renderShadow<UnlitMat, 1>(cascade);
renderShadow<MeshShader::GrassShadowShader, video::EVT_STANDARD, 3, 1>(std::vector<GLuint>{ 0 }, cascade, ListMatGrass::getInstance()->Shadows[cascade]); renderShadow<GrassMat, 3, 1>(cascade);
if (irr_driver->hasARB_draw_indirect()) if (irr_driver->hasARB_draw_indirect())
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, ShadowPassCmd::getInstance()->drawindirectcmd); glBindBuffer(GL_DRAW_INDIRECT_BUFFER, ShadowPassCmd::getInstance()->drawindirectcmd);
if (UserConfigParams::m_azdo) if (UserConfigParams::m_azdo)
{ {
multidrawShadow<MeshShader::InstancedShadowShader, Material::SHADERTYPE_SOLID, video::EVT_STANDARD>(cascade); multidrawShadow<DefaultMaterial>(cascade);
multidrawShadow<MeshShader::InstancedShadowShader, Material::SHADERTYPE_DETAIL_MAP, video::EVT_2TCOORDS>(cascade); multidrawShadow<DetailMat>(cascade);
multidrawShadow<MeshShader::InstancedShadowShader, Material::SHADERTYPE_NORMAL_MAP, video::EVT_TANGENTS>(cascade); multidrawShadow<NormalMat>(cascade);
multidrawShadow<MeshShader::InstancedRefShadowShader, Material::SHADERTYPE_ALPHA_TEST, video::EVT_STANDARD>(cascade); multidrawShadow<AlphaRef>(cascade);
multidrawShadow<MeshShader::InstancedRefShadowShader, Material::SHADERTYPE_SOLID_UNLIT, video::EVT_STANDARD>(cascade); multidrawShadow<UnlitMat>(cascade);
multidrawShadow<MeshShader::InstancedGrassShadowShader, Material::SHADERTYPE_VEGETATION, video::EVT_STANDARD>(cascade, windDir); multidrawShadow<GrassMat>(cascade, windDir);
} }
else if (irr_driver->hasARB_draw_indirect()) else if (irr_driver->hasARB_draw_indirect())
{ {
renderInstancedShadow<MeshShader::InstancedShadowShader, Material::SHADERTYPE_SOLID, video::EVT_STANDARD>(noTexUnits, cascade, ListInstancedMatDefault::getInstance()->Shadows[cascade]); renderInstancedShadow<DefaultMaterial>(cascade);
renderInstancedShadow<MeshShader::InstancedShadowShader, Material::SHADERTYPE_DETAIL_MAP, video::EVT_2TCOORDS>(noTexUnits, cascade, ListInstancedMatDetails::getInstance()->Shadows[cascade]); renderInstancedShadow<DetailMat>(cascade);
renderInstancedShadow<MeshShader::InstancedRefShadowShader, Material::SHADERTYPE_ALPHA_TEST, video::EVT_STANDARD>(std::vector < GLuint > { 0 }, cascade, ListInstancedMatAlphaRef::getInstance()->Shadows[cascade]); renderInstancedShadow<AlphaRef>(cascade);
renderInstancedShadow<MeshShader::InstancedRefShadowShader, Material::SHADERTYPE_SOLID_UNLIT, video::EVT_STANDARD>(std::vector < GLuint > { 0 }, cascade, ListInstancedMatUnlit::getInstance()->Shadows[cascade]); renderInstancedShadow<UnlitMat>(cascade);
renderInstancedShadow<MeshShader::InstancedGrassShadowShader, Material::SHADERTYPE_VEGETATION, video::EVT_STANDARD>(std::vector < GLuint > { 0 }, cascade, ListInstancedMatGrass::getInstance()->Shadows[cascade], windDir); renderInstancedShadow<GrassMat>(cascade, windDir);
renderInstancedShadow<MeshShader::InstancedShadowShader, Material::SHADERTYPE_NORMAL_MAP, video::EVT_TANGENTS>(noTexUnits, cascade, ListInstancedMatNormalMap::getInstance()->Shadows[cascade]); renderInstancedShadow<NormalMat>(cascade);
} }
} }
@ -937,56 +1047,55 @@ struct rsm_custom_unroll_args<N, List...>
} }
}; };
template<typename T, enum video::E_VERTEX_TYPE VertexType, int... Selector, typename... Args> template<typename T, int... Selector>
void drawRSM(const core::matrix4 & rsm_matrix, const std::vector<GLuint> &TextureUnits, const std::vector<STK::Tuple<Args...> > &t) void drawRSM(const core::matrix4 & rsm_matrix)
{ {
glUseProgram(T::getInstance()->Program); glUseProgram(T::RSMShader::getInstance()->Program);
if (irr_driver->hasARB_base_instance()) if (irr_driver->hasARB_base_instance())
glBindVertexArray(VAOManager::getInstance()->getVAO(VertexType)); glBindVertexArray(VAOManager::getInstance()->getVAO(T::VertexType));
auto t = T::List::getInstance()->RSM;
for (unsigned i = 0; i < t.size(); i++) for (unsigned i = 0; i < t.size(); i++)
{ {
std::vector<GLuint> Textures; std::vector<GLuint> Textures;
GLMesh *mesh = STK::tuple_get<0>(t.at(i)); GLMesh *mesh = STK::tuple_get<0>(t.at(i));
if (!irr_driver->hasARB_base_instance()) if (!irr_driver->hasARB_base_instance())
glBindVertexArray(mesh->vao); glBindVertexArray(mesh->vao);
for (unsigned j = 0; j < TextureUnits.size(); j++) if (UserConfigParams::m_azdo)
Textures.push_back(getTextureGLuint(mesh->textures[TextureUnits[j]])); HandleExpander<typename T::RSMShader>::template Expand(mesh->TextureHandles, T::RSMTextures);
T::getInstance()->SetTextureUnits(Textures); else
rsm_custom_unroll_args<Selector...>::template exec<T>(rsm_matrix, t.at(i)); TexExpander<typename T::RSMShader>::template ExpandTex(*mesh, T::RSMTextures);
rsm_custom_unroll_args<Selector...>::template exec<typename T::RSMShader>(rsm_matrix, t.at(i));
} }
} }
template<typename Shader, Material::ShaderType Mat, video::E_VERTEX_TYPE VT, typename...Args> template<typename T, typename...Args>
void renderRSMShadow(const std::vector<GLuint> TextureUnits, const std::vector<GLMesh *> &t, Args ...args) void renderRSMShadow(Args ...args)
{ {
glUseProgram(Shader::getInstance()->Program); glUseProgram(T::InstancedRSMShader::getInstance()->Program);
glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(VT, InstanceTypeRSM)); glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(T::VertexType, InstanceTypeRSM));
auto t = T::InstancedList::getInstance()->RSM;
for (unsigned i = 0; i < t.size(); i++) for (unsigned i = 0; i < t.size(); i++)
{ {
std::vector<uint64_t> Handles;
std::vector<GLuint> Textures; std::vector<GLuint> Textures;
GLMesh *mesh = t[i]; GLMesh *mesh = t[i];
for (unsigned j = 0; j < TextureUnits.size(); j++) TexExpander<typename T::InstancedRSMShader>::template ExpandTex(*mesh, T::RSMTextures);
Textures.push_back(getTextureGLuint(mesh->textures[TextureUnits[j]])); T::InstancedRSMShader::getInstance()->setUniforms(args...);
glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (const void*)((RSMPassCmd::getInstance()->Offset[T::MaterialType] + i)* sizeof(DrawElementsIndirectCommand)));
Shader::getInstance()->SetTextureUnits(Textures);
Shader::getInstance()->setUniforms(args...);
glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (const void*)((RSMPassCmd::getInstance()->Offset[Mat] + i)* sizeof(DrawElementsIndirectCommand)));
} }
} }
template<typename Shader, Material::ShaderType Mat, enum video::E_VERTEX_TYPE VertexType, typename... Args> template<typename T, typename... Args>
void multidrawRSM(Args...args) void multidrawRSM(Args...args)
{ {
glUseProgram(Shader::getInstance()->Program); glUseProgram(T::InstancedRSMShader::getInstance()->Program);
glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(VertexType, InstanceTypeRSM)); glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(T::VertexType, InstanceTypeRSM));
if (RSMPassCmd::getInstance()->Size[Mat]) if (RSMPassCmd::getInstance()->Size[T::MaterialType])
{ {
Shader::getInstance()->setUniforms(args...); T::InstancedRSMShader::getInstance()->setUniforms(args...);
glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT,
(const void*)(RSMPassCmd::getInstance()->Offset[Mat] * sizeof(DrawElementsIndirectCommand)), (const void*)(RSMPassCmd::getInstance()->Offset[T::MaterialType] * sizeof(DrawElementsIndirectCommand)),
(int)RSMPassCmd::getInstance()->Size[Mat], sizeof(DrawElementsIndirectCommand)); (int)RSMPassCmd::getInstance()->Size[T::MaterialType], sizeof(DrawElementsIndirectCommand));
} }
} }
@ -996,30 +1105,30 @@ void IrrDriver::renderRSM()
m_rtts->getRSM().Bind(); m_rtts->getRSM().Bind();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
drawRSM<MeshShader::RSMShader, video::EVT_STANDARD, 3, 1>(rsm_matrix, std::vector<GLuint>{ 0 }, ListMatDefault::getInstance()->RSM); drawRSM<DefaultMaterial, 3, 1>(rsm_matrix);
drawRSM<MeshShader::RSMShader, video::EVT_STANDARD, 3, 1>(rsm_matrix, std::vector<GLuint>{ 0 }, ListMatAlphaRef::getInstance()->RSM); drawRSM<AlphaRef, 3, 1>(rsm_matrix);
drawRSM<MeshShader::RSMShader, video::EVT_TANGENTS, 3, 1>(rsm_matrix, std::vector<GLuint>{ 0 }, ListMatNormalMap::getInstance()->RSM); drawRSM<NormalMat, 3, 1>(rsm_matrix);
drawRSM<MeshShader::RSMShader, video::EVT_STANDARD, 3, 1>(rsm_matrix, std::vector<GLuint>{ 0 }, ListMatUnlit::getInstance()->RSM); drawRSM<UnlitMat, 3, 1>(rsm_matrix);
drawRSM<MeshShader::RSMShader, video::EVT_2TCOORDS, 3, 1>(rsm_matrix, std::vector<GLuint>{ 0 }, ListMatDetails::getInstance()->RSM); drawRSM<DetailMat, 3, 1>(rsm_matrix);
drawRSM<MeshShader::SplattingRSMShader, video::EVT_2TCOORDS, 1>(rsm_matrix, createVector<GLuint>(1, 2, 3, 4, 5), ListMatSplatting::getInstance()->RSM); drawRSM<SplattingMat, 1>(rsm_matrix);
if (irr_driver->hasARB_draw_indirect()) if (irr_driver->hasARB_draw_indirect())
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, RSMPassCmd::getInstance()->drawindirectcmd); glBindBuffer(GL_DRAW_INDIRECT_BUFFER, RSMPassCmd::getInstance()->drawindirectcmd);
if (UserConfigParams::m_azdo) if (UserConfigParams::m_azdo)
{ {
multidrawRSM<MeshShader::InstancedRSMShader, Material::SHADERTYPE_SOLID, video::EVT_STANDARD>(rsm_matrix); multidrawRSM<DefaultMaterial>(rsm_matrix);
multidrawRSM<MeshShader::InstancedRSMShader, Material::SHADERTYPE_NORMAL_MAP, video::EVT_TANGENTS>(rsm_matrix); multidrawRSM<NormalMat>(rsm_matrix);
multidrawRSM<MeshShader::InstancedRSMShader, Material::SHADERTYPE_ALPHA_TEST, video::EVT_STANDARD>(rsm_matrix); multidrawRSM<AlphaRef>(rsm_matrix);
multidrawRSM<MeshShader::InstancedRSMShader, Material::SHADERTYPE_SOLID_UNLIT, video::EVT_STANDARD>(rsm_matrix); multidrawRSM<UnlitMat>(rsm_matrix);
multidrawRSM<MeshShader::InstancedRSMShader, Material::SHADERTYPE_DETAIL_MAP, video::EVT_2TCOORDS>(rsm_matrix); multidrawRSM<DetailMat>(rsm_matrix);
} }
else if (irr_driver->hasARB_draw_indirect()) else if (irr_driver->hasARB_draw_indirect())
{ {
renderRSMShadow<MeshShader::InstancedRSMShader, Material::SHADERTYPE_SOLID, video::EVT_STANDARD>(std::vector < GLuint > { 0 }, ListInstancedMatDefault::getInstance()->RSM, rsm_matrix); renderRSMShadow<DefaultMaterial>(rsm_matrix);
renderRSMShadow<MeshShader::InstancedRSMShader, Material::SHADERTYPE_ALPHA_TEST, video::EVT_STANDARD>(std::vector < GLuint > { 0 }, ListInstancedMatAlphaRef::getInstance()->RSM, rsm_matrix); renderRSMShadow<AlphaRef>(rsm_matrix);
renderRSMShadow<MeshShader::InstancedRSMShader, Material::SHADERTYPE_SOLID_UNLIT, video::EVT_STANDARD>(std::vector < GLuint > { 0 }, ListInstancedMatUnlit::getInstance()->RSM, rsm_matrix); renderRSMShadow<UnlitMat>(rsm_matrix);
renderRSMShadow<MeshShader::InstancedRSMShader, Material::SHADERTYPE_NORMAL_MAP, video::EVT_TANGENTS>(std::vector < GLuint > { 0 }, ListInstancedMatNormalMap::getInstance()->RSM, rsm_matrix); renderRSMShadow<NormalMat>(rsm_matrix);
renderRSMShadow<MeshShader::InstancedRSMShader, Material::SHADERTYPE_DETAIL_MAP, video::EVT_2TCOORDS>(std::vector < GLuint > { 0 }, ListInstancedMatDetails::getInstance()->RSM, rsm_matrix); renderRSMShadow<DetailMat>(rsm_matrix);
} }
} }

View File

@ -29,7 +29,7 @@ static void renderPointLights(unsigned count)
glBindBuffer(GL_ARRAY_BUFFER, LightShader::PointLightShader::getInstance()->vbo); glBindBuffer(GL_ARRAY_BUFFER, LightShader::PointLightShader::getInstance()->vbo);
glBufferSubData(GL_ARRAY_BUFFER, 0, count * sizeof(LightShader::PointLightInfo), PointLightsInfo); glBufferSubData(GL_ARRAY_BUFFER, 0, count * sizeof(LightShader::PointLightInfo), PointLightsInfo);
LightShader::PointLightShader::getInstance()->SetTextureUnits(createVector<GLuint>(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture())); LightShader::PointLightShader::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture());
LightShader::PointLightShader::getInstance()->setUniforms(); LightShader::PointLightShader::getInstance()->setUniforms();
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, count); glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, count);
@ -120,7 +120,7 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
{ {
glUseProgram(FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->Program); glUseProgram(FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->Program);
FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->SetTextureUnits( FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->SetTextureUnits(
createVector<GLuint>(m_rtts->getRSM().getRTT()[0], m_rtts->getRSM().getRTT()[1], m_rtts->getRSM().getDepthTexture())); m_rtts->getRSM().getRTT()[0], m_rtts->getRSM().getRTT()[1], m_rtts->getRSM().getDepthTexture());
for (unsigned i = 0; i < 32; i++) for (unsigned i = 0; i < 32; i++)
{ {
FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->setUniforms(rsm_matrix, rh_matrix, rh_extend, i, video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue())); FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->setUniforms(rsm_matrix, rh_matrix, rh_extend, i, video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
@ -131,11 +131,9 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
{ {
glUseProgram(FullScreenShader::RadianceHintsConstructionShader::getInstance()->Program); glUseProgram(FullScreenShader::RadianceHintsConstructionShader::getInstance()->Program);
FullScreenShader::RadianceHintsConstructionShader::getInstance()->SetTextureUnits( FullScreenShader::RadianceHintsConstructionShader::getInstance()->SetTextureUnits(
createVector<GLuint>(
m_rtts->getRSM().getRTT()[0], m_rtts->getRSM().getRTT()[0],
m_rtts->getRSM().getRTT()[1], m_rtts->getRSM().getRTT()[1],
m_rtts->getRSM().getDepthTexture() m_rtts->getRSM().getDepthTexture()
)
); );
FullScreenShader::RadianceHintsConstructionShader::getInstance()->setUniforms(rsm_matrix, rh_matrix, rh_extend, video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue())); FullScreenShader::RadianceHintsConstructionShader::getInstance()->setUniforms(rsm_matrix, rh_matrix, rh_extend, video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, 32); glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, 32);

View File

@ -541,7 +541,7 @@ void IrrDriver::renderSkybox(const scene::ICameraSceneNode *camera)
glUseProgram(MeshShader::SkyboxShader::getInstance()->Program); glUseProgram(MeshShader::SkyboxShader::getInstance()->Program);
MeshShader::SkyboxShader::getInstance()->setUniforms(transform); MeshShader::SkyboxShader::getInstance()->setUniforms(transform);
MeshShader::SkyboxShader::getInstance()->SetTextureUnits(createVector<GLuint>(SkyboxCubeMap)); MeshShader::SkyboxShader::getInstance()->SetTextureUnits(SkyboxCubeMap);
glDrawElements(GL_TRIANGLES, 6 * 6, GL_UNSIGNED_INT, 0); glDrawElements(GL_TRIANGLES, 6 * 6, GL_UNSIGNED_INT, 0);
glBindVertexArray(0); glBindVertexArray(0);

View File

@ -238,7 +238,8 @@ struct CreateSamplers<>
template<> template<>
struct BindTexture<> struct BindTexture<>
{ {
static void exec(const std::vector<unsigned> &TU, const std::vector<unsigned> &TexId, unsigned N) template<int N>
static void exec(const std::vector<unsigned> &TU)
{} {}
}; };
@ -260,10 +261,11 @@ void BindTextureNearest(unsigned TU, unsigned tid);
template<SamplerType...tp> template<SamplerType...tp>
struct BindTexture<Nearest_Filtered, tp...> struct BindTexture<Nearest_Filtered, tp...>
{ {
static void exec(const std::vector<unsigned> &TU, const std::vector<unsigned> &TexId, unsigned N) template<int N, typename...Args>
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
{ {
BindTextureNearest(TU[N], TexId[N]); BindTextureNearest(TU[N], TexId);
BindTexture<tp...>::exec(TU, TexId, N + 1); BindTexture<tp...>::template exec<N + 1>(TU, args...);
} }
}; };
@ -289,16 +291,17 @@ struct CreateSamplers<Neared_Clamped_Filtered, tp...>
template<SamplerType...tp> template<SamplerType...tp>
struct BindTexture<Neared_Clamped_Filtered, tp...> struct BindTexture<Neared_Clamped_Filtered, tp...>
{ {
static void exec(const std::vector<unsigned> &TU, const std::vector<unsigned> &TexId, unsigned N) template<int N, typename...Args>
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
{ {
glActiveTexture(GL_TEXTURE0 + TU[N]); glActiveTexture(GL_TEXTURE0 + TU[N]);
glBindTexture(GL_TEXTURE_2D, TexId[N]); glBindTexture(GL_TEXTURE_2D, TexId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.);
BindTexture<tp...>::exec(TU, TexId, N + 1); BindTexture<tp...>::template exec<N + 1>(TU, args...);
} }
}; };
@ -320,10 +323,11 @@ void BindTextureBilinear(unsigned TU, unsigned tex);
template<SamplerType...tp> template<SamplerType...tp>
struct BindTexture<Bilinear_Filtered, tp...> struct BindTexture<Bilinear_Filtered, tp...>
{ {
static void exec(const std::vector<unsigned> &TU, const std::vector<unsigned> &TexId, unsigned N) template<int N, typename...Args>
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
{ {
BindTextureBilinear(TU[N], TexId[N]); BindTextureBilinear(TU[N], TexId);
BindTexture<tp...>::exec(TU, TexId, N + 1); BindTexture<tp...>::template exec<N + 1>(TU, args...);
} }
}; };
@ -345,10 +349,11 @@ void BindTextureBilinearClamped(unsigned TU, unsigned tex);
template<SamplerType...tp> template<SamplerType...tp>
struct BindTexture<Bilinear_Clamped_Filtered, tp...> struct BindTexture<Bilinear_Clamped_Filtered, tp...>
{ {
static void exec(const std::vector<unsigned> &TU, const std::vector<unsigned> &TexId, unsigned N) template<int N, typename...Args>
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
{ {
BindTextureBilinearClamped(TU[N], TexId[N]); BindTextureBilinearClamped(TU[N], TexId);
BindTexture<tp...>::exec(TU, TexId, N + 1); BindTexture<tp...>::template exec<N + 1>(TU, args...);
} }
}; };
@ -370,10 +375,11 @@ void BindTextureSemiTrilinear(unsigned TU, unsigned tex);
template<SamplerType...tp> template<SamplerType...tp>
struct BindTexture<Semi_trilinear, tp...> struct BindTexture<Semi_trilinear, tp...>
{ {
static void exec(const std::vector<unsigned> &TU, const std::vector<unsigned> &TexId, unsigned N) template<int N, typename...Args>
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
{ {
BindTextureSemiTrilinear(TU[N], TexId[N]); BindTextureSemiTrilinear(TU[N], TexId);
BindTexture<tp...>::exec(TU, TexId, N + 1); BindTexture<tp...>::template exec<N + 1>(TU, args...);
} }
}; };
@ -408,20 +414,22 @@ void BindCubemapTrilinear(unsigned TU, unsigned tex);
template<SamplerType...tp> template<SamplerType...tp>
struct BindTexture<Trilinear_cubemap, tp...> struct BindTexture<Trilinear_cubemap, tp...>
{ {
static void exec(const std::vector<unsigned> &TU, const std::vector<unsigned> &TexId, unsigned N) template<int N, typename...Args>
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
{ {
BindCubemapTrilinear(TU[N], TexId[N]); BindCubemapTrilinear(TU[N], TexId);
BindTexture<tp...>::exec(TU, TexId, N + 1); BindTexture<tp...>::template exec<N + 1>(TU, args...);
} }
}; };
template<SamplerType...tp> template<SamplerType...tp>
struct BindTexture<Trilinear_Anisotropic_Filtered, tp...> struct BindTexture<Trilinear_Anisotropic_Filtered, tp...>
{ {
static void exec(const std::vector<unsigned> &TU, const std::vector<unsigned> &TexId, unsigned N) template<int N, typename...Args>
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
{ {
BindTextureTrilinearAnisotropic(TU[N], TexId[N]); BindTextureTrilinearAnisotropic(TU[N], TexId);
BindTexture<tp...>::exec(TU, TexId, N + 1); BindTexture<tp...>::template exec<N + 1>(TU, args...);
} }
}; };
@ -441,10 +449,11 @@ void BindTextureVolume(unsigned TU, unsigned tex);
template<SamplerType...tp> template<SamplerType...tp>
struct BindTexture<Volume_Linear_Filtered, tp...> struct BindTexture<Volume_Linear_Filtered, tp...>
{ {
static void exec(const std::vector<unsigned> &TU, const std::vector<unsigned> &TexId, unsigned N) template<int N, typename...Args>
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
{ {
BindTextureVolume(TU[N], TexId[N]); BindTextureVolume(TU[N], TexId);
BindTexture<tp...>::exec(TU, TexId, N + 1); BindTexture<tp...>::template exec<N + 1>(TU, args...);
} }
}; };
@ -466,10 +475,11 @@ void BindTextureShadow(unsigned TU, unsigned tex);
template<SamplerType...tp> template<SamplerType...tp>
struct BindTexture<Shadow_Sampler, tp...> struct BindTexture<Shadow_Sampler, tp...>
{ {
static void exec(const std::vector<unsigned> &TU, const std::vector<unsigned> &TexId, unsigned N) template <int N, typename...Args>
static void exec(const std::vector<unsigned> &TU, GLuint TexId, Args... args)
{ {
BindTextureShadow(TU[N], TexId[N]); BindTextureShadow(TU[N], TexId);
BindTexture<tp...>::exec(TU, TexId, N + 1); BindTexture<tp...>::template exec<N + 1>(TU, args...);
} }
}; };
@ -507,21 +517,44 @@ protected:
glUseProgram(0); glUseProgram(0);
} }
template<int N>
void SetTextureUnits_impl()
{
static_assert(N == sizeof...(tp), "Not enough texture set");
}
template<int N, typename... TexIds>
void SetTextureUnits_impl(GLuint texid, TexIds... args)
{
setTextureSampler(TextureType[N], TextureUnits[N], texid, SamplersId[N]);
SetTextureUnits_impl<N + 1>(args...);
}
template<int N>
void SetTextureHandles_impl()
{
static_assert(N == sizeof...(tp), "Not enough handle set");
}
template<int N, typename... HandlesId>
void SetTextureHandles_impl(uint64_t handle, HandlesId... args)
{
if (handle)
glUniformHandleui64ARB(TextureLocation[N], handle);
SetTextureHandles_impl<N + 1>(args...);
}
public: public:
std::vector<GLuint> SamplersId; std::vector<GLuint> SamplersId;
void SetTextureUnits(const std::vector<GLuint> &args)
template<typename... TexIds>
void SetTextureUnits(TexIds... args)
{ {
if (args.size() != sizeof...(tp))
abort();
if (getGLSLVersion() >= 330) if (getGLSLVersion() >= 330)
{ SetTextureUnits_impl<0>(args...);
for (unsigned i = 0; i < args.size(); i++)
{
setTextureSampler(TextureType[i], TextureUnits[i], args[i], SamplersId[i]);
}
}
else else
BindTexture<tp...>::exec(TextureUnits, args, 0); BindTexture<tp...>::template exec<0>(TextureUnits, args...);
} }
~TextureRead() ~TextureRead()
@ -530,14 +563,10 @@ public:
glDeleteSamplers(1, &SamplersId[i]); glDeleteSamplers(1, &SamplersId[i]);
} }
void SetTextureHandles(const std::vector<uint64_t> &args) template<typename... HandlesId>
void SetTextureHandles(HandlesId... ids)
{ {
assert(args.size() == TextureLocation.size() && "Wrong Handle count"); SetTextureHandles_impl<0>(ids...);
for (unsigned i = 0; i < args.size(); i++)
{
if (args[i])
glUniformHandleui64ARB(TextureLocation[i], args[i]);
}
} }
}; };
#endif #endif

View File

@ -52,7 +52,7 @@ void STKBillboard::render()
compressTexture(tex, true, true); compressTexture(tex, true, true);
GLuint texid = getTextureGLuint(tex); GLuint texid = getTextureGLuint(tex);
glUseProgram(MeshShader::BillboardShader::getInstance()->Program); glUseProgram(MeshShader::BillboardShader::getInstance()->Program);
MeshShader::BillboardShader::getInstance()->SetTextureUnits(createVector<GLuint>(texid)); MeshShader::BillboardShader::getInstance()->SetTextureUnits(texid);
MeshShader::BillboardShader::getInstance()->setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), pos, Size); MeshShader::BillboardShader::getInstance()->setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), pos, Size);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0); glBindVertexArray(0);

View File

@ -268,10 +268,10 @@ void STKMeshSceneNode::render()
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentFogShader::getInstance()->SamplersId[0]); mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentFogShader::getInstance()->SamplersId[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0])) if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[0]); glMakeTextureHandleResidentARB(mesh.TextureHandles[0]);
MeshShader::ObjectPass1Shader::getInstance()->SetTextureHandles(createVector<uint64_t>(mesh.TextureHandles[0])); MeshShader::ObjectPass1Shader::getInstance()->SetTextureHandles(mesh.TextureHandles[0]);
} }
else else
MeshShader::ObjectPass1Shader::getInstance()->SetTextureUnits(std::vector < GLuint > { getTextureGLuint(mesh.textures[0]) }); MeshShader::ObjectPass1Shader::getInstance()->SetTextureUnits(getTextureGLuint(mesh.textures[0]));
MeshShader::ObjectPass1Shader::getInstance()->setUniforms(AbsoluteTransformation, invmodel); MeshShader::ObjectPass1Shader::getInstance()->setUniforms(AbsoluteTransformation, invmodel);
assert(mesh.vao); assert(mesh.vao);
glBindVertexArray(mesh.vao); glBindVertexArray(mesh.vao);
@ -318,15 +318,19 @@ void STKMeshSceneNode::render()
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentFogShader::getInstance()->SamplersId[0]); mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentFogShader::getInstance()->SamplersId[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0])) if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[0]); glMakeTextureHandleResidentARB(mesh.TextureHandles[0]);
MeshShader::ObjectPass2Shader::getInstance()->SetTextureHandles(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, mesh.TextureHandles[0])); if (!mesh.TextureHandles[1])
mesh.TextureHandles[1] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[1]), MeshShader::TransparentFogShader::getInstance()->SamplersId[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[1]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[1]);
MeshShader::ObjectPass2Shader::getInstance()->SetTextureHandles(DiffuseHandle, SpecularHandle, SSAOHandle, mesh.TextureHandles[0], mesh.TextureHandles[1]);
} }
else else
MeshShader::ObjectPass2Shader::getInstance()->SetTextureUnits(createVector<GLuint>( MeshShader::ObjectPass2Shader::getInstance()->SetTextureUnits(
irr_driver->getRenderTargetTexture(RTT_DIFFUSE), irr_driver->getRenderTargetTexture(RTT_DIFFUSE),
irr_driver->getRenderTargetTexture(RTT_SPECULAR), irr_driver->getRenderTargetTexture(RTT_SPECULAR),
irr_driver->getRenderTargetTexture(RTT_HALF1_R), irr_driver->getRenderTargetTexture(RTT_HALF1_R),
getTextureGLuint(mesh.textures[0]), getTextureGLuint(mesh.textures[0]),
getTextureGLuint(mesh.textures[1]))); getTextureGLuint(mesh.textures[1]));
MeshShader::ObjectPass2Shader::getInstance()->setUniforms(AbsoluteTransformation, mesh.TextureMatrix); MeshShader::ObjectPass2Shader::getInstance()->setUniforms(AbsoluteTransformation, mesh.TextureMatrix);
assert(mesh.vao); assert(mesh.vao);
glBindVertexArray(mesh.vao); glBindVertexArray(mesh.vao);
@ -395,10 +399,10 @@ void STKMeshSceneNode::render()
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentFogShader::getInstance()->SamplersId[0]); mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentFogShader::getInstance()->SamplersId[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0])) if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[0]); glMakeTextureHandleResidentARB(mesh.TextureHandles[0]);
MeshShader::TransparentFogShader::getInstance()->SetTextureHandles(createVector<uint64_t>(mesh.TextureHandles[0])); MeshShader::TransparentFogShader::getInstance()->SetTextureHandles(mesh.TextureHandles[0]);
} }
else else
MeshShader::TransparentFogShader::getInstance()->SetTextureUnits(std::vector<GLuint>{ getTextureGLuint(mesh.textures[0]) }); MeshShader::TransparentFogShader::getInstance()->SetTextureUnits(getTextureGLuint(mesh.textures[0]));
MeshShader::TransparentFogShader::getInstance()->setUniforms(AbsoluteTransformation, mesh.TextureMatrix, fogmax, startH, endH, start, end, col); MeshShader::TransparentFogShader::getInstance()->setUniforms(AbsoluteTransformation, mesh.TextureMatrix, fogmax, startH, endH, start, end, col);
assert(mesh.vao); assert(mesh.vao);
@ -425,10 +429,10 @@ void STKMeshSceneNode::render()
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentShader::getInstance()->SamplersId[0]); mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentShader::getInstance()->SamplersId[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0])) if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[0]); glMakeTextureHandleResidentARB(mesh.TextureHandles[0]);
MeshShader::TransparentShader::getInstance()->SetTextureHandles(createVector<uint64_t>(mesh.TextureHandles[0])); MeshShader::TransparentShader::getInstance()->SetTextureHandles(mesh.TextureHandles[0]);
} }
else else
MeshShader::TransparentShader::getInstance()->SetTextureUnits(std::vector<GLuint>{ getTextureGLuint(mesh.textures[0]) }); MeshShader::TransparentShader::getInstance()->SetTextureUnits(getTextureGLuint(mesh.textures[0]));
MeshShader::TransparentShader::getInstance()->setUniforms(AbsoluteTransformation, mesh.TextureMatrix); MeshShader::TransparentShader::getInstance()->setUniforms(AbsoluteTransformation, mesh.TextureMatrix);
assert(mesh.vao); assert(mesh.vao);

View File

@ -81,7 +81,7 @@ namespace STK {
template<typename... T> template<typename... T>
struct TupleSize struct TupleSize
{ {
int value; const int value;
TupleSize() TupleSize()
{ {
value = sizeof...(T); value = sizeof...(T);