Sign in to follow this  

D3DVSD_CONST and SetVertexShaderConstant

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

This topic is 4557 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.

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