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