Moved TextureRead into a new file, fixed coding style.

This commit is contained in:
hiker 2015-04-27 09:03:33 +10:00
parent e1ef2aa305
commit b14acf2a67
16 changed files with 329 additions and 252 deletions

View File

@ -39,7 +39,7 @@ static void drawTexColoredQuad(const video::ITexture *texture, const video::SCol
UIShader::ColoredTextureRectShader::getInstance()->use();
glBindVertexArray(UIShader::ColoredTextureRectShader::getInstance()->vao);
UIShader::ColoredTextureRectShader::getInstance()->SetTextureUnits(static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName());
UIShader::ColoredTextureRectShader::getInstance()->setTextureUnits(static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName());
UIShader::ColoredTextureRectShader::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));
@ -59,7 +59,7 @@ float tex_width, float tex_height)
UIShader::TextureRectShader::getInstance()->use();
glBindVertexArray(SharedObject::UIVAO);
UIShader::TextureRectShader::getInstance()->SetTextureUnits(texture);
UIShader::TextureRectShader::getInstance()->setTextureUnits(texture);
UIShader::TextureRectShader::getInstance()->setUniforms(
core::vector2df(center_pos_x, center_pos_y), core::vector2df(width, height),
core::vector2df(tex_center_pos_x, tex_center_pos_y),
@ -161,7 +161,7 @@ void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect
UIShader::UniformColoredTextureRectShader::getInstance()->use();
glBindVertexArray(SharedObject::UIVAO);
UIShader::UniformColoredTextureRectShader::getInstance()->SetTextureUnits(static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName());
UIShader::UniformColoredTextureRectShader::getInstance()->setTextureUnits(static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName());
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);
@ -197,7 +197,7 @@ void draw2DImageFromRTT(GLuint texture, size_t texture_w, size_t texture_h,
UIShader::UniformColoredTextureRectShader::getInstance()->use();
glBindVertexArray(SharedObject::UIVAO);
UIShader::UniformColoredTextureRectShader::getInstance()->SetTextureUnits(texture);
UIShader::UniformColoredTextureRectShader::getInstance()->setTextureUnits(texture);
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),
@ -285,7 +285,7 @@ void draw2DVertexPrimitiveList(video::ITexture *tex, const void* vertices,
UIShader::Primitive2DList::getInstance()->setUniforms();
const video::SOverrideMaterial &m = irr_driver->getVideoDriver()->getOverrideMaterial();
compressTexture(tex, false);
UIShader::Primitive2DList::getInstance()->SetTextureUnits(getTextureGLuint(tex));
UIShader::Primitive2DList::getInstance()->setTextureUnits(getTextureGLuint(tex));
glDrawElements(GL_TRIANGLE_FAN, primitiveCount, GL_UNSIGNED_SHORT, 0);
glDeleteVertexArrays(1, &tmpvao);

View File

@ -369,7 +369,7 @@ GLuint generateSpecularCubemap(GLuint probe)
GLuint status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
assert(status == GL_FRAMEBUFFER_COMPLETE);
UtilShader::SpecularIBLGenerator::getInstance()->SetTextureUnits(probe);
UtilShader::SpecularIBLGenerator::getInstance()->setTextureUnits(probe);
UtilShader::SpecularIBLGenerator::getInstance()->setUniforms(M[face], viewportSize);
glDrawArrays(GL_TRIANGLES, 0, 3);

View File

@ -64,7 +64,7 @@ public:
GL_FRAGMENT_SHADER, "particle.frag");
assignUniforms("color_from", "color_to");
AssignSamplerNames(m_program, 0, "tex", 1, "dtex");
assignSamplerNames(m_program, 0, "tex", 1, "dtex");
} // SimpleParticleRender
}; // SimpleParticleRender
@ -83,7 +83,7 @@ public:
GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag",
GL_FRAGMENT_SHADER, "particle.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "tex", 1, "dtex");
assignSamplerNames(m_program, 0, "tex", 1, "dtex");
}
}; // FlipParticleShader
@ -520,7 +520,7 @@ void ParticleSystemProxy::drawFlip()
glBlendFunc(GL_ONE, GL_ONE);
FlipParticleRender::getInstance()->use();
FlipParticleRender::getInstance()->SetTextureUnits(texture, irr_driver->getDepthStencilTexture());
FlipParticleRender::getInstance()->setTextureUnits(texture, irr_driver->getDepthStencilTexture());
FlipParticleRender::getInstance()->setUniforms();
glBindVertexArray(current_rendering_vao);
@ -535,7 +535,7 @@ void ParticleSystemProxy::drawNotFlip()
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
SimpleParticleRender::getInstance()->use();
SimpleParticleRender::getInstance()->SetTextureUnits(texture, irr_driver->getDepthStencilTexture());
SimpleParticleRender::getInstance()->setTextureUnits(texture, irr_driver->getDepthStencilTexture());
video::SColorf ColorFrom = video::SColorf(getColorFrom()[0], getColorFrom()[1], getColorFrom()[2]);
video::SColorf ColorTo = video::SColorf(getColorTo()[0], getColorTo()[1], getColorTo()[2]);

View File

