Jump to content
  • Advertisement
Sign in to follow this  
MrPossoms

float decomposition in HLSL?

This topic is 2828 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!