Moved more shaders.
This commit is contained in:
parent
b40f84e89d
commit
283a7c58b9
@ -351,6 +351,47 @@ public:
|
||||
} // DegradedIBLShader
|
||||
}; // DegradedIBLShader
|
||||
|
||||
// ============================================================================
|
||||
class RHDebug : public Shader<RHDebug, core::matrix4, core::vector3df>
|
||||
{
|
||||
public:
|
||||
GLuint m_tu_shr, m_tu_shg, m_tu_shb;
|
||||
|
||||
RHDebug()
|
||||
{
|
||||
loadProgram(OBJECT, GL_VERTEX_SHADER, "rhdebug.vert",
|
||||
GL_FRAGMENT_SHADER, "rhdebug.frag");
|
||||
assignUniforms("RHMatrix", "extents");
|
||||
m_tu_shr = 0;
|
||||
m_tu_shg = 1;
|
||||
m_tu_shb = 2;
|
||||
assignTextureUnit(m_tu_shr, "SHR", m_tu_shg, "SHG",
|
||||
m_tu_shb, "SHB");
|
||||
} // RHDebug
|
||||
}; // RHDebug
|
||||
|
||||
// ============================================================================
|
||||
class GlobalIlluminationReconstructionShader
|
||||
: public TextureShader<GlobalIlluminationReconstructionShader, 5,
|
||||
core::matrix4, core::matrix4, core::vector3df >
|
||||
{
|
||||
public:
|
||||
GlobalIlluminationReconstructionShader()
|
||||
{
|
||||
loadProgram(OBJECT, GL_VERTEX_SHADER, "screenquad.vert",
|
||||
GL_FRAGMENT_SHADER, "utils/decodeNormal.frag",
|
||||
GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag",
|
||||
GL_FRAGMENT_SHADER, "gi.frag");
|
||||
|
||||
assignUniforms("RHMatrix", "InvRHMatrix", "extents");
|
||||
assignSamplerNames(0, "ntex", ST_NEAREST_FILTERED,
|
||||
1, "dtex", ST_NEAREST_FILTERED,
|
||||
2, "SHR", ST_VOLUME_LINEAR_FILTERED,
|
||||
3, "SHG", ST_VOLUME_LINEAR_FILTERED,
|
||||
4, "SHB", ST_VOLUME_LINEAR_FILTERED);
|
||||
} // GlobalIlluminationReconstructionShader
|
||||
}; // GlobalIlluminationReconstructionShader
|
||||
|
||||
// ============================================================================
|
||||
|
||||
PostProcessing::PostProcessing(IVideoDriver* video_driver)
|
||||
@ -571,14 +612,14 @@ void PostProcessing::renderRHDebug(unsigned SHR, unsigned SHG, unsigned SHB,
|
||||
const core::vector3df &rh_extend)
|
||||
{
|
||||
glEnable(GL_PROGRAM_POINT_SIZE);
|
||||
FullScreenShader::RHDebug::getInstance()->use();
|
||||
glActiveTexture(GL_TEXTURE0 + FullScreenShader::RHDebug::getInstance()->TU_SHR);
|
||||
RHDebug::getInstance()->use();
|
||||
glActiveTexture(GL_TEXTURE0 + RHDebug::getInstance()->m_tu_shr);
|
||||
glBindTexture(GL_TEXTURE_3D, SHR);
|
||||
glActiveTexture(GL_TEXTURE0 + FullScreenShader::RHDebug::getInstance()->TU_SHG);
|
||||
glActiveTexture(GL_TEXTURE0 + RHDebug::getInstance()->m_tu_shg);
|
||||
glBindTexture(GL_TEXTURE_3D, SHG);
|
||||
glActiveTexture(GL_TEXTURE0 + FullScreenShader::RHDebug::getInstance()->TU_SHB);
|
||||
glActiveTexture(GL_TEXTURE0 + RHDebug::getInstance()->m_tu_shb);
|
||||
glBindTexture(GL_TEXTURE_3D, SHB);
|
||||
FullScreenShader::RHDebug::getInstance()->setUniforms(rh_matrix, rh_extend);
|
||||
RHDebug::getInstance()->setUniforms(rh_matrix, rh_extend);
|
||||
glDrawArrays(GL_POINTS, 0, 32 * 16 * 32);
|
||||
glDisable(GL_PROGRAM_POINT_SIZE);
|
||||
} // renderRHDebug
|
||||
@ -591,10 +632,10 @@ void PostProcessing::renderGI(const core::matrix4 &RHMatrix,
|
||||
core::matrix4 InvRHMatrix;
|
||||
RHMatrix.getInverse(InvRHMatrix);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
FullScreenShader::GlobalIlluminationReconstructionShader::getInstance()
|
||||
GlobalIlluminationReconstructionShader::getInstance()
|
||||
->setTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH),
|
||||
irr_driver->getDepthStencilTexture(), shr, shg, shb);
|
||||
DrawFullScreenEffect<FullScreenShader::GlobalIlluminationReconstructionShader>
|
||||
DrawFullScreenEffect<GlobalIlluminationReconstructionShader>
|
||||
(RHMatrix, InvRHMatrix, rh_extend);
|
||||
} // renderGI
|
||||
|
||||
|
@ -185,6 +185,80 @@ public:
|
||||
} // ShadowedSunLightShaderPCF
|
||||
}; // ShadowedSunLightShaderPCF
|
||||
|
||||
// ============================================================================
|
||||
class ShadowedSunLightShaderESM : public TextureShader<ShadowedSunLightShaderESM,
|
||||
3, float, float, float,
|
||||
float>
|
||||
{
|
||||
public:
|
||||
ShadowedSunLightShaderESM()
|
||||
{
|
||||
loadProgram(OBJECT, GL_VERTEX_SHADER, "screenquad.vert",
|
||||
GL_FRAGMENT_SHADER, "utils/decodeNormal.frag",
|
||||
GL_FRAGMENT_SHADER, "utils/SpecularBRDF.frag",
|
||||
GL_FRAGMENT_SHADER, "utils/DiffuseBRDF.frag",
|
||||
GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag",
|
||||
GL_FRAGMENT_SHADER, "utils/SunMRP.frag",
|
||||
GL_FRAGMENT_SHADER, "sunlightshadowesm.frag");
|
||||
|
||||
// Use 8 to circumvent a catalyst bug when binding sampler
|
||||
assignSamplerNames(0, "ntex", ST_NEAREST_FILTERED,
|
||||
1, "dtex", ST_NEAREST_FILTERED,
|
||||
8, "shadowtex", ST_TRILINEAR_CLAMPED_ARRAY2D);
|
||||
|
||||
assignUniforms("split0", "split1", "split2", "splitmax");
|
||||
} // ShadowedSunLightShaderESM
|
||||
}; // ShadowedSunLightShaderESM
|
||||
|
||||
// ============================================================================
|
||||
class RadianceHintsConstructionShader
|
||||
: public TextureShader<RadianceHintsConstructionShader, 3, core::matrix4,
|
||||
core::matrix4, core::vector3df, video::SColorf>
|
||||
{
|
||||
public:
|
||||
RadianceHintsConstructionShader()
|
||||
{
|
||||
if (CVS->isAMDVertexShaderLayerUsable())
|
||||
{
|
||||
loadProgram(OBJECT, GL_VERTEX_SHADER, "slicedscreenquad.vert",
|
||||
GL_FRAGMENT_SHADER, "rh.frag");
|
||||
}
|
||||
else
|
||||
{
|
||||
loadProgram(OBJECT, GL_VERTEX_SHADER, "slicedscreenquad.vert",
|
||||
GL_GEOMETRY_SHADER, "rhpassthrough.geom",
|
||||
GL_FRAGMENT_SHADER, "rh.frag");
|
||||
}
|
||||
|
||||
assignUniforms("RSMMatrix", "RHMatrix", "extents", "suncol");
|
||||
assignSamplerNames(0, "ctex", ST_BILINEAR_FILTERED,
|
||||
1, "ntex", ST_BILINEAR_FILTERED,
|
||||
2, "dtex", ST_BILINEAR_FILTERED);
|
||||
} // RadianceHintsConstructionShader
|
||||
}; // RadianceHintsConstructionShader
|
||||
|
||||
// ============================================================================
|
||||
// Workaround for a bug found in kepler nvidia linux and fermi nvidia windows
|
||||
class NVWorkaroundRadianceHintsConstructionShader
|
||||
: public TextureShader<NVWorkaroundRadianceHintsConstructionShader,
|
||||
3, core::matrix4, core::matrix4, core::vector3df,
|
||||
int, video::SColorf >
|
||||
{
|
||||
public:
|
||||
NVWorkaroundRadianceHintsConstructionShader()
|
||||
{
|
||||
loadProgram(OBJECT,GL_VERTEX_SHADER,"slicedscreenquad_nvworkaround.vert",
|
||||
GL_GEOMETRY_SHADER, "rhpassthrough.geom",
|
||||
GL_FRAGMENT_SHADER, "rh.frag");
|
||||
|
||||
assignUniforms("RSMMatrix", "RHMatrix", "extents", "slice", "suncol");
|
||||
|
||||
assignSamplerNames(0, "ctex", ST_BILINEAR_FILTERED,
|
||||
1, "ntex", ST_BILINEAR_FILTERED,
|
||||
2, "dtex", ST_BILINEAR_FILTERED);
|
||||
} // NVWorkaroundRadianceHintsConstructionShader
|
||||
}; // NVWorkaroundRadianceHintsConstructionShader
|
||||
|
||||
// ============================================================================
|
||||
static void renderPointLights(unsigned count)
|
||||
{
|
||||
@ -321,32 +395,31 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
|
||||
glBindVertexArray(SharedGPUObjects::getFullScreenQuadVAO());
|
||||
if (CVS->needRHWorkaround())
|
||||
{
|
||||
FullScreenShader::NVWorkaroundRadianceHintsConstructionShader
|
||||
::getInstance()->use();
|
||||
FullScreenShader::NVWorkaroundRadianceHintsConstructionShader
|
||||
::getInstance()->setTextureUnits(
|
||||
m_rtts->getRSM().getRTT()[0],
|
||||
m_rtts->getRSM().getRTT()[1],
|
||||
m_rtts->getRSM().getDepthTexture());
|
||||
NVWorkaroundRadianceHintsConstructionShader::getInstance()->use();
|
||||
NVWorkaroundRadianceHintsConstructionShader::getInstance()
|
||||
->setTextureUnits(
|
||||
m_rtts->getRSM().getRTT()[0],
|
||||
m_rtts->getRSM().getRTT()[1],
|
||||
m_rtts->getRSM().getDepthTexture());
|
||||
for (unsigned i = 0; i < 32; i++)
|
||||
{
|
||||
FullScreenShader::NVWorkaroundRadianceHintsConstructionShader
|
||||
::getInstance()->setUniforms(rsm_matrix, rh_matrix,
|
||||
rh_extend, i,
|
||||
irr_driver->getSunColor());
|
||||
NVWorkaroundRadianceHintsConstructionShader::getInstance()
|
||||
->setUniforms(rsm_matrix, rh_matrix,
|
||||
rh_extend, i,
|
||||
irr_driver->getSunColor());
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FullScreenShader::RadianceHintsConstructionShader::getInstance()->use();
|
||||
FullScreenShader::RadianceHintsConstructionShader::getInstance()
|
||||
RadianceHintsConstructionShader::getInstance()->use();
|
||||
RadianceHintsConstructionShader::getInstance()
|
||||
->setTextureUnits(
|
||||
m_rtts->getRSM().getRTT()[0],
|
||||
m_rtts->getRSM().getRTT()[1],
|
||||
m_rtts->getRSM().getDepthTexture()
|
||||
);
|
||||
FullScreenShader::RadianceHintsConstructionShader::getInstance()
|
||||
RadianceHintsConstructionShader::getInstance()
|
||||
->setUniforms(rsm_matrix, rh_matrix, rh_extend,
|
||||
irr_driver->getSunColor());
|
||||
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, 32);
|
||||
@ -389,14 +462,15 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
|
||||
|
||||
if (CVS->isESMEnabled())
|
||||
{
|
||||
FullScreenShader::ShadowedSunLightShaderESM::getInstance()
|
||||
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]);
|
||||
DrawFullScreenEffect<ShadowedSunLightShaderESM>(shadowSplit[1],
|
||||
shadowSplit[2],
|
||||
shadowSplit[3],
|
||||
shadowSplit[4]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -481,88 +481,6 @@ namespace FullScreenShader
|
||||
|
||||
|
||||
|
||||
ShadowedSunLightShaderESM::ShadowedSunLightShaderESM()
|
||||
{
|
||||
loadProgram(OBJECT,
|
||||
GL_VERTEX_SHADER, "screenquad.vert",
|
||||
GL_FRAGMENT_SHADER, "utils/decodeNormal.frag",
|
||||
GL_FRAGMENT_SHADER, "utils/SpecularBRDF.frag",
|
||||
GL_FRAGMENT_SHADER, "utils/DiffuseBRDF.frag",
|
||||
GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag",
|
||||
GL_FRAGMENT_SHADER, "utils/SunMRP.frag",
|
||||
GL_FRAGMENT_SHADER, "sunlightshadowesm.frag");
|
||||
|
||||
// Use 8 to circumvent a catalyst bug when binding sampler
|
||||
assignSamplerNames(0, "ntex", ST_NEAREST_FILTERED,
|
||||
1, "dtex", ST_NEAREST_FILTERED,
|
||||
8, "shadowtex", ST_TRILINEAR_CLAMPED_ARRAY2D);
|
||||
|
||||
assignUniforms("split0", "split1", "split2", "splitmax");
|
||||
}
|
||||
|
||||
RadianceHintsConstructionShader::RadianceHintsConstructionShader()
|
||||
{
|
||||
if (CVS->isAMDVertexShaderLayerUsable())
|
||||
{
|
||||
loadProgram(OBJECT,
|
||||
GL_VERTEX_SHADER, "slicedscreenquad.vert",
|
||||
GL_FRAGMENT_SHADER, "rh.frag");
|
||||
}
|
||||
else
|
||||
{
|
||||
loadProgram(OBJECT,
|
||||
GL_VERTEX_SHADER, "slicedscreenquad.vert",
|
||||
GL_GEOMETRY_SHADER, "rhpassthrough.geom",
|
||||
GL_FRAGMENT_SHADER, "rh.frag");
|
||||
}
|
||||
|
||||
assignUniforms("RSMMatrix", "RHMatrix", "extents", "suncol");
|
||||
assignSamplerNames(0, "ctex", ST_BILINEAR_FILTERED,
|
||||
1, "ntex", ST_BILINEAR_FILTERED,
|
||||
2, "dtex", ST_BILINEAR_FILTERED);
|
||||
}
|
||||
|
||||
NVWorkaroundRadianceHintsConstructionShader::NVWorkaroundRadianceHintsConstructionShader()
|
||||
{
|
||||
loadProgram(OBJECT,
|
||||
GL_VERTEX_SHADER, "slicedscreenquad_nvworkaround.vert",
|
||||
GL_GEOMETRY_SHADER, "rhpassthrough.geom",
|
||||
GL_FRAGMENT_SHADER, "rh.frag");
|
||||
|
||||
assignUniforms("RSMMatrix", "RHMatrix", "extents", "slice", "suncol");
|
||||
|
||||
assignSamplerNames(0, "ctex", ST_BILINEAR_FILTERED,
|
||||
1, "ntex", ST_BILINEAR_FILTERED,
|
||||
2, "dtex", ST_BILINEAR_FILTERED);
|
||||
}
|
||||
|
||||
RHDebug::RHDebug()
|
||||
{
|
||||
loadProgram(OBJECT,
|
||||
GL_VERTEX_SHADER, "rhdebug.vert",
|
||||
GL_FRAGMENT_SHADER, "rhdebug.frag");
|
||||
assignUniforms("RHMatrix", "extents");
|
||||
TU_SHR = 0;
|
||||
TU_SHG = 1;
|
||||
TU_SHB = 2;
|
||||
assignTextureUnit(TU_SHR, "SHR", TU_SHG, "SHG", TU_SHB, "SHB");
|
||||
}
|
||||
|
||||
GlobalIlluminationReconstructionShader::GlobalIlluminationReconstructionShader()
|
||||
{
|
||||
loadProgram(OBJECT,
|
||||
GL_VERTEX_SHADER, "screenquad.vert",
|
||||
GL_FRAGMENT_SHADER, "utils/decodeNormal.frag",
|
||||
GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag",
|
||||
GL_FRAGMENT_SHADER, "gi.frag");
|
||||
|
||||
assignUniforms("RHMatrix", "InvRHMatrix", "extents");
|
||||
assignSamplerNames(0, "ntex", ST_NEAREST_FILTERED,
|
||||
1, "dtex", ST_NEAREST_FILTERED,
|
||||
2, "SHR", ST_VOLUME_LINEAR_FILTERED,
|
||||
3, "SHG", ST_VOLUME_LINEAR_FILTERED,
|
||||
4, "SHB", ST_VOLUME_LINEAR_FILTERED);
|
||||
}
|
||||
|
||||
HorizontalBlurShader::HorizontalBlurShader()
|
||||
{
|
||||
|
@ -88,43 +88,6 @@ public:
|
||||
SunLightShader();
|
||||
};
|
||||
|
||||
class ShadowedSunLightShaderESM : public TextureShader<ShadowedSunLightShaderESM, 3, float, float, float, float>
|
||||
{
|
||||
public:
|
||||
ShadowedSunLightShaderESM();
|
||||
};
|
||||
|
||||
class RadianceHintsConstructionShader : public TextureShader<RadianceHintsConstructionShader, 3, core::matrix4,
|
||||
core::matrix4, core::vector3df, video::SColorf>
|
||||
{
|
||||
public:
|
||||
RadianceHintsConstructionShader();
|
||||
};
|
||||
|
||||
// Workaround for a bug found in kepler nvidia linux and fermi nvidia windows
|
||||
class NVWorkaroundRadianceHintsConstructionShader : public TextureShader<NVWorkaroundRadianceHintsConstructionShader,
|
||||
3, core::matrix4, core::matrix4, core::vector3df,
|
||||
int, video::SColorf>
|
||||
{
|
||||
public:
|
||||
NVWorkaroundRadianceHintsConstructionShader();
|
||||
};
|
||||
|
||||
class RHDebug : public Shader<RHDebug, core::matrix4, core::vector3df>
|
||||
{
|
||||
public:
|
||||
GLuint TU_SHR, TU_SHG, TU_SHB;
|
||||
|
||||
RHDebug();
|
||||
};
|
||||
|
||||
class GlobalIlluminationReconstructionShader : public TextureShader<GlobalIlluminationReconstructionShader, 5,
|
||||
core::matrix4, core::matrix4, core::vector3df>
|
||||
{
|
||||
public:
|
||||
GlobalIlluminationReconstructionShader();
|
||||
};
|
||||
|
||||
class HorizontalBlurShader : public TextureShader<HorizontalBlurShader, 1, core::vector2df>
|
||||
{
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user