Jump to content
  • Advertisement
Sign in to follow this  

Billboards w/ lighting, DX Pondering

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

Hello. I wonder if anybody can help me to understand why I can't use lighting with the DX9 Billboard sample code. I THINK that part of the lighting problem is because the billboards have no normals. Well, I don't like reinventing the wheel so I like to utilize as much of the DX functionality as possible. I don't ENTIRELY understand this, but I was able to automate normals in mesh rendering by adding a D3DXVECTOR3 to my custom vertex for normals and then calling SetRenderState(D3DRS_NORMALIZENORMALS, TRUE) once. How the HECK does this work, and why the HECK doesn't it work w/ the billboarding sample? Hypothesis: DX uses the normal member of the FVF internally to automatically compute the normals? But at what point in the code does it do this? And how does it know what structures to do it too? Very confusing. Thanks a lot. I haven't been around here much lately but I've always loved this forum when I needed answers.

Share this post

Link to post
Share on other sites
NormalizeNormals doesn't create normals from the vertices (that would be impossible without knowing which faces the vertice touches), it simply NORMLIZES the normal (that is, it normalizes it to a unit length of 1).

Share this post

Link to post
Share on other sites
If your quad is a mesh you can try using D3DXComputeNormals()
or define your own normals (quite easy for a quad):

rectPoly->Lock(0, 0, (VOID**)&v, D3DLOCK_DISCARD);

v[0].position.x = 0.0f; v[0].position.y = 0.0; v[0].position.z = 0.0f;
v[0].normal.x = 0.0f; v[0].normal.y = 1.0f; v[0].normal.z = 0.0f;
v[0].tu = 0.0f; v[0].tv = 1.0f;

v[1].position.x = 1.0f; v[1].position.y = 0.0f; v[1].position.z = 0.0f;
v[1].normal.x = 0.0f; v[1].normal.y = 1.0f; v[1].normal.z = 0.0f;
v[1].tu = 1.0f; v[1].tv = 1.0f;

v[2].position.x = 0.0f; v[2].position.y = 1.0f; v[2].position.z = 0.0f;
v[2].normal.x = 0.0f; v[2].normal.y = 1.0f; v[2].normal.z = 0.0f;
v[2].tu = 0.0f; v[2].tv = 0.0f;

v[3].position.x = 1.0f; v[3].position.y = 1.0f; v[3].position.z = 0.0f;
v[3].normal.x = 0.0f; v[3].normal.y = 1.0f; v[3].normal.z = 0.0f;
v[3].tu = 1.0f; v[3].tv = 0.0f;



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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!