Sign in to follow this  

HLSL float bit operations

This topic is 3588 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All, I'm trying to do something like this in HLSL: float val1; -> 0xRRGGBBAA float4 vec1; vec1.x = 0xRR000000 vec1.y = 0x00GG0000 vec1.z = 0x0000BB00 vec1.w = 0x000000AA Is this possible? If so how? Thanks!

Share this post


Link to post
Share on other sites
Which shader model? Only SM4 and above (Direct3D 10) have an integer instruction set, so you only really have slight hacks and fudges to emulate integer bit twiddling using floating point numbers. It's particularly dodgy on pre-SM3 hardware which doesn't have such guarantees on internal precision (e.g. Nvidia had 32bit and ATI 24bit).

What is the bigger problem you're trying to solve? It may well be there is a better compression method you can use...

hth
Jack

Share this post


Link to post
Share on other sites
Thanks for the info jollyjeffers. What i'm actually trying to do is to label each vertex with an index, and render a pre-pass with the index as a 32-bit colour value, and use this map to do some sneaky(tm) things in later passes.

I'm really not sure if this is possible. One issue is that every pixel rendered would have 3 vertices surrounding it, and there should be some way to render atleast 1 pixel for each of those.

Basically I want to uniquely identify all rendered vertices from a bitmap. Is there a (better?) way to do this?

Share this post


Link to post
Share on other sites

This topic is 3588 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this