float decomposition in HLSL?

Started by
0 comments, last by MJP 13 years, 3 months ago
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!
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.

This topic is closed to new replies.

Advertisement