forked from townforge/townforge
50 lines
1.2 KiB
GLSL
50 lines
1.2 KiB
GLSL
#include "Uniforms.glsl"
|
|
#include "Samplers.glsl"
|
|
#include "Transform.glsl"
|
|
#include "ScreenPos.glsl"
|
|
#include "Lighting.glsl"
|
|
|
|
varying vec2 vTexCoord;
|
|
varying float vWorldHeight;
|
|
#ifdef VERTEXCOLOR
|
|
varying vec4 vColor;
|
|
#endif
|
|
#ifdef PERPIXEL
|
|
#else
|
|
varying vec3 vVertexLight;
|
|
varying vec4 vScreenPos;
|
|
#endif
|
|
|
|
uniform vec2 cSnowOffset;
|
|
uniform float cSnowStrength;
|
|
|
|
void VS()
|
|
{
|
|
mat4 modelMatrix = iModelMatrix;
|
|
vec3 worldPos = GetWorldPos(modelMatrix);
|
|
gl_Position = GetClipPos(worldPos);
|
|
vWorldHeight = worldPos.y;
|
|
vTexCoord = GetTexCoord(iTexCoord) + cSnowOffset;
|
|
}
|
|
|
|
void PS()
|
|
{
|
|
// Get material diffuse albedo
|
|
vec4 diffInput = texture2D(sDiffMap, vTexCoord.xy);
|
|
if (cSnowStrength >= 0.5)
|
|
{
|
|
diffInput += smoothstep(0.0, 1.0, cSnowStrength - 0.5) * texture2D(sDiffMap, vTexCoord.xy + vec2(0.7, 0.3));
|
|
if (cSnowStrength >= 0.8)
|
|
diffInput += smoothstep(0.0, 1.0, cSnowStrength - 0.8) * texture2D(sDiffMap, vTexCoord.xy + vec2(0.3, 0.7));
|
|
}
|
|
vec4 diffColor = cMatDiffColor * diffInput;
|
|
|
|
#ifdef VERTEXCOLOR
|
|
diffColor *= vColor;
|
|
#endif
|
|
|
|
float height = vWorldHeight - cCameraPosPS.y;
|
|
|
|
gl_FragColor = vec4(diffColor.rgb, diffColor.a);
|
|
}
|