Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Greg K

Vertex Shaders

This topic is 5814 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 am just starting out with vertex shaders and before I used to just let directX do everything with the matrices and it worked fine. Now that I am using vertex shaders I need to do matrix stuff myself. I just want to render a triangle with a diffuse colour. Sounds easy, right? Right. Here is my vertex shader. Straight outta the DX help file: vs.1.1 ; Vertex shader version 1.1.\n\ dp4 oPos.x, v0, c0 \n\ dp4 oPos.y, v0, c1 \n\ dp4 oPos.z, v0, c2 \n\ dp4 oPos.w, v0, c3 \n\ mov oD0, v1 ; The variable color.\n" I edited it to get the diffuse colour from the vertex instead of a constant. The triangle renders fine except I don''t know what matrix to pass the vertex shader. I am not quite sure what it is I am doing. I tried passing it the transposed View matrix but that only rendered it (half) correctly when the z was within 1 unit from it. I tried not transposing the matrix and when you move left to right the triangle gets skewed towards you in the opposite direction than you were moving. Any advice would be great. Thanks. -Greg Koreman

Share this post

Link to post
Share on other sites
from my book:

//Create the complete matrix
D3DXMATRIX ShaderMatrix = m_WorldMatrix * m_ViewMatrix * m_ProjectionMatrix;

//Get the transpose
D3DXMatrixTranspose(&ShaderMatrix, &ShaderMatrix);

//Pass the transposed matrix to the shader
m_pD3DDevice->SetVertexShaderConstant(0, &ShaderMatrix, 4);

Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces"

Share this post

Link to post
Share on other sites
I am seriously thinking about buying your book. Thanks.
p.s. (You should put a chapter or two online so people can evaluate your writing style)

Share this post

Link to post
Share on other sites

  • 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!