import { glsl_gen_swizzled_read } from "./glsl_gen_swizzled_read.js";

function vertexShader() {
    return `
                varying vec2 vUv;
        
                void main() {
        
                    vUv = uv;
                    gl_Position = vec4( (uv - 0.5)*2.0, 0.0, 1.0 );
                    
                }
        `;
}


/**
 *
 * @param {string[]} [swizzle] what to read from the texture
 * @returns {string}
 */
function fragmentShader(swizzle = ['r', 'g', 'b', 'a']) {

    return `
                uniform sampler2D tTexture;
                varying vec2 vUv;
                            
                void main(){
                    vec4 texel = texture2D( tTexture, vUv );
                    gl_FragColor = ${glsl_gen_swizzled_read('texel', swizzle)};
                }
        `;
}

export const ScreenSpaceQuadShader = {
    vertexShader,
    fragmentShader
};
