1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00
luanti/client/shaders/volumetric_clouds/opengl_vertex.glsl

38 lines
915 B
Text
Raw Normal View History

2024-07-05 12:15:22 +02:00
uniform mat4 mCameraProjInv;
uniform mat4 mCameraView;
2024-08-18 15:13:26 +02:00
uniform float f_timeofday;
2024-07-05 12:15:22 +02:00
varying vec3 relativePosition;
varying vec3 viewDirection;
varying vec2 screenspaceCoordinate;
2024-08-18 15:13:26 +02:00
varying float sunStrength;
float mtsmoothstep(in float edge0, in float edge1, in float x)
{
float t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
return t * t * (3.0 - 2.0 * t);
}
2024-07-05 12:15:22 +02:00
void main(void)
{
screenspaceCoordinate = inVertexPosition.xy;
vec4 p = mCameraProjInv * inVertexPosition;
viewDirection = p.xyz / p.w;
relativePosition = (p.xyz / p.w) * mat3(mCameraView);
2024-08-18 15:13:26 +02:00
if (f_timeofday < 0.21) {
sunStrength =
(1.0 - mtsmoothstep(0.18, 0.21, f_timeofday));
} else if (f_timeofday >= 0.793) {
sunStrength =
mtsmoothstep(0.793, 0.823, f_timeofday);
} else {
sunStrength =
mtsmoothstep(0.21, 0.26, f_timeofday) *
(1.0 - mtsmoothstep(0.743, 0.793, f_timeofday));
}
2024-07-05 12:15:22 +02:00
gl_Position = inVertexPosition;
}