Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl b/source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl
new file mode 100644
index 00000000000..4838289ff9e
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl
@@ -0,0 +1,21 @@
+/**
+ * This fragment shader was initially found at http://fabiensanglard.net/shadowmappingVSM/index.php
+ */
+
+varying vec4 v_position;
+
+void main()
+{
+ float depth = v_position.z / v_position.w;
+ depth = depth * 0.5 + 0.5;
+
+ float moment1 = depth;
+ float moment2 = depth * depth;
+
+ // Adjusting moments using partial derivative
+ float dx = dFdx(depth);
+ float dy = dFdy(depth);
+ moment2 += 0.25*(dx*dx+dy*dy);
+
+ gl_FragColor = vec4(moment1, moment2, 0.0, 0.0);
+}