summaryrefslogtreecommitdiff
path: root/drivers/gles3/shaders/canvas_shadow.glsl
blob: 65389c211af069d817c10408af0a457a8fee8dbc (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
60
/* clang-format off */
[vertex]

#ifdef USE_GLES_OVER_GL
#define lowp
#define mediump
#define highp
#else
precision highp float;
precision highp int;
#endif

layout(location = 0) in highp vec3 vertex;

uniform highp mat4 projection_matrix;
/* clang-format on */
uniform highp mat4 light_matrix;
uniform highp mat4 world_matrix;
uniform highp float distance_norm;

out highp vec4 position_interp;

void main() {
	gl_Position = projection_matrix * (light_matrix * (world_matrix * vec4(vertex, 1.0)));
	position_interp = gl_Position;
}

/* clang-format off */
[fragment]

#ifdef USE_GLES_OVER_GL
#define lowp
#define mediump
#define highp
#else
#if defined(USE_HIGHP_PRECISION)
precision highp float;
precision highp int;
#else
precision mediump float;
precision mediump int;
#endif
#endif

in highp vec4 position_interp;
/* clang-format on */

void main() {
	highp float depth = ((position_interp.z / position_interp.w) + 1.0) * 0.5 + 0.0; // bias

#ifdef USE_RGBA_SHADOWS

	highp vec4 comp = fract(depth * vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0));
	comp -= comp.xxyz * vec4(0.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);
	frag_color = comp;
#else

	frag_color = vec4(depth);
#endif
}