How to store 8 four bit values in 32 bits?

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,

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.

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??

out.r = (2<<4)*val0 + val1
etc.

???

Well, you can have a texture2DArray of RGBA8 format as a single attachment to your FBO…

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.

Does this help?
4 8 bit into 1 32 bit

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 :stuck_out_tongue:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.