Skip to content

Instantly share code, notes, and snippets.

@nkint
Created May 2, 2017 22:05
Show Gist options
  • Save nkint/66db01619e3a15b57e7b78ce9b1b85d4 to your computer and use it in GitHub Desktop.
Save nkint/66db01619e3a15b57e7b78ce9b1b85d4 to your computer and use it in GitHub Desktop.
Vertex shader with 4 texture (tiling satellite image)
precision mediump float;
uniform sampler2D satellite0;
uniform sampler2D satellite1;
uniform sampler2D satellite2;
uniform sampler2D satellite3;
uniform sampler2D elevation;
varying vec2 vUv;
void main() {
if (vUv.x <= 0.5 && vUv.y >= 0.5) {
vec2 mappedUv = vUv / 0.5 - vec2(0, 1.);
gl_FragColor = texture2D(satellite0, mappedUv);
}
if (vUv.x >= 0.5 && vUv.y >= 0.5) {
vec2 mappedUv = vUv / 0.5 - vec2(1., 1.);
gl_FragColor = texture2D(satellite1, mappedUv);
}
if (vUv.x >= 0.5 && vUv.y <= 0.5) {
vec2 mappedUv = vUv / 0.5 - vec2(1, 0.);
gl_FragColor = texture2D(satellite3, mappedUv);
}
if (vUv.x <= 0.5 && vUv.y <= 0.5) {
gl_FragColor = texture2D(satellite2, vUv / 0.5);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment