# Encoding 2 integers into RGBA without bitwise

**URL:** <https://discourse.processing.org/t/encoding-2-integers-into-rgba-without-bitwise/21718>\
**Category:** Coding Questions\
**Created:** [June 9, 2020, 8:48pm UTC](https://discourse.processing.org/t/encoding-2-integers-into-rgba-without-bitwise/21718 "2020-06-09T20:48:23Z")\
**Posts on this page:** 2\
**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 9, 2020, 8:48pm UTC](https://discourse.processing.org/t/encoding-2-integers-into-rgba-without-bitwise/21718/1 "2020-06-09T20:48:23Z")

</div>

I’m using Processing(Java) to write shaders that do lots of fancy code art. In my shader code I’m trying to get 2 integers (x,y positions) into an RGBA so I can send this colored pixel back to my Java program - and from there decode this color to get back the original integers. As far a I know, I cant use bitwise operations in GLSL, or least I’d have to re-write a lot of code. So I need to get 2 numbers into an RGBA, or 1 number into 2 bytes (RG) and the other in another 2 bytes (BA) - something like that… without bitwise… Help!!

---

<div class="post-metadata">

**Author:** ![micycle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micycle/32/201_2.png) [@micycle](https://discourse.processing.org/u/micycle)\
**Post date:** [June 9, 2020, 9:16pm UTC](https://discourse.processing.org/t/encoding-2-integers-into-rgba-without-bitwise/21718/2 "2020-06-09T21:16:35Z")

</div>

> <https://stackoverflow.com/questions/27548216/colour-bit-wise-shift-in-opengl-shader-glsl/27551433#27551433>

Remember too that processing parses int colours as ARGB (alpha is first 8 bits).
