uniform int sampleMode; vec4 sampleTexture( sampler2D texture, vec2 pos) { if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.) return texture2D(texture, pos); if(sampleMode <= 1) return vec4(0.); else if(sampleMode == 2) return texture2D(texture, clamp(pos, 0., 1.)); else if(sampleMode == 3) return texture2D(texture, fract(pos)); else if(sampleMode == 4) return vec4(vec3(0.), 1.); return vec4(0.); }