@ -209,7 +209,7 @@ void PostProcessing::update(float dt)
static
void renderBloom(GLuint in)
{
FullScreenShader::BloomShader::getInstance()->SetTextureUnits(in);
FullScreenShader::BloomShader::getInstance()->setTextureUnits(in);
DrawFullScreenEffect<FullScreenShader::BloomShader>();
}
@ -225,7 +225,7 @@ void PostProcessing::renderEnvMap(const float *bSHCoeff, const float *gSHCoeff,
FullScreenShader::DegradedIBLShader::getInstance()->use();
glBindVertexArray(SharedObject::FullScreenQuadVAO);
FullScreenShader::DegradedIBLShader::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH));
FullScreenShader::DegradedIBLShader::getInstance()->setTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH));
FullScreenShader::DegradedIBLShader::getInstance()->setUniforms();
}
else
@ -233,7 +233,7 @@ void PostProcessing::renderEnvMap(const float *bSHCoeff, const float *gSHCoeff,
FullScreenShader::IBLShader::getInstance()->use();
glBindVertexArray(SharedObject::FullScreenQuadVAO);
FullScreenShader::IBLShader::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture(), skybox);
FullScreenShader::IBLShader::getInstance()->setTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture(), skybox);
FullScreenShader::IBLShader::getInstance()->setUniforms();
}
@ -266,7 +266,7 @@ void PostProcessing::renderGI(const core::matrix4 &RHMatrix, const core::vector3
core::matrix4 InvRHMatrix;
RHMatrix.getInverse(InvRHMatrix);
glDisable(GL_DEPTH_TEST);
FullScreenShader::GlobalIlluminationReconstructionShader::getInstance()->SetTextureUnits(
FullScreenShader::GlobalIlluminationReconstructionShader::getInstance()->setTextureUnits(
irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture(), shr, shg, shb);
DrawFullScreenEffect<FullScreenShader::GlobalIlluminationReconstructionShader>(RHMatrix, InvRHMatrix, rh_extend);
}
@ -278,7 +278,7 @@ void PostProcessing::renderSunlight(const core::vector3df &direction, const vide
glBlendFunc(GL_ONE, GL_ONE);
glBlendEquation(GL_FUNC_ADD);
FullScreenShader::SunLightShader::getInstance()->SetTextureUnits(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>(direction, col);
}
@ -311,13 +311,13 @@ void PostProcessing::renderGaussian3Blur(FrameBuffer &in_fbo, FrameBuffer &auxil
{
auxiliary.Bind();
FullScreenShader::Gaussian3VBlurShader::getInstance()->SetTextureUnits(in_fbo.getRTT()[0]);
FullScreenShader::Gaussian3VBlurShader::getInstance()->setTextureUnits(in_fbo.getRTT()[0]);
DrawFullScreenEffect<FullScreenShader::Gaussian3VBlurShader>(core::vector2df(inv_width, inv_height));
}
{
in_fbo.Bind();
FullScreenShader::Gaussian3HBlurShader::getInstance()->SetTextureUnits(auxiliary.getRTT()[0]);
FullScreenShader::Gaussian3HBlurShader::getInstance()->setTextureUnits(auxiliary.getRTT()[0]);
DrawFullScreenEffect<FullScreenShader::Gaussian3HBlurShader>(core::vector2df(inv_width, inv_height));
}
}
@ -331,10 +331,10 @@ void PostProcessing::renderGaussian6BlurLayer(FrameBuffer &in_fbo, size_t layer,
{
// Used as temp
irr_driver->getFBO(FBO_SCALAR_1024).Bind();
FullScreenShader::Gaussian6VBlurShader::getInstance()->SetTextureUnits(LayerTex);
FullScreenShader::Gaussian6VBlurShader::getInstance()->setTextureUnits(LayerTex);
DrawFullScreenEffect<FullScreenShader::Gaussian6VBlurShader>(core::vector2df(1.f / UserConfigParams::m_shadows_resolution, 1.f / UserConfigParams::m_shadows_resolution), sigmaV);
in_fbo.BindLayer(layer);
FullScreenShader::Gaussian6HBlurShader::getInstance()->SetTextureUnits(irr_driver->getFBO(FBO_SCALAR_1024).getRTT()[0]);
FullScreenShader::Gaussian6HBlurShader::getInstance()->setTextureUnits(irr_driver->getFBO(FBO_SCALAR_1024).getRTT()[0]);
DrawFullScreenEffect<FullScreenShader::Gaussian6HBlurShader>(core::vector2df(1.f / UserConfigParams::m_shadows_resolution, 1.f / UserConfigParams::m_shadows_resolution), sigmaH);
}
else
@ -342,7 +342,7 @@ void PostProcessing::renderGaussian6BlurLayer(FrameBuffer &in_fbo, size_t layer,
const std::vector<float> &weightsV = getGaussianWeight(sigmaV, 7);
glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT);
FullScreenShader::ComputeShadowBlurVShader::getInstance()->use();
FullScreenShader::ComputeShadowBlurVShader::getInstance()->SetTextureUnits(LayerTex);
FullScreenShader::ComputeShadowBlurVShader::getInstance()->setTextureUnits(LayerTex);
glBindSampler(FullScreenShader::ComputeShadowBlurVShader::getInstance()->TU_dest, 0);
glBindImageTexture(FullScreenShader::ComputeShadowBlurVShader::getInstance()->TU_dest, irr_driver->getFBO(FBO_SCALAR_1024).getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R32F);
FullScreenShader::ComputeShadowBlurVShader::getInstance()->setUniforms(core::vector2df(1.f / UserConfigParams::m_shadows_resolution, 1.f / UserConfigParams::m_shadows_resolution), weightsV);
@ -351,7 +351,7 @@ void PostProcessing::renderGaussian6BlurLayer(FrameBuffer &in_fbo, size_t layer,
const std::vector<float> &weightsH = getGaussianWeight(sigmaH, 7);
glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT | GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
FullScreenShader::ComputeShadowBlurHShader::getInstance()->use();
FullScreenShader::ComputeShadowBlurHShader::getInstance()->SetTextureUnits(irr_driver->getFBO(FBO_SCALAR_1024).getRTT()[0]);
FullScreenShader::ComputeShadowBlurHShader::getInstance()->setTextureUnits(irr_driver->getFBO(FBO_SCALAR_1024).getRTT()[0]);
glBindSampler(FullScreenShader::ComputeShadowBlurHShader::getInstance()->TU_dest, 0);
glBindImageTexture(FullScreenShader::ComputeShadowBlurHShader::getInstance()->TU_dest, LayerTex, 0, false, 0, GL_WRITE_ONLY, GL_R32F);
FullScreenShader::ComputeShadowBlurHShader::getInstance()->setUniforms(core::vector2df(1.f / UserConfigParams::m_shadows_resolution, 1.f / UserConfigParams::m_shadows_resolution), weightsH);
@ -370,12 +370,12 @@ void PostProcessing::renderGaussian6Blur(FrameBuffer &in_fbo, FrameBuffer &auxil
{
auxiliary.Bind();
FullScreenShader::Gaussian6VBlurShader::getInstance()->SetTextureUnits(in_fbo.getRTT()[0]);
FullScreenShader::Gaussian6VBlurShader::getInstance()->setTextureUnits(in_fbo.getRTT()[0]);
DrawFullScreenEffect<FullScreenShader::Gaussian6VBlurShader>(core::vector2df(inv_width, inv_height), sigmaV);
in_fbo.Bind();
FullScreenShader::Gaussian6HBlurShader::getInstance()->SetTextureUnits(auxiliary.getRTT()[0]);
FullScreenShader::Gaussian6HBlurShader::getInstance()->setTextureUnits(auxiliary.getRTT()[0]);
DrawFullScreenEffect<FullScreenShader::Gaussian6HBlurShader>(core::vector2df(inv_width, inv_height), sigmaH);
}
else
@ -383,7 +383,7 @@ void PostProcessing::renderGaussian6Blur(FrameBuffer &in_fbo, FrameBuffer &auxil
const std::vector<float> &weightsV = getGaussianWeight(sigmaV, 7);
glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT);
FullScreenShader::ComputeGaussian6VBlurShader::getInstance()->use();
FullScreenShader::ComputeGaussian6VBlurShader::getInstance()->SetTextureUnits(in_fbo.getRTT()[0]);
FullScreenShader::ComputeGaussian6VBlurShader::getInstance()->setTextureUnits(in_fbo.getRTT()[0]);
glBindSampler(FullScreenShader::ComputeGaussian6VBlurShader::getInstance()->TU_dest, 0);
glBindImageTexture(FullScreenShader::ComputeGaussian6VBlurShader::getInstance()->TU_dest, auxiliary.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_RGBA16F);
FullScreenShader::ComputeGaussian6VBlurShader::getInstance()->setUniforms(core::vector2df(inv_width, inv_height), weightsV);
@ -392,7 +392,7 @@ void PostProcessing::renderGaussian6Blur(FrameBuffer &in_fbo, FrameBuffer &auxil
const std::vector<float> &weightsH = getGaussianWeight(sigmaH, 7);
glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT | GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
FullScreenShader::ComputeGaussian6HBlurShader::getInstance()->use();
FullScreenShader::ComputeGaussian6HBlurShader::getInstance()->SetTextureUnits(auxiliary.getRTT()[0]);
FullScreenShader::ComputeGaussian6HBlurShader::getInstance()->setTextureUnits(auxiliary.getRTT()[0]);
glBindSampler(FullScreenShader::ComputeGaussian6HBlurShader::getInstance()->TU_dest, 0);
glBindImageTexture(FullScreenShader::ComputeGaussian6HBlurShader::getInstance()->TU_dest, in_fbo.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_RGBA16F);
FullScreenShader::ComputeGaussian6HBlurShader::getInstance()->setUniforms(core::vector2df(inv_width, inv_height), weightsH);
@ -409,13 +409,13 @@ void PostProcessing::renderHorizontalBlur(FrameBuffer &in_fbo, FrameBuffer &auxi
{
auxiliary.Bind();
FullScreenShader::Gaussian6HBlurShader::getInstance()->SetTextureUnits(in_fbo.getRTT()[0]);
FullScreenShader::Gaussian6HBlurShader::getInstance()->setTextureUnits(in_fbo.getRTT()[0]);
DrawFullScreenEffect<FullScreenShader::Gaussian6HBlurShader>(core::vector2df(inv_width, inv_height), 2.0f);
}
{
in_fbo.Bind();
FullScreenShader::Gaussian6HBlurShader::getInstance()->SetTextureUnits(auxiliary.getRTT()[0]);
FullScreenShader::Gaussian6HBlurShader::getInstance()->setTextureUnits(auxiliary.getRTT()[0]);
DrawFullScreenEffect<FullScreenShader::Gaussian6HBlurShader>(core::vector2df(inv_width, inv_height), 2.0f);
}
}
@ -431,14 +431,14 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
if (!CVS->supportsComputeShadersFiltering())
{
auxiliary.Bind();
FullScreenShader::Gaussian17TapHShader::getInstance()->SetTextureUnits(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));
}
else
{
FullScreenShader::ComputeGaussian17TapHShader::getInstance()->use();
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);
FullScreenShader::ComputeGaussian17TapHShader::getInstance()->setUniforms(core::vector2df(inv_width, inv_height));
glDispatchCompute((int)in_fbo.getWidth() / 8 + 1, (int)in_fbo.getHeight() / 8 + 1, 1);
@ -451,14 +451,14 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
{
in_fbo.Bind();
FullScreenShader::Gaussian17TapVShader::getInstance()->SetTextureUnits(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));
}
else
{
FullScreenShader::ComputeGaussian17TapVShader::getInstance()->use();
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);
FullScreenShader::ComputeGaussian17TapVShader::getInstance()->setUniforms(core::vector2df(inv_width, inv_height));
glDispatchCompute((int)in_fbo.getWidth() / 8 + 1, (int)in_fbo.getHeight() / 8 + 1, 1);
@ -470,7 +470,7 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
void PostProcessing::renderPassThrough(GLuint tex, unsigned width, unsigned height)
{
FullScreenShader::PassThroughShader::getInstance()->SetTextureUnits(tex);
FullScreenShader::PassThroughShader::getInstance()->setTextureUnits(tex);
DrawFullScreenEffect<FullScreenShader::PassThroughShader>(width, height);
}
@ -493,7 +493,7 @@ void PostProcessing::renderGlow(unsigned tex)
FullScreenShader::GlowShader::getInstance()->use();
glBindVertexArray(FullScreenShader::GlowShader::getInstance()->vao);
FullScreenShader::GlowShader::getInstance()->SetTextureUnits(tex);
FullScreenShader::GlowShader::getInstance()->setTextureUnits(tex);
FullScreenShader::GlowShader::getInstance()->setUniforms();
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
@ -506,11 +506,11 @@ void PostProcessing::renderSSAO()
// Generate linear depth buffer
irr_driver->getFBO(FBO_LINEAR_DEPTH).Bind();
FullScreenShader::LinearizeDepthShader::getInstance()->SetTextureUnits(irr_driver->getDepthStencilTexture());
FullScreenShader::LinearizeDepthShader::getInstance()->setTextureUnits(irr_driver->getDepthStencilTexture());
DrawFullScreenEffect<FullScreenShader::LinearizeDepthShader>(irr_driver->getSceneManager()->getActiveCamera()->getNearValue(), irr_driver->getSceneManager()->getActiveCamera()->getFarValue());
irr_driver->getFBO(FBO_SSAO).Bind();
FullScreenShader::SSAOShader::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_LINEAR_DEPTH));
FullScreenShader::SSAOShader::getInstance()->setTextureUnits(irr_driver->getRenderTargetTexture(RTT_LINEAR_DEPTH));
glGenerateMipmap(GL_TEXTURE_2D);
DrawFullScreenEffect<FullScreenShader::SSAOShader>(irr_driver->getSSAORadius(), irr_driver->getSSAOK(), irr_driver->getSSAOSigma());
@ -543,7 +543,7 @@ void PostProcessing::renderMotionBlur(unsigned , FrameBuffer &in_fbo, FrameBuffe
out_fbo.Bind();
glClear(GL_COLOR_BUFFER_BIT);
FullScreenShader::MotionBlurShader::getInstance()->SetTextureUnits(in_fbo.getRTT()[0], irr_driver->getDepthStencilTexture());
FullScreenShader::MotionBlurShader::getInstance()->setTextureUnits(in_fbo.getRTT()[0], irr_driver->getDepthStencilTexture());
DrawFullScreenEffect<FullScreenShader::MotionBlurShader>(
// Todo : use a previousPVMatrix per cam, not global
cam->getPreviousPVMatrix(),
@ -554,27 +554,27 @@ void PostProcessing::renderMotionBlur(unsigned , FrameBuffer &in_fbo, FrameBuffe
static void renderGodFade(GLuint tex, const SColor &col)
{
FullScreenShader::GodFadeShader::getInstance()->SetTextureUnits(tex);
FullScreenShader::GodFadeShader::getInstance()->setTextureUnits(tex);
DrawFullScreenEffect<FullScreenShader::GodFadeShader>(col);
}
static void renderGodRay(GLuint tex, const core::vector2df &sunpos)
{
FullScreenShader::GodRayShader::getInstance()->SetTextureUnits(tex);
FullScreenShader::GodRayShader::getInstance()->setTextureUnits(tex);
DrawFullScreenEffect<FullScreenShader::GodRayShader>(sunpos);
}
static void toneMap(FrameBuffer &fbo, GLuint rtt, float vignette_weight)
{
fbo.Bind();
FullScreenShader::ToneMapShader::getInstance()->SetTextureUnits(rtt);
FullScreenShader::ToneMapShader::getInstance()->setTextureUnits(rtt);
DrawFullScreenEffect<FullScreenShader::ToneMapShader>(vignette_weight);
}
static void renderDoF(FrameBuffer &fbo, GLuint rtt)
{
fbo.Bind();
FullScreenShader::DepthOfFieldShader::getInstance()->SetTextureUnits(rtt, irr_driver->getDepthStencilTexture());
FullScreenShader::DepthOfFieldShader::getInstance()->setTextureUnits(rtt, irr_driver->getDepthStencilTexture());
DrawFullScreenEffect<FullScreenShader::DepthOfFieldShader>();
}
@ -591,7 +591,7 @@ void PostProcessing::applyMLAA()
// Pass 1: color edge detection
FullScreenShader::MLAAColorEdgeDetectionSHader::getInstance()->use();
FullScreenShader::MLAAColorEdgeDetectionSHader::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_MLAA_COLORS));
FullScreenShader::MLAAColorEdgeDetectionSHader::getInstance()->setTextureUnits(irr_driver->getRenderTargetTexture(RTT_MLAA_COLORS));
DrawFullScreenEffect<FullScreenShader::MLAAColorEdgeDetectionSHader>(PIXEL_SIZE);
glStencilFunc(GL_EQUAL, 1, ~0);
@ -602,7 +602,7 @@ void PostProcessing::applyMLAA()
glClear(GL_COLOR_BUFFER_BIT);
FullScreenShader::MLAABlendWeightSHader::getInstance()->use();
FullScreenShader::MLAABlendWeightSHader::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_MLAA_TMP), getTextureGLuint(m_areamap));
FullScreenShader::MLAABlendWeightSHader::getInstance()->setTextureUnits(irr_driver->getRenderTargetTexture(RTT_MLAA_TMP), getTextureGLuint(m_areamap));
DrawFullScreenEffect<FullScreenShader::MLAABlendWeightSHader>(PIXEL_SIZE);
// Blit in to tmp1
@ -612,7 +612,7 @@ void PostProcessing::applyMLAA()
irr_driver->getFBO(FBO_MLAA_COLORS).Bind();
FullScreenShader::MLAAGatherSHader::getInstance()->use();
FullScreenShader::MLAAGatherSHader::getInstance()->SetTextureUnits(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));
DrawFullScreenEffect<FullScreenShader::MLAAGatherSHader>(PIXEL_SIZE);
// Done.
@ -753,11 +753,11 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode, boo
glBlendFunc(GL_ONE, GL_ONE);
glBlendEquation(GL_FUNC_ADD);
FullScreenShader::BloomBlendShader::getInstance()->SetTextureUnits(
FullScreenShader::BloomBlendShader::getInstance()->setTextureUnits(
irr_driver->getRenderTargetTexture(RTT_BLOOM_128), irr_driver->getRenderTargetTexture(RTT_BLOOM_256), irr_driver->getRenderTargetTexture(RTT_BLOOM_512));
DrawFullScreenEffect<FullScreenShader::BloomBlendShader>();
FullScreenShader::LensBlendShader::getInstance()->SetTextureUnits(
FullScreenShader::LensBlendShader::getInstance()->setTextureUnits(
irr_driver->getRenderTargetTexture(RTT_LENS_128), irr_driver->getRenderTargetTexture(RTT_LENS_256), irr_driver->getRenderTargetTexture(RTT_LENS_512));
DrawFullScreenEffect<FullScreenShader::LensBlendShader>();

View File

@ -376,7 +376,7 @@ 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...);
T::getInstance()->setTextureUnits(args...);
}
};
@ -408,7 +408,7 @@ 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...);
T::getInstance()->setTextureHandles(args...);
}
};
@ -614,19 +614,19 @@ void IrrDriver::renderSolidSecondPass()
if (CVS->isAZDOEnabled())
{
DiffuseHandle = glGetTextureSamplerHandleARB(m_rtts->getRenderTarget(RTT_DIFFUSE), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[0]);
DiffuseHandle = glGetTextureSamplerHandleARB(m_rtts->getRenderTarget(RTT_DIFFUSE), MeshShader::ObjectPass2Shader::getInstance()->m_sampler_ids[0]);
if (!glIsTextureHandleResidentARB(DiffuseHandle))
glMakeTextureHandleResidentARB(DiffuseHandle);
SpecularHandle = glGetTextureSamplerHandleARB(m_rtts->getRenderTarget(RTT_SPECULAR), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[1]);
SpecularHandle = glGetTextureSamplerHandleARB(m_rtts->getRenderTarget(RTT_SPECULAR), MeshShader::ObjectPass2Shader::getInstance()->m_sampler_ids[1]);
if (!glIsTextureHandleResidentARB(SpecularHandle))
glMakeTextureHandleResidentARB(SpecularHandle);
SSAOHandle = glGetTextureSamplerHandleARB(m_rtts->getRenderTarget(RTT_HALF1_R), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[2]);
SSAOHandle = glGetTextureSamplerHandleARB(m_rtts->getRenderTarget(RTT_HALF1_R), MeshShader::ObjectPass2Shader::getInstance()->m_sampler_ids[2]);
if (!glIsTextureHandleResidentARB(SSAOHandle))
glMakeTextureHandleResidentARB(SSAOHandle);
DepthHandle = glGetTextureSamplerHandleARB(getDepthStencilTexture(), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[3]);
DepthHandle = glGetTextureSamplerHandleARB(getDepthStencilTexture(), MeshShader::ObjectPass2Shader::getInstance()->m_sampler_ids[3]);
if (!glIsTextureHandleResidentARB(DepthHandle))
glMakeTextureHandleResidentARB(DepthHandle);
}
@ -773,9 +773,9 @@ void renderTransparenPass(const std::vector<RenderGeometry::TexUnit> &TexUnits,
}
if (CVS->isAZDOEnabled())
Shader::getInstance()->SetTextureHandles(mesh.TextureHandles[0]);
Shader::getInstance()->setTextureHandles(mesh.TextureHandles[0]);
else
Shader::getInstance()->SetTextureUnits(getTextureGLuint(mesh.textures[0]));
Shader::getInstance()->setTextureUnits(getTextureGLuint(mesh.textures[0]));
custom_unroll_args<List...>::template exec(Shader::getInstance(), meshes->at(i));
}
}
@ -885,7 +885,7 @@ void IrrDriver::renderTransparent()
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
// Render the effect
MeshShader::DisplaceShader::getInstance()->SetTextureUnits(
MeshShader::DisplaceShader::getInstance()->setTextureUnits(
getTextureGLuint(displaceTex),
irr_driver->getRenderTargetTexture(RTT_COLOR),
irr_driver->getRenderTargetTexture(RTT_TMP1),

View File

@ -47,7 +47,7 @@ static void renderPointLights(unsigned count)
glBindBuffer(GL_ARRAY_BUFFER, LightShader::PointLightShader::getInstance()->vbo);
glBufferSubData(GL_ARRAY_BUFFER, 0, count * sizeof(LightShader::PointLightInfo), PointLightsInfo);
LightShader::PointLightShader::getInstance()->SetTextureUnits(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();
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, count);
@ -159,7 +159,7 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
if (CVS->needRHWorkaround())
{
FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->use();
FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->SetTextureUnits(
FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->setTextureUnits(
m_rtts->getRSM().getRTT()[0], m_rtts->getRSM().getRTT()[1], m_rtts->getRSM().getDepthTexture());
for (unsigned i = 0; i < 32; i++)
{
@ -170,7 +170,7 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
else
{
FullScreenShader::RadianceHintsConstructionShader::getInstance()->use();
FullScreenShader::RadianceHintsConstructionShader::getInstance()->SetTextureUnits(
FullScreenShader::RadianceHintsConstructionShader::getInstance()->setTextureUnits(
m_rtts->getRSM().getRTT()[0],
m_rtts->getRSM().getRTT()[1],
m_rtts->getRSM().getDepthTexture()
@ -212,12 +212,12 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
if (CVS->isESMEnabled())
{
FullScreenShader::ShadowedSunLightShaderESM::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture(), m_rtts->getShadowFBO().getRTT()[0]);
FullScreenShader::ShadowedSunLightShaderESM::getInstance()->setTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture(), m_rtts->getShadowFBO().getRTT()[0]);
DrawFullScreenEffect<FullScreenShader::ShadowedSunLightShaderESM>(shadowSplit[1], shadowSplit[2], shadowSplit[3], shadowSplit[4]);
}
else
{
FullScreenShader::ShadowedSunLightShaderPCF::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture(), m_rtts->getShadowFBO().getDepthTexture());
FullScreenShader::ShadowedSunLightShaderPCF::getInstance()->setTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture(), m_rtts->getShadowFBO().getDepthTexture());
DrawFullScreenEffect<FullScreenShader::ShadowedSunLightShaderPCF>(shadowSplit[1],
shadowSplit[2],
shadowSplit[3],
@ -264,7 +264,7 @@ void IrrDriver::renderAmbientScatter()
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_ONE, GL_ONE);
FullScreenShader::FogShader::getInstance()->SetTextureUnits(irr_driver->getDepthStencilTexture());
FullScreenShader::FogShader::getInstance()->setTextureUnits(irr_driver->getDepthStencilTexture());
DrawFullScreenEffect<FullScreenShader::FogShader>(1.f / (40.f * start), col);
}
@ -295,7 +295,7 @@ void IrrDriver::renderLightsScatter(unsigned pointlightcount)
LightShader::PointLightScatterShader::getInstance()->use();
glBindVertexArray(LightShader::PointLightScatterShader::getInstance()->vao);
LightShader::PointLightScatterShader::getInstance()->SetTextureUnits(irr_driver->getDepthStencilTexture());
LightShader::PointLightScatterShader::getInstance()->setTextureUnits(irr_driver->getDepthStencilTexture());
LightShader::PointLightScatterShader::getInstance()->setUniforms(1.f / (40.f * start), col2);
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, MIN2(pointlightcount, MAXLIGHT));

View File

@ -407,7 +407,7 @@ void IrrDriver::renderSkybox(const scene::ICameraSceneNode *camera)
glBindVertexArray(MeshShader::SkyboxShader::getInstance()->vao);
MeshShader::SkyboxShader::getInstance()->setUniforms();
MeshShader::SkyboxShader::getInstance()->SetTextureUnits(SkyboxCubeMap);
MeshShader::SkyboxShader::getInstance()->setTextureUnits(SkyboxCubeMap);
glDrawArrays(GL_TRIANGLES, 0, 3);
glBindVertexArray(0);

View File

@ -325,4 +325,5 @@ public:
}; // Shader
// ============================================================================
#endif

View File

@ -760,7 +760,7 @@ namespace UtilShader
GL_FRAGMENT_SHADER, "importance_sampling_specular.frag");
assignUniforms("PermutationMatrix", "ViewportSize");
TU_Samples = 1;
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
assignTextureUnit(TU_Samples, "samples");
}
}
@ -775,7 +775,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "utils/encode_normal.frag",
GL_FRAGMENT_SHADER, "object_pass1.frag");
assignUniforms("ModelMatrix", "InverseModelMatrix");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
ObjectRefPass1Shader::ObjectRefPass1Shader()
@ -785,7 +785,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "utils/encode_normal.frag",
GL_FRAGMENT_SHADER, "objectref_pass1.frag");
assignUniforms("ModelMatrix", "InverseModelMatrix", "TextureMatrix");
AssignSamplerNames(m_program, 0, "tex", 1, "glosstex");
assignSamplerNames(m_program, 0, "tex", 1, "glosstex");
}
GrassPass1Shader::GrassPass1Shader()
@ -795,7 +795,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "utils/encode_normal.frag",
GL_FRAGMENT_SHADER, "objectref_pass1.frag");
assignUniforms("ModelMatrix", "InverseModelMatrix", "windDir");
AssignSamplerNames(m_program, 0, "tex", 1, "glosstex");
assignSamplerNames(m_program, 0, "tex", 1, "glosstex");
}
NormalMapShader::NormalMapShader()
@ -805,7 +805,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "utils/encode_normal.frag",
GL_FRAGMENT_SHADER, "normalmap.frag");
assignUniforms("ModelMatrix", "InverseModelMatrix");
AssignSamplerNames(m_program, 1, "normalMap", 0, "DiffuseForAlpha");
assignSamplerNames(m_program, 1, "normalMap", 0, "DiffuseForAlpha");
}
InstancedObjectPass1Shader::InstancedObjectPass1Shader()
@ -817,7 +817,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "instanced_object_pass1.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "glosstex");
assignSamplerNames(m_program, 0, "glosstex");
}
InstancedObjectRefPass1Shader::InstancedObjectRefPass1Shader()
@ -829,7 +829,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "instanced_objectref_pass1.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "tex", 1, "glosstex");
assignSamplerNames(m_program, 0, "tex", 1, "glosstex");
}
InstancedGrassPass1Shader::InstancedGrassPass1Shader()
@ -840,7 +840,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "utils/encode_normal.frag",
GL_FRAGMENT_SHADER, "instanced_objectref_pass1.frag");
assignUniforms("windDir");
AssignSamplerNames(m_program, 0, "tex", 1, "glosstex");
assignSamplerNames(m_program, 0, "tex", 1, "glosstex");
}
InstancedNormalMapShader::InstancedNormalMapShader()
@ -851,7 +851,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "utils/encode_normal.frag",
GL_FRAGMENT_SHADER, "instanced_normalmap.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "normalMap", 1, "glossMap");
assignSamplerNames(m_program, 0, "normalMap", 1, "glossMap");
}
// Solid Lit pass shaders
@ -862,7 +862,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "utils/getLightFactor.frag",
GL_FRAGMENT_SHADER, "object_pass2.frag");
assignUniforms("ModelMatrix", "TextureMatrix");
AssignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap");
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap");
}
InstancedObjectPass2Shader::InstancedObjectPass2Shader()
@ -873,7 +873,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "utils/getLightFactor.frag",
GL_FRAGMENT_SHADER, "instanced_object_pass2.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap");
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap");
}
InstancedObjectRefPass2Shader::InstancedObjectRefPass2Shader()
@ -884,7 +884,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "utils/getLightFactor.frag",
GL_FRAGMENT_SHADER, "instanced_objectref_pass2.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap");
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap");
}
DetailledObjectPass2Shader::DetailledObjectPass2Shader()
@ -894,7 +894,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "utils/getLightFactor.frag",
GL_FRAGMENT_SHADER, "detailledobject_pass2.frag");
assignUniforms("ModelMatrix");
AssignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail", 5, "SpecMap");
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail", 5, "SpecMap");
}
InstancedDetailledObjectPass2Shader::InstancedDetailledObjectPass2Shader()
@ -905,7 +905,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "utils/getLightFactor.frag",
GL_FRAGMENT_SHADER, "instanced_detailledobject_pass2.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail", 5, "SpecMap");
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail", 5, "SpecMap");
}
ObjectUnlitShader::ObjectUnlitShader()
@ -914,7 +914,7 @@ namespace MeshShader
GL_VERTEX_SHADER, "object_pass.vert",
GL_FRAGMENT_SHADER, "object_unlit.frag");
assignUniforms("ModelMatrix", "TextureMatrix");
AssignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "tex");
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "tex");
}
InstancedObjectUnlitShader::InstancedObjectUnlitShader()
@ -924,7 +924,7 @@ namespace MeshShader
GL_VERTEX_SHADER, "instanced_object_pass.vert",
GL_FRAGMENT_SHADER, "instanced_object_unlit.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "tex");
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "tex");
}
ObjectRefPass2Shader::ObjectRefPass2Shader()
@ -934,7 +934,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "utils/getLightFactor.frag",
GL_FRAGMENT_SHADER, "objectref_pass2.frag");
assignUniforms("ModelMatrix", "TextureMatrix");
AssignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap");
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap");
}
GrassPass2Shader::GrassPass2Shader()
@ -944,7 +944,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "utils/getLightFactor.frag",
GL_FRAGMENT_SHADER, "grass_pass2.frag");
assignUniforms("ModelMatrix", "windDir");
AssignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap");
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap");
}
InstancedGrassPass2Shader::InstancedGrassPass2Shader()
@ -955,7 +955,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "utils/getLightFactor.frag",
GL_FRAGMENT_SHADER, "instanced_grass_pass2.frag");
assignUniforms("windDir", "SunDir");
AssignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "dtex", 4, "Albedo", 5, "SpecMap");
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "dtex", 4, "Albedo", 5, "SpecMap");
}
SphereMapShader::SphereMapShader()
@ -966,7 +966,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag",
GL_FRAGMENT_SHADER, "objectpass_spheremap.frag");
assignUniforms("ModelMatrix", "InverseModelMatrix");
AssignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "tex");
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "tex");
}
InstancedSphereMapShader::InstancedSphereMapShader()
@ -978,7 +978,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag",
GL_FRAGMENT_SHADER, "instanced_objectpass_spheremap.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "tex");
assignSamplerNames(m_program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "tex");
}
SplattingShader::SplattingShader()
@ -989,7 +989,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "splatting.frag");
assignUniforms("ModelMatrix");
AssignSamplerNames(m_program,
assignSamplerNames(m_program,
0, "DiffuseMap",
1, "SpecularMap",
2, "SSAO",
@ -1006,7 +1006,7 @@ namespace MeshShader
GL_VERTEX_SHADER, "object_pass.vert",
GL_FRAGMENT_SHADER, "transparent.frag");
assignUniforms("ModelMatrix", "TextureMatrix");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
TransparentFogShader::TransparentFogShader()
@ -1015,7 +1015,7 @@ namespace MeshShader
GL_VERTEX_SHADER, "object_pass.vert",
GL_FRAGMENT_SHADER, "transparentfog.frag");
assignUniforms("ModelMatrix", "TextureMatrix", "fogmax", "startH", "endH", "start", "end", "col");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
BillboardShader::BillboardShader()
@ -1025,7 +1025,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "billboard.frag");
assignUniforms("ModelViewMatrix", "ProjectionMatrix", "Position", "Size");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
ColorizeShader::ColorizeShader()
@ -1073,7 +1073,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "rsm.frag");
assignUniforms("RSMMatrix", "ModelMatrix", "TextureMatrix");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
InstancedRSMShader::InstancedRSMShader()
@ -1084,7 +1084,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "instanced_rsm.frag");
assignUniforms("RSMMatrix");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
SplattingRSMShader::SplattingRSMShader()
@ -1094,7 +1094,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "splatting_rsm.frag");
assignUniforms("RSMMatrix", "ModelMatrix");
AssignSamplerNames(m_program, 0, "tex_layout", 1, "tex_detail0", 2, "tex_detail1", 3, "tex_detail2", 4, "tex_detail3");
assignSamplerNames(m_program, 0, "tex_layout", 1, "tex_detail0", 2, "tex_detail1", 3, "tex_detail2", 4, "tex_detail3");
}
InstancedShadowShader::InstancedShadowShader()
@ -1139,7 +1139,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "shadowref.frag");
}
assignUniforms("layer", "ModelMatrix");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
InstancedRefShadowShader::InstancedRefShadowShader()
@ -1163,7 +1163,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "instanced_shadowref.frag");
}
assignUniforms("layer");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
GrassShadowShader::GrassShadowShader()
@ -1185,7 +1185,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "instanced_shadowref.frag");
}
assignUniforms("layer", "ModelMatrix", "windDir");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
InstancedGrassShadowShader::InstancedGrassShadowShader()
@ -1209,7 +1209,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "instanced_shadowref.frag");
}
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
assignUniforms("layer", "windDir");
}
@ -1229,7 +1229,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, "displace.frag");
assignUniforms("ModelMatrix", "dir", "dir2");
AssignSamplerNames(m_program,
assignSamplerNames(m_program,
0, "displacement_tex",
1, "color_tex",
2, "mask_tex",
@ -1242,7 +1242,7 @@ namespace MeshShader
GL_VERTEX_SHADER, "sky.vert",
GL_FRAGMENT_SHADER, "sky.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
@ -1293,7 +1293,7 @@ namespace LightShader
GL_FRAGMENT_SHADER, "pointlight.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "ntex", 1, "dtex");
assignSamplerNames(m_program, 0, "ntex", 1, "dtex");
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
@ -1330,7 +1330,7 @@ namespace LightShader
GL_FRAGMENT_SHADER, "pointlightscatter.frag");
assignUniforms("density", "fogcol");
AssignSamplerNames(m_program, 0, "dtex");
assignSamplerNames(m_program, 0, "dtex");
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
@ -1387,7 +1387,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "bloom.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
BloomBlendShader::BloomBlendShader()
@ -1397,7 +1397,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "bloomblend.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "tex_128", 1, "tex_256", 2, "tex_512");
assignSamplerNames(m_program, 0, "tex_128", 1, "tex_256", 2, "tex_512");
}
LensBlendShader::LensBlendShader()
@ -1407,7 +1407,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "lensblend.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "tex_128", 1, "tex_256", 2, "tex_512");
assignSamplerNames(m_program, 0, "tex_128", 1, "tex_256", 2, "tex_512");
}
ToneMapShader::ToneMapShader()
@ -1419,7 +1419,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "tonemap.frag");
assignUniforms("vignette_weight");
AssignSamplerNames(m_program, 0, "text");
assignSamplerNames(m_program, 0, "text");
}
DepthOfFieldShader::DepthOfFieldShader()
@ -1429,7 +1429,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "dof.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "tex", 1, "dtex");
assignSamplerNames(m_program, 0, "tex", 1, "dtex");
}
SunLightShader::SunLightShader()
@ -1443,7 +1443,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "utils/SunMRP.frag",
GL_FRAGMENT_SHADER, "sunlight.frag");
AssignSamplerNames(m_program, 0, "ntex", 1, "dtex");
assignSamplerNames(m_program, 0, "ntex", 1, "dtex");
assignUniforms("direction", "col");
}
@ -1457,7 +1457,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "utils/SpecularIBL.frag",
GL_FRAGMENT_SHADER, "IBL.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "ntex", 1, "dtex", 2, "probe");
assignSamplerNames(m_program, 0, "ntex", 1, "dtex", 2, "probe");
}
DegradedIBLShader::DegradedIBLShader()
@ -1470,7 +1470,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "utils/SpecularIBL.frag",
GL_FRAGMENT_SHADER, "degraded_ibl.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "ntex");
assignSamplerNames(m_program, 0, "ntex");
}
ShadowedSunLightShaderPCF::ShadowedSunLightShaderPCF()
@ -1485,7 +1485,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "sunlightshadow.frag");
// Use 8 to circumvent a catalyst bug when binding sampler
AssignSamplerNames(m_program, 0, "ntex", 1, "dtex", 8, "shadowtex");
assignSamplerNames(m_program, 0, "ntex", 1, "dtex", 8, "shadowtex");
assignUniforms("split0", "split1", "split2", "splitmax", "shadow_res");
}
@ -1501,7 +1501,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "sunlightshadowesm.frag");
// Use 8 to circumvent a catalyst bug when binding sampler
AssignSamplerNames(m_program, 0, "ntex", 1, "dtex", 8, "shadowtex");
assignSamplerNames(m_program, 0, "ntex", 1, "dtex", 8, "shadowtex");
assignUniforms("split0", "split1", "split2", "splitmax");
}
@ -1522,7 +1522,7 @@ namespace FullScreenShader
}
assignUniforms("RSMMatrix", "RHMatrix", "extents", "suncol");
AssignSamplerNames(m_program, 0, "ctex", 1, "ntex", 2, "dtex");
assignSamplerNames(m_program, 0, "ctex", 1, "ntex", 2, "dtex");
}
NVWorkaroundRadianceHintsConstructionShader::NVWorkaroundRadianceHintsConstructionShader()
@ -1534,7 +1534,7 @@ namespace FullScreenShader
assignUniforms("RSMMatrix", "RHMatrix", "extents", "slice", "suncol");
AssignSamplerNames(m_program, 0, "ctex", 1, "ntex", 2, "dtex");
assignSamplerNames(m_program, 0, "ctex", 1, "ntex", 2, "dtex");
}
RHDebug::RHDebug()
@ -1558,7 +1558,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "gi.frag");
assignUniforms("RHMatrix", "InvRHMatrix", "extents");
AssignSamplerNames(m_program, 0, "ntex", 1, "dtex", 2, "SHR", 3, "SHG", 4, "SHB");
assignSamplerNames(m_program, 0, "ntex", 1, "dtex", 2, "SHR", 3, "SHG", 4, "SHB");
}
Gaussian17TapHShader::Gaussian17TapHShader()
@ -1567,7 +1567,7 @@ namespace FullScreenShader
GL_VERTEX_SHADER, "screenquad.vert",
GL_FRAGMENT_SHADER, "bilateralH.frag");
assignUniforms("pixel");
AssignSamplerNames(m_program, 0, "tex", 1, "depth");
assignSamplerNames(m_program, 0, "tex", 1, "depth");
}
ComputeGaussian17TapHShader::ComputeGaussian17TapHShader()
@ -1575,7 +1575,7 @@ namespace FullScreenShader
loadProgram(OBJECT, GL_COMPUTE_SHADER, "bilateralH.comp");
TU_dest = 2;
assignUniforms("pixel");
AssignSamplerNames(m_program, 0, "source", 1, "depth");
assignSamplerNames(m_program, 0, "source", 1, "depth");
assignTextureUnit(TU_dest, "dest");
}
@ -1585,7 +1585,7 @@ namespace FullScreenShader
GL_COMPUTE_SHADER, "gaussian6h.comp");
TU_dest = 1;
assignUniforms("pixel", "weights");
AssignSamplerNames(m_program, 0, "source");
assignSamplerNames(m_program, 0, "source");
assignTextureUnit(TU_dest, "dest");
}
@ -1595,7 +1595,7 @@ namespace FullScreenShader
GL_COMPUTE_SHADER, "blurshadowH.comp");
TU_dest = 1;
assignUniforms("pixel", "weights");
AssignSamplerNames(m_program, 0, "source");
assignSamplerNames(m_program, 0, "source");
assignTextureUnit(TU_dest, "dest");
}
@ -1606,7 +1606,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "gaussian6h.frag");
assignUniforms("pixel", "sigma");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
HorizontalBlurShader::HorizontalBlurShader()
@ -1616,7 +1616,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "gaussian6h.frag");
assignUniforms("pixel");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
Gaussian3HBlurShader::Gaussian3HBlurShader()
@ -1626,7 +1626,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "gaussian3h.frag");
assignUniforms("pixel");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
Gaussian17TapVShader::Gaussian17TapVShader()
@ -1636,7 +1636,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "bilateralV.frag");
assignUniforms("pixel");
AssignSamplerNames(m_program, 0, "tex", 1, "depth");
assignSamplerNames(m_program, 0, "tex", 1, "depth");
}
ComputeGaussian17TapVShader::ComputeGaussian17TapVShader()
@ -1645,7 +1645,7 @@ namespace FullScreenShader
GL_COMPUTE_SHADER, "bilateralV.comp");
TU_dest = 2;
assignUniforms("pixel");
AssignSamplerNames(m_program, 0, "source", 1, "depth");
assignSamplerNames(m_program, 0, "source", 1, "depth");
assignTextureUnit(TU_dest, "dest");
}
@ -1655,7 +1655,7 @@ namespace FullScreenShader
GL_COMPUTE_SHADER, "gaussian6v.comp");
TU_dest = 1;
assignUniforms("pixel", "weights");
AssignSamplerNames(m_program, 0, "source");
assignSamplerNames(m_program, 0, "source");
assignTextureUnit(TU_dest, "dest");
}
@ -1665,7 +1665,7 @@ namespace FullScreenShader
GL_COMPUTE_SHADER, "blurshadowV.comp");
TU_dest = 1;
assignUniforms("pixel", "weights");
AssignSamplerNames(m_program, 0, "source");
assignSamplerNames(m_program, 0, "source");
assignTextureUnit(TU_dest, "dest");
}
@ -1676,7 +1676,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "gaussian6v.frag");
assignUniforms("pixel", "sigma");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
Gaussian3VBlurShader::Gaussian3VBlurShader()
@ -1686,7 +1686,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "gaussian3v.frag");
assignUniforms("pixel");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
PassThroughShader::PassThroughShader()
@ -1696,7 +1696,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "passthrough.frag");
assignUniforms("width", "height");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
LayerPassThroughShader::LayerPassThroughShader()
@ -1717,7 +1717,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "linearizedepth.frag");
assignUniforms("zn", "zf");
AssignSamplerNames(m_program, 0, "texture");
assignSamplerNames(m_program, 0, "texture");
}
@ -1726,7 +1726,7 @@ namespace FullScreenShader
loadProgram(OBJECT,
GL_COMPUTE_SHADER, "Lightspaceboundingbox.comp",
GL_COMPUTE_SHADER, "utils/getPosFromUVDepth.frag");
AssignSamplerNames(m_program, 0, "depth");
assignSamplerNames(m_program, 0, "depth");
assignUniforms("SunCamMatrix", "split0", "split1", "split2", "splitmax");
GLuint block_idx = glGetProgramResourceIndex(m_program, GL_SHADER_STORAGE_BLOCK, "BoundingBoxes");
glShaderStorageBlockBinding(m_program, block_idx, 2);
@ -1748,7 +1748,7 @@ namespace FullScreenShader
loadProgram(OBJECT,
GL_COMPUTE_SHADER, "depthhistogram.comp",
GL_COMPUTE_SHADER, "utils/getPosFromUVDepth.frag");
AssignSamplerNames(m_program, 0, "depth");
assignSamplerNames(m_program, 0, "depth");
GLuint block_idx = glGetProgramResourceIndex(m_program, GL_SHADER_STORAGE_BLOCK, "Histogram");
glShaderStorageBlockBinding(m_program, block_idx, 1);
@ -1761,7 +1761,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "glow.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
vao = createVAO(m_program);
}
@ -1774,7 +1774,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "ssao.frag");
assignUniforms("radius", "k", "sigma");
AssignSamplerNames(m_program, 0, "dtex");
assignSamplerNames(m_program, 0, "dtex");
}
FogShader::FogShader()
@ -1785,7 +1785,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "fog.frag");
assignUniforms("density", "col");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
MotionBlurShader::MotionBlurShader()
@ -1795,7 +1795,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag",
GL_FRAGMENT_SHADER, "motion_blur.frag");
assignUniforms("previous_viewproj", "center", "boost_amount", "mask_radius");
AssignSamplerNames(m_program, 0, "color_buffer", 1, "dtex");
assignSamplerNames(m_program, 0, "color_buffer", 1, "dtex");
}
GodFadeShader::GodFadeShader()
@ -1805,7 +1805,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "godfade.frag");
assignUniforms("col");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
GodRayShader::GodRayShader()
@ -1815,7 +1815,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "godray.frag");
assignUniforms("sunpos");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
MLAAColorEdgeDetectionSHader::MLAAColorEdgeDetectionSHader()
@ -1825,7 +1825,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "mlaa_color1.frag");
assignUniforms("PIXEL_SIZE");
AssignSamplerNames(m_program, 0, "colorMapG");
assignSamplerNames(m_program, 0, "colorMapG");
}
MLAABlendWeightSHader::MLAABlendWeightSHader()
@ -1835,7 +1835,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "mlaa_blend2.frag");
assignUniforms("PIXEL_SIZE");
AssignSamplerNames(m_program, 0, "edgesMap", 1, "areaMap");
assignSamplerNames(m_program, 0, "edgesMap", 1, "areaMap");
}
MLAAGatherSHader::MLAAGatherSHader()
@ -1845,7 +1845,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, "mlaa_neigh3.frag");
assignUniforms("PIXEL_SIZE");
AssignSamplerNames(m_program, 0, "blendMap", 1, "colorMap");
assignSamplerNames(m_program, 0, "blendMap", 1, "colorMap");
}
}
@ -1858,7 +1858,7 @@ namespace UIShader
GL_VERTEX_SHADER, "primitive2dlist.vert",
GL_FRAGMENT_SHADER, "transparent.frag");
assignUniforms();
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
TextureRectShader::TextureRectShader()
@ -1868,7 +1868,7 @@ namespace UIShader
GL_FRAGMENT_SHADER, "texturedquad.frag");
assignUniforms("center", "size", "texcenter", "texsize");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
UniformColoredTextureRectShader::UniformColoredTextureRectShader()
@ -1879,7 +1879,7 @@ namespace UIShader
assignUniforms("center", "size", "texcenter", "texsize", "color");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
}
ColoredTextureRectShader::ColoredTextureRectShader()
@ -1889,7 +1889,7 @@ namespace UIShader
GL_FRAGMENT_SHADER, "colortexturedquad.frag");
assignUniforms("center", "size", "texcenter", "texsize");
AssignSamplerNames(m_program, 0, "tex");
assignSamplerNames(m_program, 0, "tex");
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);

