2018-08-27 07:31:48 +02:00
|
|
|
/* clang-format off */
|
2016-10-03 21:33:42 +02:00
|
|
|
[vertex]
|
|
|
|
|
|
|
|
uniform highp mat4 projection_matrix;
|
2018-08-27 07:31:48 +02:00
|
|
|
/* clang-format on */
|
2016-10-03 21:33:42 +02:00
|
|
|
uniform highp mat4 light_matrix;
|
|
|
|
uniform highp mat4 world_matrix;
|
|
|
|
uniform highp float distance_norm;
|
|
|
|
|
2018-08-24 13:42:18 +02:00
|
|
|
layout(location = 0) in highp vec3 vertex;
|
2016-10-03 21:33:42 +02:00
|
|
|
|
|
|
|
out highp vec4 position_interp;
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
2018-08-24 13:42:18 +02:00
|
|
|
gl_Position = projection_matrix * (light_matrix * (world_matrix * vec4(vertex, 1.0)));
|
|
|
|
position_interp = gl_Position;
|
2016-10-03 21:33:42 +02:00
|
|
|
}
|
|
|
|
|
2018-08-27 07:31:48 +02:00
|
|
|
/* clang-format off */
|
2016-10-03 21:33:42 +02:00
|
|
|
[fragment]
|
|
|
|
|
|
|
|
in highp vec4 position_interp;
|
2018-08-27 07:31:48 +02:00
|
|
|
/* clang-format on */
|
2016-10-03 21:33:42 +02:00
|
|
|
|
|
|
|
#ifdef USE_RGBA_SHADOWS
|
2018-08-24 13:42:18 +02:00
|
|
|
layout(location = 0) out lowp vec4 distance_buf;
|
2016-10-03 21:33:42 +02:00
|
|
|
#else
|
2018-08-24 13:42:18 +02:00
|
|
|
layout(location = 0) out highp float distance_buf;
|
2016-10-03 21:33:42 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
2018-08-24 13:42:18 +02:00
|
|
|
highp float depth = ((position_interp.z / position_interp.w) + 1.0) * 0.5 + 0.0; // bias
|
2016-10-03 21:33:42 +02:00
|
|
|
|
|
|
|
#ifdef USE_RGBA_SHADOWS
|
|
|
|
|
2019-07-27 17:05:26 +02:00
|
|
|
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);
|
2018-08-24 13:42:18 +02:00
|
|
|
distance_buf = comp;
|
2016-10-03 21:33:42 +02:00
|
|
|
#else
|
|
|
|
|
2018-08-24 13:42:18 +02:00
|
|
|
distance_buf = depth;
|
2016-10-03 21:33:42 +02:00
|
|
|
#endif
|
|
|
|
}
|