I am trying to do the following in GLSL 2 es:
Given a number (say 4 for example) of normalized var4
variables(RGBA) reduce their bit depth and pack the results in a single 0-1 clamped var4
. This will be stored as an 8 bit (per channel) texture and later unpacked. I realize that this will result in quality loss but that is acceptable.
So in this example:
RGBA 8 bit
->
reduced to RGBA 2 bit
->
packed with 3 other RGBA 2 bit var4s
->
saved as single 8 bit RGBA texture
->
unpacked back into 4 x RGBA 2 bit variables
->
scaled back to a reduced quality version of the original.
I realize that I can't do bit-shifting in GLSL so I would have to do some collection of multiplications, the magic combination of which has so far escaped me! Others have talked about packing floats in vec4s
but my problem is a little different.
Thanks!