2
* This fragment shader was initially found at http://fabiensanglard.net/shadowmappingVSM/index.php
5
varying vec4 v_position;
9
float depth = v_position.z / v_position.w;
10
depth = depth * 0.5 + 0.5;
12
float moment1 = depth;
13
float moment2 = depth * depth;
15
// Adjusting moments using partial derivative
16
float dx = dFdx(depth);
17
float dy = dFdy(depth);
18
moment2 += 0.25*(dx*dx+dy*dy);
20
gl_FragColor = vec4(moment1, moment2, 0.0, 0.0);