mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 05:23:51 +00:00
Merge pull request #2799 from Capostrophic/simplewaterfog
Fix simple water with radial fog enabled
This commit is contained in:
commit
aaa8990006
2 changed files with 10 additions and 1 deletions
|
@ -82,6 +82,9 @@ namespace SceneUtil
|
||||||
|
|
||||||
stateset->setRenderBinDetails(renderBin, "RenderBin");
|
stateset->setRenderBinDetails(renderBin, "RenderBin");
|
||||||
|
|
||||||
|
// Let the shader know we're dealing with simple water here.
|
||||||
|
stateset->addUniform(new osg::Uniform("simpleWater", true));
|
||||||
|
|
||||||
return stateset;
|
return stateset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,8 @@ uniform vec2 envMapLumaBias;
|
||||||
uniform mat2 bumpMapMatrix;
|
uniform mat2 bumpMapMatrix;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uniform bool simpleWater = false;
|
||||||
|
|
||||||
varying float euclideanDepth;
|
varying float euclideanDepth;
|
||||||
varying float linearDepth;
|
varying float linearDepth;
|
||||||
|
|
||||||
|
@ -180,7 +182,11 @@ void main()
|
||||||
|
|
||||||
gl_FragData[0].xyz += getSpecular(normalize(viewNormal), normalize(passViewPos.xyz), shininess, matSpec) * shadowing;
|
gl_FragData[0].xyz += getSpecular(normalize(viewNormal), normalize(passViewPos.xyz), shininess, matSpec) * shadowing;
|
||||||
#if @radialFog
|
#if @radialFog
|
||||||
float fogValue = clamp((euclideanDepth - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0);
|
float depth = euclideanDepth;
|
||||||
|
// For the less detailed mesh of simple water we need to recalculate depth on per-pixel basis
|
||||||
|
if (simpleWater)
|
||||||
|
depth = length(passViewPos);
|
||||||
|
float fogValue = clamp((depth - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
float fogValue = clamp((linearDepth - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0);
|
float fogValue = clamp((linearDepth - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue