HLSL pack two values into one component of a 4x16_UNORM target

Started by
11 comments, last by B_old 14 years, 11 months ago
Quote:Original post by Nik02
Quote:Original post by B_old

I can't say all my coef-parts are in the first x bits and all the other parts are in the last x bits



Oh but you can... ;)

Note that you can both output and input different representations of the values, regardless of where they come from or go to.

The way I understood it, as*() won't change the way the bits are laid out. Isn't it problematic when the shader variable is 32bit but is gonna be output to 16bit?
I guess I have to see a practical use of as*() in order to get some inspiration first.
Advertisement
The very point here is that the as* functions won't change how the bits are laid out. Remember, even though floats have more complex representation than ints, they are still constructed entirely from bits with well-defined algorithms.

Ask yourself, what stops you from constructing floats and halfs from bits yourself? And following that, what stops you from writing them out in any format, provided adequate space is available in the destination? When you can answer these, the solution may well become obvious [smile]

Niko Suni

I guess you are right. You gave me something to think about.

Regarding my original problem I changed tactics and rearranged my rendertargets, so right now there is no need to pack any values.
Thanks for the help!

This topic is closed to new replies.

Advertisement