Jump to content
  • Advertisement
Sign in to follow this  

Help with Direct3D Normals

This topic is 4470 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, I know that this is like one of the simplest, most basic concepts, but I just can't get it to work with Direct3D. I haven't been in touch with 3D math/programming for more than 6 months now, so do correct me wherever I'm wrong. From my understanding: DirectX uses the LH coordinate system, right? Which means, Vertices facing the front(viewer) should be specified in CW-order (As Z increases, it moves away from the viewer) So I'm trying to create a simple triangle facing the viewer:
    // Format {posX, posY, posZ, normVector, color}
    // Using -1 for Z normal, because I want it to face the viewer, the negative
    // direction of Z.
    NormalVertex vertices[] = {
        {0, 5, 0, D3DXVECTOR3(0,0,-1), 0xffff0000},
        {5, -5, 0, D3DXVECTOR3(0,0,-1), 0xff00ff00},
        {-5, -5, 0, D3DXVECTOR3(0,0,-1), 0xff0000ff}

But by doing this, it is drawn as nothing more than a dark triangle. I had to change the Z-component from -1 to 1 for the triangle to show up. Also, please note that: 1. I'm using LH for projection and view 2. Camera and light is set at {0,0,-30} Thanks.

Share this post

Link to post
Share on other sites
the winding order of the vertices and the normal direction are independent to directx. you can have clockwise or counter clockwise or no culling and face the normal in whatever dir you want. it's probably what dir you have the light facing that is mattering here.

D3DRS_CULLMODE render state determine culling (clock wise, counter, none)

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!