Jump to content
  • Advertisement
Sign in to follow this  
KumGame07

Int - float with shader

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

Hi gang, In my application, texture factor is getting used for modulating the fragment color. d3dDevice->SetRenderState(D3DRS_TEXTUREFACTOR, someDWORDval); Obviously, no fragment shader is used for this rendering. Now I want to do this with a fragment shader. So I'm passing 'someDWORDval' as one of the shader constants. But whenever I pass this value as a float, I do not get the desired result. But passing 'someDWORDval' as int to the shader makes the result better (not exactly the same as FFP) So my question is what is the range of values for integers in the shaders? How do I pass a long int from my application as a float to the shader?

Share this post


Link to post
Share on other sites
Advertisement
Most shaders don't have native support for integers (until you get to DX10 hardware), and instead emulate them using their native floating-point format (usually 32-bit floats). Therefore you'll probably want to convert your D3DCOLOR to a vector of floats outside the shader, and pass that in via SetFloatArray or SetVector. You can either do the shifting and casting yourself, or create a D3DXCOLOR by passing in the D3DCOLOR to the constructor.

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!