Merge branch 'master' of github.com:supertuxkart/stk-code
This commit is contained in:
commit
de694cc5fe
@ -11,5 +11,6 @@ varying vec2 uv;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
FragColor = texture(tex, uv);
|
||||
vec4 color = texture(tex, uv);
|
||||
FragColor = vec4(color.rgb * color.a, color.a);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ varying vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = texture(tex, uv);
|
||||
FragColor.a *= transparency;
|
||||
vec4 Color = texture(tex, uv);
|
||||
Color.a *= transparency;
|
||||
FragColor = vec4(Color.rgb * Color.a, Color.a);
|
||||
}
|
||||
|
@ -13,11 +13,11 @@ void main() {
|
||||
/**
|
||||
* Luma calculation requires gamma-corrected colors:
|
||||
*/
|
||||
float L = dot(texture(colorMapG, uv).rgb, weights);
|
||||
float Lleft = dot(texture(colorMapG, offset[0].xy).rgb, weights);
|
||||
float Ltop = dot(texture(colorMapG, offset[0].zw).rgb, weights);
|
||||
float Lright = dot(texture(colorMapG, offset[1].xy).rgb, weights);
|
||||
float Lbottom = dot(texture(colorMapG, offset[1].zw).rgb, weights);
|
||||
float L = dot(pow(texture(colorMapG, uv).rgb, vec3(1./2.2)), weights);
|
||||
float Lleft = dot(pow(texture(colorMapG, offset[0].xy).rgb, vec3(1./2.2)), weights);
|
||||
float Ltop = dot(pow(texture(colorMapG, offset[0].zw).rgb, vec3(1./2.2)), weights);
|
||||
float Lright = dot(pow(texture(colorMapG, offset[1].xy).rgb, vec3(1./2.2)), weights);
|
||||
float Lbottom = dot(pow(texture(colorMapG, offset[1].zw).rgb, vec3(1./2.2)), weights);
|
||||
|
||||
vec4 delta = abs(vec4(L) - vec4(Lleft, Ltop, Lright, Lbottom));
|
||||
vec4 edges = step(vec4(threshold), delta);
|
||||
|
@ -26,16 +26,16 @@ void main() {
|
||||
vec4 color = vec4(0.0);
|
||||
|
||||
// Add the contributions of the possible 4 lines that can cross this pixel:
|
||||
vec4 C = texture(colorMap, uv);
|
||||
vec4 Cleft = texture(colorMap, offset[0].xy);
|
||||
vec4 Ctop = texture(colorMap, offset[0].zw);
|
||||
vec4 Cright = texture(colorMap, offset[1].xy);
|
||||
vec4 Cbottom = texture(colorMap, offset[1].zw);
|
||||
vec4 C = pow(texture(colorMap, uv), vec4(1./2.2));
|
||||
vec4 Cleft = pow(texture(colorMap, offset[0].xy), vec4(1./2.2));
|
||||
vec4 Ctop = pow(texture(colorMap, offset[0].zw), vec4(1./2.2));
|
||||
vec4 Cright = pow(texture(colorMap, offset[1].xy), vec4(1./2.2));
|
||||
vec4 Cbottom = pow(texture(colorMap, offset[1].zw), vec4(1./2.2));
|
||||
color = mix(C, Ctop, a.r) * w.r + color;
|
||||
color = mix(C, Cbottom, a.g) * w.g + color;
|
||||
color = mix(C, Cleft, a.b) * w.b + color;
|
||||
color = mix(C, Cright, a.a) * w.a + color;
|
||||
|
||||
// Normalize the resulting color and we are finished!
|
||||
FragColor = color / sum;
|
||||
FragColor = vec4(pow(color / sum, vec4(2.2)));
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ uniform vec2 screen;
|
||||
in float lf;
|
||||
in vec2 tc;
|
||||
in vec3 pc;
|
||||
out vec4 color;
|
||||
out vec4 FragColor;
|
||||
|
||||
|
||||
void main(void)
|
||||
@ -19,6 +19,7 @@ void main(void)
|
||||
vec4 EnvPos = invproj * (2. * vec4(xy, EnvZ, 1.0) - 1.);
|
||||
EnvPos /= EnvPos.w;
|
||||
float alpha = clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
|
||||
color = texture(tex, tc) * vec4(pc, 1.0);
|
||||
vec4 color = texture(tex, tc) * vec4(pc, 1.0);
|
||||
color.a *= alpha * smoothstep(1., 0.8, lf);
|
||||
FragColor = vec4(color.rgb * color.a, color.a);
|
||||
}
|
||||
|
@ -12,5 +12,7 @@ varying vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = texture(tex, uv) * color;
|
||||
vec4 Color = texture(tex, uv) * color;
|
||||
// Premultiply alpha
|
||||
FragColor = vec4(Color.rgb * Color.a, Color.a);
|
||||
}
|
||||
|
@ -34,5 +34,6 @@ void main()
|
||||
|
||||
fog = min(fog, fogmax);
|
||||
|
||||
FragColor = vec4(vec4(col, 0.) * fog + diffusecolor *(1. - fog));
|
||||
vec4 color = vec4(vec4(col, 0.) * fog + diffusecolor *(1. - fog));
|
||||
FragColor = vec4(color.rgb * color.a, color.a);
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ void ParticleSystemProxy::simulate()
|
||||
|
||||
void ParticleSystemProxy::drawFlip()
|
||||
{
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glUseProgram(ParticleShader::FlipParticleRender::Program);
|
||||
|
||||
float screen[2] = {
|
||||
@ -455,9 +455,9 @@ void ParticleSystemProxy::drawFlip()
|
||||
void ParticleSystemProxy::drawNotFlip()
|
||||
{
|
||||
if (m_alpha_additive)
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
else
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glUseProgram(ParticleShader::SimpleParticleRender::Program);
|
||||
|
||||
float screen[2] = {
|
||||
|
@ -222,6 +222,10 @@ private:
|
||||
|
||||
void renderFixed(float dt);
|
||||
void renderGLSL(float dt);
|
||||
void renderSolidFirstPass();
|
||||
void renderSolidSecondPass();
|
||||
void renderTransparent();
|
||||
void renderParticles();
|
||||
void renderShadows(//ShadowImportanceProvider * const sicb,
|
||||
scene::ICameraSceneNode * const camnode,
|
||||
//video::SOverrideMaterial &overridemat,
|
||||
|
@ -172,21 +172,10 @@ void IrrDriver::renderGLSL(float dt)
|
||||
}*/
|
||||
|
||||
// Fire up the MRT
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false);
|
||||
PROFILER_PUSH_CPU_MARKER("- Solid Pass 1", 0xFF, 0x00, 0x00);
|
||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID;
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_CULL_FACE);
|
||||
irr_driver->setPhase(SOLID_NORMAL_AND_DEPTH_PASS);
|
||||
m_scene_manager->drawAll(m_renderpass);
|
||||
irr_driver->setProjMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION));
|
||||
irr_driver->setViewMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW));
|
||||
irr_driver->genProjViewMatrix();
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
PROFILER_PUSH_CPU_MARKER("- Solid Pass 1", 0xFF, 0x00, 0x00);
|
||||
renderSolidFirstPass();
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
|
||||
// Todo : reenable glow and shadows
|
||||
//ShadowImportanceProvider * const sicb = (ShadowImportanceProvider *)
|
||||
@ -212,21 +201,7 @@ void IrrDriver::renderGLSL(float dt)
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Solid Pass 2", 0x00, 0x00, 0xFF);
|
||||
irr_driver->setPhase(SOLID_LIT_PASS);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID;
|
||||
setTexture(0, getTextureGLuint(irr_driver->getRTT(RTT_TMP1)), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(1, getTextureGLuint(irr_driver->getRTT(RTT_TMP2)), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(2, getTextureGLuint(irr_driver->getRTT(RTT_SSAO)), GL_NEAREST, GL_NEAREST);
|
||||
if (!UserConfigParams::m_ssao)
|
||||
{
|
||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ONE };
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
m_scene_manager->drawAll(m_renderpass);
|
||||
renderSolidSecondPass();
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
if (World::getWorld()->getTrack()->isFogEnabled())
|
||||
@ -284,25 +259,11 @@ void IrrDriver::renderGLSL(float dt)
|
||||
|
||||
// We need to re-render camera due to the per-cam-node hack.
|
||||
PROFILER_PUSH_CPU_MARKER("- Transparent Pass", 0xFF, 0x00, 0x00);
|
||||
irr_driver->setPhase(TRANSPARENT_PASS);
|
||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT;
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDisable(GL_CULL_FACE);
|
||||
m_scene_manager->drawAll(m_renderpass);
|
||||
renderTransparent();
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Particles", 0xFF, 0xFF, 0x00);
|
||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT_EFFECT;
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
m_scene_manager->drawAll(m_renderpass);
|
||||
renderParticles();
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Displacement", 0x00, 0x00, 0xFF);
|
||||
@ -445,6 +406,67 @@ void IrrDriver::renderFixed(float dt)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void IrrDriver::renderSolidFirstPass()
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false);
|
||||
|
||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID;
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_CULL_FACE);
|
||||
irr_driver->setPhase(SOLID_NORMAL_AND_DEPTH_PASS);
|
||||
m_scene_manager->drawAll(m_renderpass);
|
||||
irr_driver->setProjMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION));
|
||||
irr_driver->setViewMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW));
|
||||
irr_driver->genProjViewMatrix();
|
||||
}
|
||||
|
||||
void IrrDriver::renderSolidSecondPass()
|
||||
{
|
||||
irr_driver->setPhase(SOLID_LIT_PASS);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID;
|
||||
setTexture(0, getTextureGLuint(irr_driver->getRTT(RTT_TMP1)), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(1, getTextureGLuint(irr_driver->getRTT(RTT_TMP2)), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(2, getTextureGLuint(irr_driver->getRTT(RTT_SSAO)), GL_NEAREST, GL_NEAREST);
|
||||
if (!UserConfigParams::m_ssao)
|
||||
{
|
||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ONE };
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
m_scene_manager->drawAll(m_renderpass);
|
||||
}
|
||||
|
||||
void IrrDriver::renderTransparent()
|
||||
{
|
||||
irr_driver->setPhase(TRANSPARENT_PASS);
|
||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT;
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDisable(GL_CULL_FACE);
|
||||
m_scene_manager->drawAll(m_renderpass);
|
||||
}
|
||||
|
||||
void IrrDriver::renderParticles()
|
||||
{
|
||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT_EFFECT;
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
m_scene_manager->drawAll(m_renderpass);
|
||||
}
|
||||
|
||||
void IrrDriver::renderShadows(//ShadowImportanceProvider * const sicb,
|
||||
scene::ICameraSceneNode * const camnode,
|
||||
//video::SOverrideMaterial &overridemat,
|
||||
|
Loading…
Reference in New Issue
Block a user