Remove a shader callback
This commit is contained in:
@@ -150,62 +150,6 @@ void MipVizProvider::OnSetConstants(IMaterialRendererServices *srv, int)
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
void SunLightProvider::OnSetConstants(IMaterialRendererServices *srv, int)
|
||||
{
|
||||
const int hasclouds = World::getWorld()->getTrack()->hasClouds() &&
|
||||
UserConfigParams::m_weather_effects;
|
||||
|
||||
srv->setVertexShaderConstant("screen", m_screen, 2);
|
||||
srv->setVertexShaderConstant("col", m_color, 3);
|
||||
srv->setVertexShaderConstant("center", m_pos, 3);
|
||||
srv->setVertexShaderConstant("invproj", irr_driver->getInvProjMatrix().pointer(), 16);
|
||||
srv->setVertexShaderConstant("hasclouds", &hasclouds, 1);
|
||||
|
||||
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
|
||||
|
||||
float strength = time;
|
||||
strength = fabsf(noise2d(strength / 10.0f)) * 0.003f;
|
||||
|
||||
const vector3df winddir = irr_driver->getWind() * strength;
|
||||
m_wind[0] += winddir.X;
|
||||
m_wind[1] += winddir.Z;
|
||||
srv->setVertexShaderConstant("wind", m_wind, 2);
|
||||
|
||||
if (UserConfigParams::m_shadows)
|
||||
{
|
||||
srv->setVertexShaderConstant("shadowmat", m_shadowmat.pointer(), 16);
|
||||
}
|
||||
|
||||
// Can't use the firstdone optimization, as this callback is used for multiple shaders
|
||||
//if (!firstdone)
|
||||
{
|
||||
int tex = 0;
|
||||
srv->setVertexShaderConstant("ntex", &tex, 1);
|
||||
|
||||
tex = 1;
|
||||
srv->setVertexShaderConstant("dtex", &tex, 1);
|
||||
|
||||
tex = 2;
|
||||
srv->setVertexShaderConstant("cloudtex", &tex, 1);
|
||||
|
||||
tex = 3;
|
||||
srv->setVertexShaderConstant("shadowtex", &tex, 1);
|
||||
|
||||
tex = 4;
|
||||
srv->setVertexShaderConstant("warpx", &tex, 1);
|
||||
|
||||
tex = 5;
|
||||
srv->setVertexShaderConstant("warpy", &tex, 1);
|
||||
|
||||
// const float shadowoffset = 1.0f / irr_driver->getRTT(RTT_SHADOW)->getSize().Width;
|
||||
// srv->setVertexShaderConstant("shadowoffset", &shadowoffset, 1);
|
||||
|
||||
firstdone = true;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
void DisplaceProvider::OnSetConstants(IMaterialRendererServices *srv, int)
|
||||
{
|
||||
|
||||
|
||||
@@ -211,75 +211,6 @@ public:
|
||||
|
||||
//
|
||||
|
||||
class SunLightProvider: public CallBase
|
||||
{
|
||||
public:
|
||||
SunLightProvider()
|
||||
{
|
||||
m_screen[0] = (float)UserConfigParams::m_width;
|
||||
m_screen[1] = (float)UserConfigParams::m_height;
|
||||
|
||||
m_wind[0] = m_wind[1] = 0;
|
||||
}
|
||||
|
||||
virtual void OnSetConstants(video::IMaterialRendererServices *srv, int);
|
||||
|
||||
void setColor(float r, float g, float b)
|
||||
{
|
||||
m_color[0] = r;
|
||||
m_color[1] = g;
|
||||
m_color[2] = b;
|
||||
}
|
||||
|
||||
float getRed() const
|
||||
{
|
||||
return m_color[0];
|
||||
}
|
||||
|
||||
float getGreen() const
|
||||
{
|
||||
return m_color[1];
|
||||
}
|
||||
|
||||
float getBlue() const
|
||||
{
|
||||
return m_color[2];
|
||||
}
|
||||
|
||||
void setPosition(float x, float y, float z)
|
||||
{
|
||||
// Sun "position" is actually a direction and not a position
|
||||
core::matrix4 m_view = irr_driver->getViewMatrix();
|
||||
m_view.makeInverse();
|
||||
m_view = m_view.getTransposed();
|
||||
core::vector3df pos(x, y, z);
|
||||
m_view.transformVect(pos);
|
||||
pos.normalize();
|
||||
m_pos[0] = pos.X;
|
||||
m_pos[1] = pos.Y;
|
||||
m_pos[2] = pos.Z;
|
||||
}
|
||||
|
||||
core::vector3df getPosition() const
|
||||
{
|
||||
return core::vector3df(m_pos[0], m_pos[1], m_pos[2]);
|
||||
}
|
||||
|
||||
void setShadowMatrix(const core::matrix4 &mat)
|
||||
{
|
||||
m_shadowmat = mat;
|
||||
}
|
||||
|
||||
private:
|
||||
core::matrix4 m_shadowmat;
|
||||
float m_color[3];
|
||||
float m_pos[3];
|
||||
float m_screen[2];
|
||||
float m_wind[2];
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
class DisplaceProvider: public CallBase
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -380,6 +380,8 @@ private:
|
||||
class STKMeshSceneNode *m_sun_interposer;
|
||||
scene::CLensFlareSceneNode *m_lensflare;
|
||||
scene::ICameraSceneNode *m_suncam;
|
||||
core::vector3df m_sundirection;
|
||||
video::SColorf m_suncolor;
|
||||
std::pair<float, float> m_shadow_scales[4];
|
||||
scene::ICameraSceneNode *m_shadow_camnodes[4];
|
||||
float m_shadows_cam[4][24];
|
||||
@@ -619,6 +621,25 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
inline core::vector3df getWind() {return m_wind->getWind();}
|
||||
// -----------------------------------------------------------------------
|
||||
core::vector3df getSunDirection() const { return m_sundirection; };
|
||||
// -----------------------------------------------------------------------
|
||||
void setSunDirection(const core::vector3df &SunPos)
|
||||
{
|
||||
core::matrix4 m_view = getViewMatrix();
|
||||
m_view.makeInverse();
|
||||
m_view = m_view.getTransposed();
|
||||
m_sundirection = SunPos;
|
||||
m_view.transformVect(m_sundirection);
|
||||
m_sundirection.normalize();
|
||||
}
|
||||
// -----------------------------------------------------------------------
|
||||
video::SColorf getSunColor() const { return m_suncolor; }
|
||||
// -----------------------------------------------------------------------
|
||||
void setSunColor(const video::SColorf &col)
|
||||
{
|
||||
m_suncolor = col;
|
||||
}
|
||||
// -----------------------------------------------------------------------
|
||||
inline video::E_MATERIAL_TYPE getShader(const ShaderType num) {return m_shaders->getShader(num);}
|
||||
// -----------------------------------------------------------------------
|
||||
inline void updateShaders() {m_shaders->killShaders();}
|
||||
|
||||
@@ -644,14 +644,13 @@ void IrrDriver::renderSolidSecondPass()
|
||||
|
||||
// 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());
|
||||
GrassMat::InstancedSecondPassShader::getInstance()->setUniforms(windDir, irr_driver->getSunDirection());
|
||||
glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT,
|
||||
(const void*)(SolidPassCmd::getInstance()->Offset[GrassMat::MaterialType] * sizeof(DrawElementsIndirectCommand)),
|
||||
(int)SolidPassCmd::getInstance()->Size[GrassMat::MaterialType],
|
||||
@@ -670,7 +669,6 @@ void IrrDriver::renderSolidSecondPass()
|
||||
|
||||
// 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));
|
||||
@@ -678,7 +676,7 @@ void IrrDriver::renderSolidSecondPass()
|
||||
{
|
||||
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());
|
||||
GrassMat::InstancedSecondPassShader::getInstance()->setUniforms(windDir, irr_driver->getSunDirection());
|
||||
glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (const void*)((SolidPassCmd::getInstance()->Offset[GrassMat::MaterialType] + i) * sizeof(DrawElementsIndirectCommand)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,6 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
|
||||
glDisable(GL_BLEND);
|
||||
m_rtts->getRH().Bind();
|
||||
glBindVertexArray(SharedObject::FullScreenQuadVAO);
|
||||
SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT);
|
||||
if (irr_driver->needRHWorkaround())
|
||||
{
|
||||
glUseProgram(FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->Program);
|
||||
@@ -123,7 +122,7 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
|
||||
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, video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->setUniforms(rsm_matrix, rh_matrix, rh_extend, i, irr_driver->getSunColor());
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
}
|
||||
@@ -135,7 +134,7 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
|
||||
m_rtts->getRSM().getRTT()[1],
|
||||
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, irr_driver->getSunColor());
|
||||
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, 32);
|
||||
}
|
||||
}
|
||||
@@ -162,13 +161,11 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
|
||||
// Render sunlight if and only if track supports shadow
|
||||
if (!World::getWorld() || World::getWorld()->getTrack()->hasShadows())
|
||||
{
|
||||
SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT);
|
||||
const video::SColorf &col = video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue());
|
||||
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_SUN));
|
||||
if (World::getWorld() && UserConfigParams::m_shadows && !irr_driver->needUBOWorkaround() && hasShadow)
|
||||
m_post_processing->renderShadowedSunlight(cb->getPosition(), col, sun_ortho_matrix, m_rtts->getShadowFBO().getRTT()[0]);
|
||||
m_post_processing->renderShadowedSunlight(irr_driver->getSunDirection(), irr_driver->getSunColor(), sun_ortho_matrix, m_rtts->getShadowFBO().getRTT()[0]);
|
||||
else
|
||||
m_post_processing->renderSunlight(cb->getPosition(), col);
|
||||
m_post_processing->renderSunlight(irr_driver->getSunDirection(), irr_driver->getSunColor());
|
||||
}
|
||||
{
|
||||
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_POINTLIGHTS));
|
||||
|
||||
@@ -114,7 +114,6 @@ Shaders::Shaders()
|
||||
m_callbacks[ES_GRASS] = new GrassShaderProvider();
|
||||
m_callbacks[ES_MOTIONBLUR] = new MotionBlurProvider();
|
||||
m_callbacks[ES_MIPVIZ] = new MipVizProvider();
|
||||
m_callbacks[ES_SUNLIGHT] = new SunLightProvider();
|
||||
m_callbacks[ES_DISPLACE] = new DisplaceProvider();
|
||||
|
||||
for (s32 i = 0; i < ES_COUNT; i++)
|
||||
@@ -500,8 +499,6 @@ void Shaders::loadShaders()
|
||||
m_shaders[ES_OBJECTPASS_REF] = glsl_noinput(dir + "pass.vert", dir + "pass.frag");
|
||||
m_shaders[ES_OBJECTPASS_RIMLIT] = glsl_noinput(dir + "pass.vert", dir + "pass.frag");
|
||||
|
||||
m_shaders[ES_SUNLIGHT] = glsl_noinput(dir + "pass.vert", dir + "pass.frag");
|
||||
|
||||
m_shaders[ES_DISPLACE] = glslmat(dir + "pass.vert", dir + "pass.frag",
|
||||
m_callbacks[ES_DISPLACE], EMT_TRANSPARENT_ALPHA_CHANNEL);
|
||||
|
||||
|
||||
@@ -694,7 +694,6 @@ public:
|
||||
ACT(ES_OBJECT_UNLIT) \
|
||||
ACT(ES_OBJECTPASS) \
|
||||
ACT(ES_OBJECTPASS_REF) \
|
||||
ACT(ES_SUNLIGHT) \
|
||||
ACT(ES_OBJECTPASS_RIMLIT) \
|
||||
ACT(ES_DISPLACE) \
|
||||
ACT(ES_PASSFAR) \
|
||||
|
||||
@@ -49,11 +49,10 @@ SunNode::~SunNode()
|
||||
|
||||
void SunNode::render()
|
||||
{
|
||||
SunLightProvider * const cb = (SunLightProvider *) irr_driver->getCallback(ES_SUNLIGHT);
|
||||
cb->setColor(m_color[0], m_color[1], m_color[2]);
|
||||
irr_driver->setSunColor(video::SColorf(m_color[0], m_color[1], m_color[2]));
|
||||
|
||||
vector3df pos = getPosition();
|
||||
cb->setPosition(pos.X, pos.Y, pos.Z);
|
||||
irr_driver->setSunDirection(pos);
|
||||
return;
|
||||
|
||||
/* array<IRenderTarget> mrt;
|
||||
|
||||
Reference in New Issue
Block a user