2020-11-18 18:11:30 +00:00
|
|
|
/* clang-format off */
|
|
|
|
[vertex]
|
|
|
|
|
|
|
|
#ifdef USE_GLES_OVER_GL
|
|
|
|
#define lowp
|
|
|
|
#define mediump
|
|
|
|
#define highp
|
|
|
|
#else
|
|
|
|
precision highp float;
|
|
|
|
precision highp int;
|
|
|
|
#endif
|
|
|
|
|
2021-11-16 15:25:42 +00:00
|
|
|
layout(location = 0) in highp vec3 vertex;
|
2020-11-18 18:11:30 +00:00
|
|
|
|
|
|
|
uniform highp mat4 projection_matrix;
|
|
|
|
/* clang-format on */
|
|
|
|
uniform highp mat4 light_matrix;
|
2022-03-18 09:10:55 +00:00
|
|
|
uniform highp mat4 model_matrix;
|
2020-11-18 18:11:30 +00:00
|
|
|
uniform highp float distance_norm;
|
|
|
|
|
2021-10-26 15:18:39 +00:00
|
|
|
out highp vec4 position_interp;
|
2020-11-18 18:11:30 +00:00
|
|
|
|
|
|
|
void main() {
|
2022-03-18 09:10:55 +00:00
|
|
|
gl_Position = projection_matrix * (light_matrix * (model_matrix * vec4(vertex, 1.0)));
|
2020-11-18 18:11:30 +00:00
|
|
|
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
|
|
|
|
|
2021-10-26 15:18:39 +00:00
|
|
|
in highp vec4 position_interp;
|
2020-11-18 18:11:30 +00:00
|
|
|
/* 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);
|
2021-10-26 15:18:39 +00:00
|
|
|
frag_color = comp;
|
2020-11-18 18:11:30 +00:00
|
|
|
#else
|
|
|
|
|
2021-10-26 15:18:39 +00:00
|
|
|
frag_color = vec4(depth);
|
2020-11-18 18:11:30 +00:00
|
|
|
#endif
|
|
|
|
}
|