PDA

View Full Version : How to store 8 four bit values in 32 bits??



Keith Z. Leonard
08-03-2010, 12:09 AM
Long story short is that I'd like to store 8 four bit values in a 32 bit attachment and decode them in a shader. Am I totally screwed without requiring shader model 4? Int samplers and bit masks/shifts are the straight forward way of doing this, but is there another way of which I am too tired to think?

Thanks,

Alfonse Reinheart
08-03-2010, 12:21 AM
a 32 bit attachment

Do you mean a 32-bit texture or some kind of uniform or buffer object or what?


Am I totally screwed without requiring shader model 4?

If this is indeed a texture, why not just make 2 textures that are each RGBA4? Same effective size, and no need for special decoding logic.

Keith Z. Leonard
08-08-2010, 11:32 PM
Alfonse, I cannot as I also need a RGBA8 attachment, and yes I was indeed referring to texture attatchments to a framebuffer object, sorry for not being clear. I am in essence trying to shove more useful data into 1 attachment to get around the limitation of needing to have the same formats bound to all color attachments.

Anyone have thoughts on this??

Dark Photon
08-09-2010, 04:31 AM
RGBA8 attachment
out.r = (2<<4)*val0 + val1
etc.

???

DmitryM
08-09-2010, 07:41 AM
Well, you can have a texture2DArray of RGBA8 format as a single attachment to your FBO...

Alfonse Reinheart
08-09-2010, 09:56 AM
Well, you can have a texture2DArray of RGBA8 format as a single attachment to your FBO...

That requires layered rendering, which requires a geometry shader, which requires GL 3.x class hardware. Which he has already said isn't an option.

nickels
08-12-2010, 03:14 PM
Does this help?
4 8 bit into 1 32 bit (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&amp;Number=281430#Post2814 30)

It basically sounds like the same thing I am doing: stuffing 3 8 bit lightmap values into a 32 bit float. Except you have one more to store. Should work though, by the law of conservation of bits :p