25 lines
580 B
GLSL
25 lines
580 B
GLSL
in vec3 v_position;
|
|
out vec4 fragcolor;
|
|
|
|
const int SHADOW_VSM = 0;
|
|
const int SHADOW_PCF = 1;
|
|
|
|
uniform int shadow_technique;
|
|
|
|
void main() {
|
|
if (shadow_technique == SHADOW_VSM) {
|
|
float depth = length(v_position) / 20;
|
|
|
|
float moment1 = depth;
|
|
float moment2 = depth * depth;
|
|
|
|
float dx = dFdx(depth);
|
|
float dy = dFdy(depth);
|
|
moment2 += 0.25*(dx*dx+dy*dy);
|
|
fragcolor = vec4( moment1, moment2, 0.0, 1.0);
|
|
}
|
|
else if (shadow_technique == SHADOW_PCF) {
|
|
fragcolor = vec4(vec3(gl_FragCoord.z), 1.0);
|
|
}
|
|
}
|