2020-12-31 02:23:21 +08:00
|
|
|
#extension GL_EXT_texture_array : enable
|
|
|
|
|
2020-12-31 23:06:30 +08:00
|
|
|
#pragma import_defines ( WINDOW_WIDTH, WINDOW_HEIGHT, INTERLEAVE )
|
2020-12-31 19:47:56 +08:00
|
|
|
|
2020-12-31 02:23:21 +08:00
|
|
|
uniform sampler2DArray texture_0;
|
|
|
|
uniform sampler2DArray texture_1;
|
|
|
|
uniform sampler2DArray texture_2;
|
|
|
|
uniform sampler2DArray texture_3;
|
|
|
|
|
|
|
|
varying vec2 texcoord;
|
|
|
|
|
2020-12-31 23:06:30 +08:00
|
|
|
#ifndef WINDOW_WIDTH
|
|
|
|
#define WINDOW_WIDTH 1920
|
|
|
|
#define WINDOW_HEIGHT 1080
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define INTERLEAVE
|
|
|
|
|
2020-12-31 02:23:21 +08:00
|
|
|
void main(void)
|
|
|
|
{
|
2020-12-31 23:06:30 +08:00
|
|
|
#ifdef INTERLEAVE
|
|
|
|
|
|
|
|
float i = mod(gl_FragCoord.x, 4.0);
|
|
|
|
float j = mod(gl_FragCoord.y, 4.0);
|
|
|
|
|
|
|
|
vec3 tc = vec3(gl_FragCoord.x / WINDOW_WIDTH, gl_FragCoord.y / WINDOW_HEIGHT, i);
|
|
|
|
|
|
|
|
if (j < 1.0) gl_FragColor = texture2DArray( texture_0, tc);
|
|
|
|
else if (j < 2.0) gl_FragColor = texture2DArray( texture_1, tc);
|
|
|
|
else if (j < 3.0) gl_FragColor = texture2DArray( texture_2, tc);
|
|
|
|
else gl_FragColor = texture2DArray( texture_3, tc);
|
|
|
|
|
|
|
|
#else
|
2020-12-31 02:23:21 +08:00
|
|
|
float cell_width = WINDOW_WIDTH/4.0;
|
|
|
|
float cell_height = WINDOW_HEIGHT/4.0;
|
|
|
|
|
|
|
|
float i = floor(gl_FragCoord.x / cell_width);
|
|
|
|
float j = floor(gl_FragCoord.y / cell_height);
|
|
|
|
|
|
|
|
vec3 tc = vec3(gl_FragCoord.x / cell_width - i, gl_FragCoord.y / cell_height - j, i);
|
|
|
|
|
|
|
|
if (j < 1.0) gl_FragColor = texture2DArray( texture_0, tc);
|
|
|
|
else if (j < 2.0) gl_FragColor = texture2DArray( texture_1, tc);
|
|
|
|
else if (j < 3.0) gl_FragColor = texture2DArray( texture_2, tc);
|
|
|
|
else gl_FragColor = texture2DArray( texture_3, tc);
|
2020-12-31 23:06:30 +08:00
|
|
|
#endif
|
2020-12-31 02:23:21 +08:00
|
|
|
}
|