Sign in to follow this  

float decomposition in HLSL?

This topic is 2541 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

Hello everyone!

Here is my dilemma. I'm writing a GPU based particle system in HLSL to be used in XNA. I'm using a set of vertex textures which hold the data pertaining to properties of a particle such as initial position, rotation, scale and the like.

However, my attribute texture is where I'm running into a bit of trouble. Each pixel in the texture is of the type float4, but I need more than 4 numbers to really do what I want with each particle. The r, g and b values in the attribute texture have been used and have to remain floats. The values I need to represent with the alpha, on the other hand, do not need the precision of a floating point number.

So I was thinking. Wouldn't it be possible to have HalfSingle array on the CPU side of the program which is holding these values that I need on the GPU, and use some unsafe C# code and pointers to compose that HalfSingle array into a float, then set it to the alpha value for a specific pixel. From there in the HLSL code I would need to decompose this float in to two halfs.

This is where my problem lies, since HLSL does not support pointers how could I do this? Is it possible?

Thanks in advance!

Share this post


Link to post
Share on other sites
I'd imagine doing this would really suck in XNA, since you only have access to shader model 3.0 which only has floating point instructions. So you'd have to manually extract the bits and convert from the half-precision values to single-precision (using only floating point ops!), which doesn't sound like fun. Shader model 5.0 supports this kind of thing natively.

Share this post


Link to post
Share on other sites

This topic is 2541 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