bare bones sudo example
unknown
glsl
2 years ago
893 B
5
Indexable
Never
//VERTEX SHADER in vec2 a_texCoord; //pixel location from cpu out vec2 v_texCoord; //pixel location to gpu void main() { v_texCoord = a_texCoord; //pixel location is pixel location } //FRAGMENT SHADER uniform int img1t; //image input uniform ivec2 img1s; //image size [x,y] in vec2 v_texCoord; //pixel locaion from vertex shader out vec4 finalcolor; //output for this pixel (frament is run for each pixel.. i like to thing of it like every pixel on the screen is like cpu thred running THIS fragment code all at the same time) void main(){ vec2 ploc=vec2(v_texCoord[0],1.0-v_texCoord[1]); //location is 0.0-1.0 (i flip Y.. prob some error i made some where once lol) vec4 color=texelFetch(img1,ivec2(ploc*float(img1s)),0); //texelFetch gets pixel from sample image as an int (more absalute controll i found but thats could just be me) finalcolor=color; //return output this pixels value }