From ae4fda82b026ae6e2b003c1105f329b7e76582b0 Mon Sep 17 00:00:00 2001 From: Daniel Stokes Date: Tue, 1 May 2012 02:50:17 +0000 Subject: Merging phase 1 of the BGE Harmony branch: * Shadow color now usable in the BGE * Simplified the shadow panel while "Blender Game" renderer is active * Added variance shadow maps for the BGE * Buffered shadows on sun lamps in the BGE (orthographic) * Light textures in the BGE --- .../gpu/shaders/gpu_shader_vsm_store_frag.glsl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl (limited to 'source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl') 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); +} -- cgit v1.2.3