Change fog equation

This commit is contained in:
Vincent Lejeune 2014-11-10 22:08:12 +01:00
parent 85bbc0f8b8
commit 84affec451
3 changed files with 7 additions and 8 deletions

View File

@ -15,13 +15,11 @@ vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
void main()
{
vec2 uv = gl_FragCoord.xy / screen;
float z = texture(tex, uv).x;
vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix);
float z = texture(tex, uv).x;
vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix);
float dist = length(xpos.xyz);
float fog = smoothstep(start, end, dist);
float dist = length(xpos.xyz);
vec3 fog = col * (1. - exp(- fogmax * .01 * dist));
fog = min(fog, fogmax);
FragColor = vec4(col, fog);
FragColor = vec4(fog, 1.);
}

View File

@ -473,7 +473,7 @@ void PostProcessing::renderFog()
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendFunc(GL_ONE, GL_ONE);
FullScreenShader::FogShader::getInstance()->SetTextureUnits(irr_driver->getDepthStencilTexture());

View File

@ -538,6 +538,7 @@ void IrrDriver::renderSkybox(const scene::ICameraSceneNode *camera)
core::matrix4 transform = translate * scale;
core::matrix4 invtransform;
transform.getInverse(invtransform);
glDisable(GL_BLEND);
glUseProgram(MeshShader::SkyboxShader::getInstance()->Program);
MeshShader::SkyboxShader::getInstance()->setUniforms(transform);