Jump to content
  • Advertisement
Sign in to follow this  
Halsafar

D3DVSD_CONST and SetVertexShaderConstant

This topic is 4775 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 see this in vertex declarations for vertex shader: D3DVSD_CONST(0,1),*(DWORD*)&c[0],*(DWORD*)&c[1],*(DWORD*)&c[2],*(DWORD*)&c[3] This sets the c0 register to contain 1-128bit value. &c[0]--&c[3] set those values repsectively. But then I get confused because I see this right after: m_pd3dDevice->SetVertexShaderConstant( 0, &vZero, 1 ); I don't get it....Is there 2 ways to set these values?

Share this post


Link to post
Share on other sites
Advertisement
The first method, constants defined in the declaration, defines the constants that get set when the shader is set on the device. You can use this for constant constants (More on this below).

The second method can be used to dynamically change the constants after you set the shader - you use this for variable constants.

Now this seems a little bit weird: constant and variable constants?
Constant constants are constant from both the points of view of the application and the shader. For example, pi is a constant constant.

Variable constants are variable from the point of view of the application, but constant from the point of view of the shader. For example: The camera's position. The camera's position changes each frame so it's variable for the application. On the other hand, the shader is called on a static snapshot of your scene, in a single frame. So to the shader, the camera's position is a constant.

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!