HLSL semantic & Xna data type problem

Started by
5 comments, last by bdubreuil 11 years, 10 months ago
Hello,

I'm actually trying to pass a byte into my vertex shader's input, but because I didn't see any semantic of the byte data type, I'm trying to pass an uint. I have a little problem with Xna when I try to pass my uint : I don't see any kind of vertex element format that is close to be like a uint. Everything things I see are floating points or vectors. How can I pass my uint if there is no vertex element format for this type of data? Also, is there a way I could pass a byte (without a semantic) into my vertex shader's input?

Thank you,
thecheeselover

Hide yo cheese! Hide yo wife!

Advertisement
DX9 shaders don't support integer operations or data types, they only work with floating point. Consequently, all vertex element formats will either specify a floating point format or will convert from integer to floating point. You can use the uint type in your HLSL code, but when the shader is compiled it will only use floating point instructions.

DX9 shaders don't support integer operations or data types, they only work with floating point. Consequently, all vertex element formats will either specify a floating point format or will convert from integer to floating point. You can use the uint type in your HLSL code, but when the shader is compiled it will only use floating point instructions.


What about DX10 shaders? Do they support integers or it's the same as DX9? Also, if I use a half (half float), will the shader still convert it into a 32 bit float?

Thank you! :)

Hide yo cheese! Hide yo wife!

DX10 does have integer support.

The half data type will have the precision of at least a 16-bit float, on some hardware it will be higher. If you need more precision use floats.

DX10 does have integer support.

The half data type will have the precision of at least a 16-bit float, on some hardware it will be higher. If you need more precision use floats.


Thank you. Now for my main questions:

How can I pass a uint from Xna to my shader if there is no vertex element format for this type of data? Also, is there a way I could pass a byte (without a semantic) into my vertex shader's input?

Hide yo cheese! Hide yo wife!

A float can't represent the full range of values of a uint, and DX9 shaders can only work with floats (and half floats). You'll start losing precision once you go over 2^24. That means passing a uint to a DX9 shader isn't possible. However you can convert it to a float first and then pass it over if you don't need the full range of values.

A float can easily represent the full range of values of a byte, so just convert it to a float and pass it to the shader in any way you want.

What are you trying to achieve by doing this?
I only want to pass a byte for each vertex and then use a switch statement to check if the value is 0, 1, 2, 3, 4 or 5.

Hide yo cheese! Hide yo wife!

This topic is closed to new replies.

Advertisement