From bd4fe57524936dc227e97e06bf8774fd120fe67c Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Tue, 11 Nov 2014 21:52:54 +0100 Subject: [PATCH] Use fog start value to determine density --- data/shaders/fog.frag | 8 ++------ src/graphics/post_processing.cpp | 2 +- src/graphics/shaders.cpp | 2 +- src/graphics/shaders.hpp | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/data/shaders/fog.frag b/data/shaders/fog.frag index 3b97ab40f..3560b0a69 100644 --- a/data/shaders/fog.frag +++ b/data/shaders/fog.frag @@ -1,10 +1,6 @@ uniform sampler2D tex; -uniform float fogmax; -uniform float startH; -uniform float endH; -uniform float start; -uniform float end; +uniform float density; uniform vec3 col; out vec4 FragColor; @@ -19,7 +15,7 @@ void main() vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix); float dist = length(xpos.xyz); - vec3 fog = col * (1. - exp(- fogmax * .01 * dist)); + vec3 fog = col * (1. - exp(- density * dist)); FragColor = vec4(fog, 1.); } diff --git a/src/graphics/post_processing.cpp b/src/graphics/post_processing.cpp index 8322ae814..60938906a 100644 --- a/src/graphics/post_processing.cpp +++ b/src/graphics/post_processing.cpp @@ -477,7 +477,7 @@ void PostProcessing::renderFog() FullScreenShader::FogShader::getInstance()->SetTextureUnits(irr_driver->getDepthStencilTexture()); - DrawFullScreenEffect(fogmax, startH, endH, start, end, col); + DrawFullScreenEffect(1. / (20. * start), col); glEnable(GL_DEPTH_TEST); glDisable(GL_BLEND); diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index 72b2b3576..14f2cf4cf 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -1842,7 +1842,7 @@ namespace FullScreenShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/fog.frag").c_str()); - AssignUniforms("fogmax", "startH", "endH", "start", "end", "col"); + AssignUniforms("density", "col"); AssignSamplerNames(Program, 0, "tex"); } diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp index f4fbd06f7..e6bb2e07f 100644 --- a/src/graphics/shaders.hpp +++ b/src/graphics/shaders.hpp @@ -537,7 +537,7 @@ public: SSAOShader(); }; -class FogShader : public ShaderHelperSingleton, public TextureRead +class FogShader : public ShaderHelperSingleton, public TextureRead { public: FogShader();