View File

@ -21,6 +21,7 @@
#include "config/user_config.hpp"
#include "graphics/shader.hpp"
#include "graphics/shaders_util.hpp"
#include "graphics/texture_read.hpp"
#include <IMeshSceneNode.h>
#include <IShaderConstantSetCallBack.h>
@ -48,7 +49,8 @@ public:
ColoredLine();
};
class SpecularIBLGenerator : public Shader<SpecularIBLGenerator, core::matrix4, float >, public TextureRead<Trilinear_cubemap>
class SpecularIBLGenerator : public Shader<SpecularIBLGenerator, core::matrix4, float >,
public TextureRead<Trilinear_cubemap>
{
public:
GLuint TU_Samples;
@ -59,13 +61,15 @@ public:
namespace MeshShader
{
class ObjectPass1Shader : public Shader<ObjectPass1Shader, core::matrix4, core::matrix4>, public TextureRead<Trilinear_Anisotropic_Filtered>
class ObjectPass1Shader : public Shader<ObjectPass1Shader, core::matrix4, core::matrix4>,
public TextureRead<Trilinear_Anisotropic_Filtered>
{
public:
ObjectPass1Shader();
};
class ObjectRefPass1Shader : public Shader<ObjectRefPass1Shader, core::matrix4, core::matrix4, core::matrix4>, public TextureRead<Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
class ObjectRefPass1Shader : public Shader<ObjectRefPass1Shader, core::matrix4, core::matrix4, core::matrix4>,
public TextureRead<Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
{
public:
ObjectRefPass1Shader();

View File

@ -344,92 +344,4 @@ struct BindTexture<Trilinear_Clamped_Array2D, tp...>
}
};
template<SamplerType...tp>
class TextureRead
{
private:
template<unsigned N, typename...Args>
void AssignTextureNames_impl(GLuint)
{
static_assert(N == sizeof...(tp), "Wrong number of texture name");
}
template<unsigned N, typename...Args>
void AssignTextureNames_impl(GLuint Program, GLuint TexUnit, const char *name, Args...args)
{
GLuint location = glGetUniformLocation(Program, name);
TextureLocation.push_back(location);
glUniform1i(location, TexUnit);
TextureUnits.push_back(TexUnit);
AssignTextureNames_impl<N + 1>(Program, args...);
}
protected:
std::vector<GLuint> TextureUnits;
std::vector<GLenum> TextureType;
std::vector<GLenum> TextureLocation;
public:
template<typename...Args>
void AssignSamplerNames(GLuint Program, Args...args)
{
CreateSamplers<tp...>::exec(SamplersId, TextureType);
glUseProgram(Program);
AssignTextureNames_impl<0>(Program, args...);
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:
std::vector<GLuint> SamplersId;
template<typename... TexIds>
void SetTextureUnits(TexIds... args)
{
if (getGLSLVersion() >= 330)
SetTextureUnits_impl<0>(args...);
else
BindTexture<tp...>::template exec<0>(TextureUnits, args...);
}
~TextureRead()
{
for (unsigned i = 0; i < SamplersId.size(); i++)
glDeleteSamplers(1, &SamplersId[i]);
}
template<typename... HandlesId>
void SetTextureHandles(HandlesId... ids)
{
SetTextureHandles_impl<0>(ids...);
}
};
#endif

View File

@ -148,7 +148,7 @@ void IrrDriver::UpdateSplitAndLightcoordRangeFromComputeShaders(size_t width, si
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, CBBssbo);
FullScreenShader::LightspaceBoundingBoxShader::getInstance()->use();
FullScreenShader::LightspaceBoundingBoxShader::getInstance()->SetTextureUnits(getDepthStencilTexture());
FullScreenShader::LightspaceBoundingBoxShader::getInstance()->setTextureUnits(getDepthStencilTexture());
FullScreenShader::LightspaceBoundingBoxShader::getInstance()->setUniforms(m_suncam->getViewMatrix(), shadowSplit[1], shadowSplit[2], shadowSplit[3], shadowSplit[4]);
glDispatchCompute((int)width / 64, (int)height / 64, 1);

View File

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

View File

@ -308,7 +308,7 @@ SetTexture(GLMesh &mesh, unsigned i, bool isSrgb, const std::string &matname)
if (CVS->isAZDOEnabled())
{
if (!mesh.TextureHandles[i])
mesh.TextureHandles[i] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[i]), MeshShader::ObjectPass1Shader::getInstance()->SamplersId[0]);
mesh.TextureHandles[i] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[i]), MeshShader::ObjectPass1Shader::getInstance()->m_sampler_ids[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[i]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[i]);
}
@ -381,7 +381,7 @@ void InitTexturesTransparent(GLMesh &mesh)
if (CVS->isAZDOEnabled())
{
if (!mesh.TextureHandles[0])
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::ObjectPass1Shader::getInstance()->SamplersId[0]);
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::ObjectPass1Shader::getInstance()->m_sampler_ids[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[0]);
}

