v4k-git-backup/engine/art/shaders/fs_shadow_vsm.glsl

31 lines
758 B
Plaintext
Raw Normal View History

2024-08-29 18:46:30 +00:00
const int SHADOW_VSM = 0;
2024-08-30 19:00:04 +00:00
const int SHADOW_CSM = 1;
2024-08-29 18:46:30 +00:00
uniform int shadow_technique;
2024-09-02 17:48:15 +00:00
#include "model_fs.glsl"
#include "surface.glsl"
2023-09-10 14:46:07 +00:00
void main() {
2024-09-02 17:48:15 +00:00
vec4 diffuse = get_diffuse_map();
diffuse.a *= u_global_alpha*u_global_opacity;
if (diffuse.a < 0.1)
discard;
2024-08-29 18:46:30 +00:00
if (shadow_technique == SHADOW_VSM) {
2024-08-30 14:01:46 +00:00
float depth = length(v_position) / 200;
2024-08-29 15:32:34 +00:00
2024-08-30 01:46:46 +00:00
float moment1 = depth;
float moment2 = depth * depth;
float dx = dFdx(depth);
float dy = dFdy(depth);
moment2 += 0.25*(dx*dx+dy*dy);
2024-09-02 17:48:15 +00:00
fragcolor = vec4( moment1, moment2, /* diffuse.a */ 0.0, 1.0);
2024-08-29 18:46:30 +00:00
}
2024-08-30 19:00:04 +00:00
else if (shadow_technique == SHADOW_CSM) {
2024-09-02 17:48:15 +00:00
fragcolor = vec4(gl_FragCoord.z, /* diffuse.a */ 0.0, 0.0, 1.0);
2024-08-29 18:46:30 +00:00
}
2024-08-29 15:32:34 +00:00
}