Jump to content
  • Advertisement
Sign in to follow this  

d3d10 input layout

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

I have a color variable (D3DXCOLOR) in my vertex and its value is [0,255].

Is it possible to pass it into my shader and have it automatically be interpreted as a value from [0,1]?

I can just normalize it to [0,1] at initialization but I would like to know if I can avoid doing that.

I've tried setting up its input element description as one of these :

with its byte offset as
PrevElementOffset += 4

and the color components are still in [0,255]

but my mesh doesn't render.

(It does render if I normalize it [0,1] and use DXGI_FORMAT_R32G32B32A32_FLOAT and PrevElementOffset += 16 )

Is it possible doing it that way or am I stuck with normalizing it at initialization?

Share this post

Link to post
Share on other sites
The D3DXCOLOR struct is made up of 4 float's. So yeah it's not going to work if you use a format that specifies 4 8-bit integer components. The only way you would be able to use it directly is by specifiying a format with 4 32-bit floats. However it has a casting operator for DWORD, which lets you convert it to a 32-bit integer with 4 8-bit unsigned components. This would let you use the DXGI_FORMAT_R8G8B8A8_UNORM format and the shader will interpret it as [0,1] values. However it requires that your values in the D3DXCOLOR color struct are of the range [0,1] before casting.

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!