View File

@ -288,13 +288,13 @@ void STKMeshSceneNode::render()
if (CVS->isAZDOEnabled())
{
if (!mesh.TextureHandles[0])
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::ObjectPass1Shader::getInstance()->SamplersId[0]);
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::ObjectPass1Shader::getInstance()->m_sampler_ids[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[0]);
MeshShader::ObjectPass1Shader::getInstance()->SetTextureHandles(mesh.TextureHandles[0]);
MeshShader::ObjectPass1Shader::getInstance()->setTextureHandles(mesh.TextureHandles[0]);
}
else
MeshShader::ObjectPass1Shader::getInstance()->SetTextureUnits(getTextureGLuint(mesh.textures[0]));
MeshShader::ObjectPass1Shader::getInstance()->setTextureUnits(getTextureGLuint(mesh.textures[0]));
MeshShader::ObjectPass1Shader::getInstance()->setUniforms(AbsoluteTransformation, invmodel);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
@ -325,30 +325,30 @@ void STKMeshSceneNode::render()
if (CVS->isAZDOEnabled())
{
GLuint64 DiffuseHandle = glGetTextureSamplerHandleARB(irr_driver->getRenderTargetTexture(RTT_DIFFUSE), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[0]);
GLuint64 DiffuseHandle = glGetTextureSamplerHandleARB(irr_driver->getRenderTargetTexture(RTT_DIFFUSE), MeshShader::ObjectPass2Shader::getInstance()->m_sampler_ids[0]);
if (!glIsTextureHandleResidentARB(DiffuseHandle))
glMakeTextureHandleResidentARB(DiffuseHandle);
GLuint64 SpecularHandle = glGetTextureSamplerHandleARB(irr_driver->getRenderTargetTexture(RTT_SPECULAR), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[1]);
GLuint64 SpecularHandle = glGetTextureSamplerHandleARB(irr_driver->getRenderTargetTexture(RTT_SPECULAR), MeshShader::ObjectPass2Shader::getInstance()->m_sampler_ids[1]);
if (!glIsTextureHandleResidentARB(SpecularHandle))
glMakeTextureHandleResidentARB(SpecularHandle);
GLuint64 SSAOHandle = glGetTextureSamplerHandleARB(irr_driver->getRenderTargetTexture(RTT_HALF1_R), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[2]);
GLuint64 SSAOHandle = glGetTextureSamplerHandleARB(irr_driver->getRenderTargetTexture(RTT_HALF1_R), MeshShader::ObjectPass2Shader::getInstance()->m_sampler_ids[2]);
if (!glIsTextureHandleResidentARB(SSAOHandle))
glMakeTextureHandleResidentARB(SSAOHandle);
if (!mesh.TextureHandles[0])
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[0]);
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::ObjectPass2Shader::getInstance()->m_sampler_ids[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[0]);
if (!mesh.TextureHandles[1])
mesh.TextureHandles[1] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[1]), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[0]);
mesh.TextureHandles[1] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[1]), MeshShader::ObjectPass2Shader::getInstance()->m_sampler_ids[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[1]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[1]);
MeshShader::ObjectPass2Shader::getInstance()->SetTextureHandles(DiffuseHandle, SpecularHandle, SSAOHandle, mesh.TextureHandles[0], mesh.TextureHandles[1]);
MeshShader::ObjectPass2Shader::getInstance()->setTextureHandles(DiffuseHandle, SpecularHandle, SSAOHandle, mesh.TextureHandles[0], mesh.TextureHandles[1]);
}
else
MeshShader::ObjectPass2Shader::getInstance()->SetTextureUnits(
MeshShader::ObjectPass2Shader::getInstance()->setTextureUnits(
irr_driver->getRenderTargetTexture(RTT_DIFFUSE),
irr_driver->getRenderTargetTexture(RTT_SPECULAR),
irr_driver->getRenderTargetTexture(RTT_HALF1_R),
@ -422,13 +422,13 @@ void STKMeshSceneNode::render()
if (CVS->isAZDOEnabled())
{
if (!mesh.TextureHandles[0])
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentFogShader::getInstance()->SamplersId[0]);
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentFogShader::getInstance()->m_sampler_ids[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[0]);
MeshShader::TransparentFogShader::getInstance()->SetTextureHandles(mesh.TextureHandles[0]);
MeshShader::TransparentFogShader::getInstance()->setTextureHandles(mesh.TextureHandles[0]);
}
else
MeshShader::TransparentFogShader::getInstance()->SetTextureUnits(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);
assert(mesh.vao);
@ -452,13 +452,13 @@ void STKMeshSceneNode::render()
if (CVS->isAZDOEnabled())
{
if (!mesh.TextureHandles[0])
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentShader::getInstance()->SamplersId[0]);
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentShader::getInstance()->m_sampler_ids[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[0]);
MeshShader::TransparentShader::getInstance()->SetTextureHandles(mesh.TextureHandles[0]);
MeshShader::TransparentShader::getInstance()->setTextureHandles(mesh.TextureHandles[0]);
}
else
MeshShader::TransparentShader::getInstance()->SetTextureUnits(getTextureGLuint(mesh.textures[0]));
MeshShader::TransparentShader::getInstance()->setTextureUnits(getTextureGLuint(mesh.textures[0]));
MeshShader::TransparentShader::getInstance()->setUniforms(AbsoluteTransformation, mesh.TextureMatrix);
assert(mesh.vao);

