Sign in to follow this  
thecheeselover

HLSL semantic & Xna data type problem

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[quote name='MJP' timestamp='1339917947' post='4949966']
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.
[/quote]

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! :)

Share this post


Link to post
Share on other sites
[quote name='Adam_42' timestamp='1339941641' post='4950019']
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.
[/quote]

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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

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