2018-08-27 07:31:48 +02:00
|
|
|
/* clang-format off */
|
2017-12-04 13:41:34 +01:00
|
|
|
[vertex]
|
|
|
|
|
|
|
|
uniform highp mat4 projection_matrix;
|
2018-08-27 07:31:48 +02:00
|
|
|
/* clang-format on */
|
2017-12-04 13:41:34 +01:00
|
|
|
uniform highp mat4 light_matrix;
|
|
|
|
uniform highp mat4 world_matrix;
|
|
|
|
uniform highp float distance_norm;
|
|
|
|
|
2018-08-24 14:50:59 +02:00
|
|
|
layout(location = 0) in highp vec3 vertex;
|
2017-12-04 13:41:34 +01:00
|
|
|
|
|
|
|
out highp vec4 position_interp;
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
2018-08-24 14:50:59 +02:00
|
|
|
gl_Position = projection_matrix * (light_matrix * (world_matrix * vec4(vertex, 1.0)));
|
|
|
|
position_interp = gl_Position;
|
2017-12-04 13:41:34 +01:00
|
|
|
}
|
|
|
|
|
2018-08-27 07:31:48 +02:00
|
|
|
/* clang-format off */
|
2017-12-04 13:41:34 +01:00
|
|
|
[fragment]
|
|
|
|
|
|
|
|
in highp vec4 position_interp;
|
2018-08-27 07:31:48 +02:00
|
|
|
/* clang-format on */
|
2017-12-04 13:41:34 +01:00
|
|
|
|
|
|
|
#ifdef USE_RGBA_SHADOWS
|
|
|
|
|
2018-08-24 14:50:59 +02:00
|
|
|
layout(location = 0) out lowp vec4 distance_buf;
|
2017-12-04 13:41:34 +01:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2018-08-24 14:50:59 +02:00
|
|
|
layout(location = 0) out highp float distance_buf;
|
2017-12-04 13:41:34 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
2018-08-24 14:50:59 +02:00
|
|
|
highp float depth = ((position_interp.z / position_interp.w) + 1.0) * 0.5 + 0.0; //bias;
|
2017-12-04 13:41:34 +01:00
|
|
|
|
|
|
|
#ifdef USE_RGBA_SHADOWS
|
|
|
|
|
|
|
|
highp vec4 comp = fract(depth * vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0));
|
|
|
|
comp -= comp.xxyz * vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);
|
2018-08-24 14:50:59 +02:00
|
|
|
distance_buf = comp;
|
2017-12-04 13:41:34 +01:00
|
|
|
#else
|
|
|
|
|
2018-08-24 14:50:59 +02:00
|
|
|
distance_buf = depth;
|
2017-12-04 13:41:34 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|