#include "camera.glsl" // Shadows use a different format, so don't use draw_cmds_data.glsl layout(std430, binding = 3) readonly buffer DrawCmdDatasShadow { // Access by gl_DrawID mat4 transforms[]; }; // Input, output blocks #if VERTEX_SHADER layout(location = 0) in vec3 aPos; void main() { mat4 model = transforms[gl_DrawID]; gl_Position = projection * view * model * vec4(aPos.xyz, 1.0); } #endif // VERTEX_SHADER #if FRAGMENT_SHADER out vec4 FragColor; void main() { // Store moments for VSM float clamped_depth = clamp(gl_FragCoord.z, 0.0, 1.0); float dx = dFdx(clamped_depth); float dy = dFdy(clamped_depth); vec2 moments; moments.x = clamped_depth; moments.y = clamped_depth * clamped_depth + 0.25 * (dx * dx + dy * dy); moments.y = clamp(moments.y, 0.0, 1.0); FragColor = vec4(moments.x, moments.y, 0.0, 1.0); } #endif // FRAGMNET_SHADER