2018-08-27 05:31:48 +00:00
|
|
|
/* clang-format off */
|
2017-12-04 12:41:34 +00:00
|
|
|
[vertex]
|
|
|
|
|
|
|
|
#ifdef USE_GLES_OVER_GL
|
|
|
|
#define mediump
|
|
|
|
#define highp
|
|
|
|
#else
|
|
|
|
precision mediump float;
|
|
|
|
precision mediump int;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
attribute highp vec4 vertex_attrib; // attrib:0
|
2018-08-27 05:31:48 +00:00
|
|
|
/* clang-format on */
|
2018-02-24 13:48:22 +00:00
|
|
|
|
|
|
|
#if defined(USE_CUBEMAP) || defined(USE_PANORAMA)
|
|
|
|
attribute vec3 cube_in; // attrib:4
|
|
|
|
#else
|
2017-12-04 12:41:34 +00:00
|
|
|
attribute vec2 uv_in; // attrib:4
|
2018-02-24 13:48:22 +00:00
|
|
|
#endif
|
|
|
|
|
2017-12-04 12:41:34 +00:00
|
|
|
attribute vec2 uv2_in; // attrib:5
|
|
|
|
|
2018-02-24 13:48:22 +00:00
|
|
|
#if defined(USE_CUBEMAP) || defined(USE_PANORAMA)
|
|
|
|
varying vec3 cube_interp;
|
|
|
|
#else
|
2017-12-04 12:41:34 +00:00
|
|
|
varying vec2 uv_interp;
|
2018-02-24 13:48:22 +00:00
|
|
|
#endif
|
2017-12-04 12:41:34 +00:00
|
|
|
varying vec2 uv2_interp;
|
|
|
|
|
|
|
|
#ifdef USE_COPY_SECTION
|
|
|
|
uniform vec4 copy_section;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
2018-02-24 13:48:22 +00:00
|
|
|
#if defined(USE_CUBEMAP) || defined(USE_PANORAMA)
|
|
|
|
cube_interp = cube_in;
|
|
|
|
#else
|
2017-12-04 12:41:34 +00:00
|
|
|
uv_interp = uv_in;
|
2018-02-24 13:48:22 +00:00
|
|
|
#endif
|
|
|
|
|
2017-12-04 12:41:34 +00:00
|
|
|
uv2_interp = uv2_in;
|
|
|
|
gl_Position = vertex_attrib;
|
|
|
|
|
|
|
|
#ifdef USE_COPY_SECTION
|
|
|
|
uv_interp = copy_section.xy + uv_interp * copy_section.zw;
|
|
|
|
gl_Position.xy = (copy_section.xy + (gl_Position.xy * 0.5 + 0.5) * copy_section.zw) * 2.0 - 1.0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-08-27 05:31:48 +00:00
|
|
|
/* clang-format off */
|
2017-12-04 12:41:34 +00:00
|
|
|
[fragment]
|
|
|
|
|
2018-02-24 13:48:22 +00:00
|
|
|
#define M_PI 3.14159265359
|
|
|
|
|
2017-12-04 12:41:34 +00:00
|
|
|
#ifdef USE_GLES_OVER_GL
|
|
|
|
#define mediump
|
|
|
|
#define highp
|
|
|
|
#else
|
|
|
|
precision mediump float;
|
|
|
|
precision mediump int;
|
|
|
|
#endif
|
|
|
|
|
2018-02-24 13:48:22 +00:00
|
|
|
#if defined(USE_CUBEMAP) || defined(USE_PANORAMA)
|
|
|
|
varying vec3 cube_interp;
|
|
|
|
#else
|
2017-12-04 12:41:34 +00:00
|
|
|
varying vec2 uv_interp;
|
2018-02-24 13:48:22 +00:00
|
|
|
#endif
|
2018-08-27 05:31:48 +00:00
|
|
|
/* clang-format on */
|
2018-02-24 13:48:22 +00:00
|
|
|
|
|
|
|
#ifdef USE_CUBEMAP
|
|
|
|
uniform samplerCube source_cube; // texunit:0
|
|
|
|
#else
|
2017-12-04 12:41:34 +00:00
|
|
|
uniform sampler2D source; // texunit:0
|
2018-02-24 13:48:22 +00:00
|
|
|
#endif
|
2017-12-04 12:41:34 +00:00
|
|
|
|
|
|
|
varying vec2 uv2_interp;
|
|
|
|
|
2018-02-24 13:48:22 +00:00
|
|
|
#ifdef USE_MULTIPLIER
|
|
|
|
uniform float multiplier;
|
|
|
|
#endif
|
|
|
|
|
2017-12-04 12:41:34 +00:00
|
|
|
#ifdef USE_CUSTOM_ALPHA
|
|
|
|
uniform float custom_alpha;
|
|
|
|
#endif
|
|
|
|
|
2018-02-24 13:48:22 +00:00
|
|
|
#if defined(USE_PANORAMA) || defined(USE_ASYM_PANO)
|
|
|
|
|
|
|
|
vec4 texturePanorama(sampler2D pano, vec3 normal) {
|
|
|
|
|
|
|
|
vec2 st = vec2(
|
2018-08-24 12:50:59 +00:00
|
|
|
atan(normal.x, normal.z),
|
|
|
|
acos(normal.y));
|
2018-02-24 13:48:22 +00:00
|
|
|
|
2018-08-24 12:50:59 +00:00
|
|
|
if (st.x < 0.0)
|
|
|
|
st.x += M_PI * 2.0;
|
2018-02-24 13:48:22 +00:00
|
|
|
|
2018-08-24 12:50:59 +00:00
|
|
|
st /= vec2(M_PI * 2.0, M_PI);
|
2018-02-24 13:48:22 +00:00
|
|
|
|
2018-08-24 12:50:59 +00:00
|
|
|
return texture2D(pano, st);
|
2018-02-24 13:48:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2017-12-04 12:41:34 +00:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
2018-02-24 13:48:22 +00:00
|
|
|
#ifdef USE_PANORAMA
|
|
|
|
|
|
|
|
vec4 color = texturePanorama(source, normalize(cube_interp));
|
|
|
|
|
|
|
|
#elif defined(USE_CUBEMAP)
|
|
|
|
vec4 color = textureCube(source_cube, normalize(cube_interp));
|
|
|
|
#else
|
2018-08-24 12:50:59 +00:00
|
|
|
vec4 color = texture2D(source, uv_interp);
|
2018-02-24 13:48:22 +00:00
|
|
|
#endif
|
2017-12-04 12:41:34 +00:00
|
|
|
|
|
|
|
#ifdef USE_NO_ALPHA
|
2018-08-24 12:50:59 +00:00
|
|
|
color.a = 1.0;
|
2017-12-04 12:41:34 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_CUSTOM_ALPHA
|
2018-08-24 12:50:59 +00:00
|
|
|
color.a = custom_alpha;
|
2017-12-04 12:41:34 +00:00
|
|
|
#endif
|
|
|
|
|
2018-02-24 13:48:22 +00:00
|
|
|
#ifdef USE_MULTIPLIER
|
|
|
|
color.rgb *= multiplier;
|
|
|
|
#endif
|
2017-12-04 12:41:34 +00:00
|
|
|
|
|
|
|
gl_FragColor = color;
|
|
|
|
}
|