2018-08-27 07:31:48 +02:00
|
|
|
/* clang-format off */
|
2017-12-04 13:41:34 +01:00
|
|
|
[vertex]
|
|
|
|
|
|
|
|
#ifdef USE_GLES_OVER_GL
|
|
|
|
#define mediump
|
|
|
|
#define highp
|
|
|
|
#else
|
|
|
|
precision mediump float;
|
|
|
|
precision mediump int;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
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 modelview_matrix;
|
|
|
|
uniform highp mat4 extra_matrix;
|
|
|
|
attribute highp vec2 vertex; // attrib:0
|
|
|
|
attribute vec4 color_attrib; // attrib:3
|
|
|
|
attribute vec2 uv_attrib; // attrib:4
|
|
|
|
|
|
|
|
varying vec2 uv_interp;
|
|
|
|
varying vec4 color_interp;
|
|
|
|
|
|
|
|
uniform highp vec2 color_texpixel_size;
|
|
|
|
|
2018-08-20 02:10:14 +02:00
|
|
|
#ifdef USE_TEXTURE_RECT
|
|
|
|
|
|
|
|
uniform vec4 dst_rect;
|
|
|
|
uniform vec4 src_rect;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2018-02-24 14:48:22 +01:00
|
|
|
uniform highp float time;
|
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
|
|
|
VERTEX_SHADER_GLOBALS
|
|
|
|
|
2018-08-27 07:31:48 +02:00
|
|
|
/* clang-format on */
|
|
|
|
|
2017-12-04 13:41:34 +01:00
|
|
|
vec2 select(vec2 a, vec2 b, bvec2 c) {
|
|
|
|
vec2 ret;
|
|
|
|
|
|
|
|
ret.x = c.x ? b.x : a.x;
|
|
|
|
ret.y = c.y ? b.y : a.y;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
|
|
|
vec4 color = color_attrib;
|
|
|
|
|
2018-08-20 02:10:14 +02:00
|
|
|
#ifdef USE_TEXTURE_RECT
|
|
|
|
|
|
|
|
if (dst_rect.z < 0.0) { // Transpose is encoded as negative dst_rect.z
|
|
|
|
uv_interp = src_rect.xy + abs(src_rect.zw) * vertex.yx;
|
|
|
|
} else {
|
|
|
|
uv_interp = src_rect.xy + abs(src_rect.zw) * vertex;
|
|
|
|
}
|
|
|
|
|
|
|
|
vec4 outvec = vec4(0.0, 0.0, 0.0, 1.0);
|
|
|
|
|
|
|
|
// This is what is done in the GLES 3 bindings and should
|
|
|
|
// take care of flipped rects.
|
|
|
|
//
|
|
|
|
// But it doesn't.
|
|
|
|
// I don't know why, will need to investigate further.
|
|
|
|
|
|
|
|
outvec.xy = dst_rect.xy + abs(dst_rect.zw) * select(vertex, vec2(1.0, 1.0) - vertex, lessThan(src_rect.zw, vec2(0.0, 0.0)));
|
|
|
|
|
|
|
|
// outvec.xy = dst_rect.xy + abs(dst_rect.zw) * vertex;
|
|
|
|
#else
|
2017-12-04 13:41:34 +01:00
|
|
|
vec4 outvec = vec4(vertex.xy, 0.0, 1.0);
|
|
|
|
|
2018-08-20 02:10:14 +02:00
|
|
|
#ifdef USE_UV_ATTRIBUTE
|
2017-12-04 13:41:34 +01:00
|
|
|
uv_interp = uv_attrib;
|
2018-08-20 02:10:14 +02:00
|
|
|
#else
|
|
|
|
uv_interp = vertex.xy;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
2017-12-04 13:41:34 +01:00
|
|
|
|
2018-08-27 07:31:48 +02:00
|
|
|
{
|
|
|
|
vec2 src_vtx = outvec.xy;
|
|
|
|
/* clang-format off */
|
|
|
|
|
2017-12-04 13:41:34 +01:00
|
|
|
VERTEX_SHADER_CODE
|
|
|
|
|
2018-08-27 07:31:48 +02:00
|
|
|
/* clang-format on */
|
|
|
|
}
|
2017-12-04 13:41:34 +01:00
|
|
|
|
2018-09-30 17:20:20 +02:00
|
|
|
#if !defined(SKIP_TRANSFORM_USED)
|
|
|
|
outvec = extra_matrix * outvec;
|
|
|
|
outvec = modelview_matrix * outvec;
|
|
|
|
#endif
|
|
|
|
|
2017-12-04 13:41:34 +01:00
|
|
|
color_interp = color;
|
|
|
|
|
2018-09-30 17:20:20 +02:00
|
|
|
gl_Position = projection_matrix * outvec;
|
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]
|
|
|
|
|
|
|
|
#ifdef USE_GLES_OVER_GL
|
|
|
|
#define mediump
|
|
|
|
#define highp
|
|
|
|
#else
|
|
|
|
precision mediump float;
|
|
|
|
precision mediump int;
|
|
|
|
#endif
|
|
|
|
|
2018-08-23 16:46:43 +02:00
|
|
|
uniform sampler2D color_texture; // texunit:-1
|
2018-08-27 07:31:48 +02:00
|
|
|
/* clang-format on */
|
2017-12-04 13:41:34 +01:00
|
|
|
uniform highp vec2 color_texpixel_size;
|
2018-08-23 16:46:43 +02:00
|
|
|
uniform mediump sampler2D normal_texture; // texunit:-2
|
2017-12-04 13:41:34 +01:00
|
|
|
|
|
|
|
varying mediump vec2 uv_interp;
|
|
|
|
varying mediump vec4 color_interp;
|
|
|
|
|
2018-02-24 14:48:22 +01:00
|
|
|
uniform highp float time;
|
2017-12-04 13:41:34 +01:00
|
|
|
|
|
|
|
uniform vec4 final_modulate;
|
|
|
|
|
|
|
|
#ifdef SCREEN_TEXTURE_USED
|
|
|
|
|
2018-08-23 16:46:43 +02:00
|
|
|
uniform sampler2D screen_texture; // texunit:-3
|
2017-12-04 13:41:34 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SCREEN_UV_USED
|
|
|
|
|
|
|
|
uniform vec2 screen_pixel_size;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2018-08-27 07:31:48 +02:00
|
|
|
/* clang-format off */
|
|
|
|
|
2017-12-04 13:41:34 +01:00
|
|
|
FRAGMENT_SHADER_GLOBALS
|
|
|
|
|
2018-08-27 07:31:48 +02:00
|
|
|
/* clang-format on */
|
|
|
|
|
2017-12-04 13:41:34 +01:00
|
|
|
void main() {
|
|
|
|
|
|
|
|
vec4 color = color_interp;
|
|
|
|
|
|
|
|
color *= texture2D(color_texture, uv_interp);
|
2018-02-24 14:48:22 +01:00
|
|
|
|
|
|
|
#ifdef SCREEN_UV_USED
|
|
|
|
vec2 screen_uv = gl_FragCoord.xy * screen_pixel_size;
|
|
|
|
#endif
|
2018-08-27 07:31:48 +02:00
|
|
|
{
|
|
|
|
/* clang-format off */
|
2017-12-04 13:41:34 +01:00
|
|
|
|
|
|
|
FRAGMENT_SHADER_CODE
|
|
|
|
|
2018-08-27 07:31:48 +02:00
|
|
|
/* clang-format on */
|
|
|
|
}
|
2017-12-04 13:41:34 +01:00
|
|
|
|
|
|
|
color *= final_modulate;
|
|
|
|
|
|
|
|
gl_FragColor = color;
|
|
|
|
}
|