summaryrefslogtreecommitdiff
path: root/servers/rendering/renderer_rd/shaders/canvas_occlusion.glsl
blob: 930cf792cbb9a97e483832945fefac9c9d014d5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#[vertex]

#version 450

#VERSION_DEFINES

layout(location = 0) in highp vec3 vertex;

layout(push_constant, std430) uniform Constants {
	mat4 projection;
	mat2x4 modelview;
	vec2 direction;
	float z_far;
	float pad;
}
constants;

#ifdef MODE_SHADOW
layout(location = 0) out highp float depth;
#endif

void main() {
	highp vec4 vtx = vec4(vertex, 1.0) * mat4(constants.modelview[0], constants.modelview[1], vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0));

#ifdef MODE_SHADOW
	depth = dot(constants.direction, vtx.xy);
#endif
	gl_Position = constants.projection * vtx;
}

#[fragment]

#version 450

#VERSION_DEFINES

layout(push_constant, std430) uniform Constants {
	mat4 projection;
	mat2x4 modelview;
	vec2 direction;
	float z_far;
	float pad;
}
constants;

#ifdef MODE_SHADOW
layout(location = 0) in highp float depth;
layout(location = 0) out highp float distance_buf;
#else
layout(location = 0) out highp float sdf_buf;
#endif

void main() {
#ifdef MODE_SHADOW
	distance_buf = depth / constants.z_far;
#else
	sdf_buf = 1.0;
#endif
}