Use fog start value to determine density

This commit is contained in:
Vincent Lejeune 2014-11-11 21:52:54 +01:00
parent 84affec451
commit bd4fe57524
4 changed files with 5 additions and 9 deletions

View File

@ -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.);
}

View File

@ -477,7 +477,7 @@ void PostProcessing::renderFog()
FullScreenShader::FogShader::getInstance()->SetTextureUnits(irr_driver->getDepthStencilTexture());
DrawFullScreenEffect<FullScreenShader::FogShader>(fogmax, startH, endH, start, end, col);
DrawFullScreenEffect<FullScreenShader::FogShader>(1. / (20. * start), col);
glEnable(GL_DEPTH_TEST);
glDisable(GL_BLEND);

View File

@ -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");
}

View File

@ -537,7 +537,7 @@ public:
SSAOShader();
};
class FogShader : public ShaderHelperSingleton<FogShader, float, float, float, float, float, core::vector3df>, public TextureRead<Nearest_Filtered>
class FogShader : public ShaderHelperSingleton<FogShader, float, core::vector3df>, public TextureRead<Nearest_Filtered>
{
public:
FogShader();