mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-14 06:20:26 +01:00
9954667c45
The exact commands to make this commit were: git reset --hard origin/master find -type f | # list all regular files grep -E '\.(h|cpp|fsh|vsh|mm)|LICENSE$' | # filter for text files xargs -n 1 -P $(nproc) sed -i 's:\s*$::' # for each file, trim trailing whitespace including the CR git commit -a
68 lines
1.2 KiB
GLSL
68 lines
1.2 KiB
GLSL
precision mediump float;
|
|
|
|
/* Uniforms */
|
|
|
|
uniform float uAlphaRef;
|
|
uniform int uTextureUsage0;
|
|
uniform sampler2D uTextureUnit0;
|
|
uniform int uFogEnable;
|
|
uniform int uFogType;
|
|
uniform vec4 uFogColor;
|
|
uniform float uFogStart;
|
|
uniform float uFogEnd;
|
|
uniform float uFogDensity;
|
|
|
|
/* Varyings */
|
|
|
|
varying vec2 vTextureCoord0;
|
|
varying vec4 vVertexColor;
|
|
varying vec4 vSpecularColor;
|
|
varying float vFogCoord;
|
|
|
|
float computeFog()
|
|
{
|
|
const float LOG2 = 1.442695;
|
|
float FogFactor = 0.0;
|
|
|
|
if (uFogType == 0) // Exp
|
|
{
|
|
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
|
|
}
|
|
else if (uFogType == 1) // Linear
|
|
{
|
|
float Scale = 1.0 / (uFogEnd - uFogStart);
|
|
FogFactor = (uFogEnd - vFogCoord) * Scale;
|
|
}
|
|
else if (uFogType == 2) // Exp2
|
|
{
|
|
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
|
|
}
|
|
|
|
FogFactor = clamp(FogFactor, 0.0, 1.0);
|
|
|
|
return FogFactor;
|
|
}
|
|
|
|
void main()
|
|
{
|
|
vec4 Color = vVertexColor;
|
|
|
|
if (bool(uTextureUsage0))
|
|
Color *= texture2D(uTextureUnit0, vTextureCoord0);
|
|
|
|
if (Color.a < uAlphaRef)
|
|
discard;
|
|
|
|
Color += vSpecularColor;
|
|
|
|
if (bool(uFogEnable))
|
|
{
|
|
float FogFactor = computeFog();
|
|
vec4 FogColor = uFogColor;
|
|
FogColor.a = 1.0;
|
|
Color = mix(FogColor, Color, FogFactor);
|
|
}
|
|
|
|
gl_FragColor = Color;
|
|
}
|