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

gpu_shader_vsm_store_frag.glsl « shaders « gpu « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6aad94bbf590bf96ff379cc9341fc07242c01d9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
 * This fragment shader was initially found at http://fabiensanglard.net/shadowmappingVSM/index.php
 */

in vec4 v_position;
out vec4 fragColor;

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);

	fragColor = vec4(moment1, moment2, 0.0, 0.0);
	// TODO: write to a 2-component target --^
}