Need help with some GLSL shader code

Hi
I want to use Processing shaders to do some code art algorithms - but I want to do it all through a shader to take advantage of the high GPU power.

I know the basics of shader programming, but what I’m stuck on at the minute is,

how would I draw a bitmap on top of another bitmap (if I have 2 2dsamplers for example)
how could I get the individual pixel color from an x,y position on either of these bitmaps
how could I change / write the value of a new color into a bitmap at an x,y pixel position.

thanks!

1 Like
  1. Transparency
  2. texelFetch(texMap,ivec2(ix,iy),0)
  3. You can’t. The result of the fragment shader IS the new bitmap.
#version 320 es

#ifdef GL_ES
precision highp float;
precision mediump int;
#endif

in vec4 vertTexCoord;
out vec4 was_gl_FragColor;
uniform sampler2D texMap;

....
void main(void)
{
    was_gl_FragColor=yourcode();
}


1 Like

thanks, i’ve worked out other solutions…

Good for you.
Which?

well,I didn’t really, just had compromise - I worked out texelfetch though, which was very useful - but I still want to know how to simply write / store a pixel into a texture already in GPU memory e.g. the uniform sampler2D texMap - how would i write a single pixel into an x,y there?