# Need help with some GLSL shader code

**URL:** https://discourse.processing.org/t/need-help-with-some-glsl-shader-code/21655
**Category:** Coding Questions
**Created:** [June 7, 2020, 1:36pm UTC](https://discourse.processing.org/t/need-help-with-some-glsl-shader-code/21655 "2020-06-07T13:36:22Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![zenglenn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/zenglenn/32/5569_2.png) [@zenglenn](https://discourse.processing.org/u/zenglenn)
#### Post date: [June 7, 2020, 1:36pm UTC](https://discourse.processing.org/t/need-help-with-some-glsl-shader-code/21655/1 "2020-06-07T13:36:22Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![uheinema](https://avatars.discourse-cdn.com/v4/letter/u/e99b99/32.png) [@uheinema](https://discourse.processing.org/u/uheinema)
#### Post date: [June 8, 2020, 5:14pm UTC](https://discourse.processing.org/t/need-help-with-some-glsl-shader-code/21655/2 "2020-06-08T17:14:04Z")

</div>

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

```auto
#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();
}

```

---

<div class="post-metadata">

### Author: ![zenglenn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/zenglenn/32/5569_2.png) [@zenglenn](https://discourse.processing.org/u/zenglenn)
#### Post date: [June 9, 2020, 8:46pm UTC](https://discourse.processing.org/t/need-help-with-some-glsl-shader-code/21655/3 "2020-06-09T20:46:12Z")

</div>

thanks, i’ve worked out other solutions…

---

<div class="post-metadata">

### Author: ![uheinema](https://avatars.discourse-cdn.com/v4/letter/u/e99b99/32.png) [@uheinema](https://discourse.processing.org/u/uheinema)
#### Post date: [June 11, 2020, 11:09am UTC](https://discourse.processing.org/t/need-help-with-some-glsl-shader-code/21655/4 "2020-06-11T11:09:18Z")

</div>

Good for you.  
Which?

---

<div class="post-metadata">

### Author: ![zenglenn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/zenglenn/32/5569_2.png) [@zenglenn](https://discourse.processing.org/u/zenglenn)
#### Post date: [June 12, 2020, 6:41am UTC](https://discourse.processing.org/t/need-help-with-some-glsl-shader-code/21655/5 "2020-06-12T06:41:13Z")

</div>

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?