View File

@ -0,0 +1,160 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2014-2015 SuperTuxKart-Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_TEXTURE_READ_HPP
#define HEADER_TEXTURE_READ_HPP
#include "shaders_util.hpp"
template<SamplerType...tp>
class TextureRead
{
protected:
std::vector<GLuint> m_texture_units;
std::vector<GLenum> m_texture_type;
std::vector<GLenum> m_texture_location;
public:
std::vector<GLuint> m_sampler_ids;
// A variadic template to assign texture names
// ===========================================
private:
/** End of recursive variadic template AssigTextureNames. It just
* checks if the number of arguments is correct.*/
template<unsigned N, typename...Args>
void assignTextureNamesImpl(GLuint)
{
static_assert(N == sizeof...(tp), "Wrong number of texture name");
} // assignTextureNamesImpl
// ------------------------------------------------------------------------
/** Recursive implementation, peeling the texture unit and name off the
* list of arguments.
*/
template<unsigned N, typename...Args>
void assignTextureNamesImpl(GLuint program, GLuint tex_unit,
const char *name, Args...args)
{
GLuint location = glGetUniformLocation(program, name);
m_texture_location.push_back(location);
glUniform1i(location, tex_unit);
m_texture_units.push_back(tex_unit);
assignTextureNamesImpl<N + 1>(program, args...);
} // assignTextureNamesImpl
// ------------------------------------------------------------------------
protected:
/** The protected interface for setting sampler names - it is only called
* from instances.
*/
template<typename...Args>
void assignSamplerNames(GLuint program, Args...args)
{
CreateSamplers<tp...>::exec(m_sampler_ids, m_texture_type);
glUseProgram(program);
assignTextureNamesImpl<0>(program, args...);
glUseProgram(0);
} // AssignSamplerNames
// Variadic template implementation of setTextureUnits
// ===================================================
/** End of recursion, just check if number of arguments is correct. */
template<int N>
void setTextureUnitsImpl()
{
static_assert(N == sizeof...(tp), "Not enough texture set");
} // setTextureUnitsImpl
// ------------------------------------------------------------------------
/** The recursive implementation.
*/
template<int N, typename... TexIds>
void setTextureUnitsImpl(GLuint texid, TexIds... args)
{
setTextureSampler(m_texture_type[N], m_texture_units[N], texid,
m_sampler_ids[N]);
setTextureUnitsImpl<N + 1>(args...);
} // setTextureUnitsImpl
// ------------------------------------------------------------------------
public:
/** Public implementation of setTextureUnits.
*/
template<typename... TexIds>
void setTextureUnits(TexIds... args)
{
if (getGLSLVersion() >= 330)
setTextureUnitsImpl<0>(args...);
else
BindTexture<tp...>::template exec<0>(m_texture_units, args...);
} // SetTextureUnits
// ========================================================================
// Variadic template implementation of setTextureHandles.
/** End of recursion, just checks at compile time if number of arguments
* is correct.
* \param N number of arguments. */
template<int N>
void setTextureHandlesImpl()
{
static_assert(N == sizeof...(tp), "Not enough handle set");
} // setTextureHandlesImpl
// ------------------------------------------------------------------------
/** Recursive implementation of setTextureHandles.
* \param N The number of the current argument in the recursion (or the
* recursion depth).
* \param handle The texture handle to set.
*/
template<int N, typename... HandlesId>
void setTextureHandlesImpl(uint64_t handle, HandlesId... args)
{
if (handle)
glUniformHandleui64ARB(m_texture_location[N], handle);
setTextureHandlesImpl<N + 1>(args...);
} // setTextureHandlesImpl
// ------------------------------------------------------------------------
public:
/** The protected interface.
* \param ids The ids of all texture handls.
*/
template<typename... HandlesId>
void setTextureHandles(HandlesId... ids)
{
setTextureHandlesImpl<0>(ids...);
} // SetTextureHandles
public:
// ------------------------------------------------------------------------
/** Destructor which frees al lsampler ids.
*/
~TextureRead()
{
for (unsigned i = 0; i < m_sampler_ids.size(); i++)
glDeleteSamplers(1, &m_sampler_ids[i]);
} // ~TextureRead
}; // class TextureRead
#endif