Billboards w/ lighting, DX Pondering
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.
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).
If your quad is a mesh you can try using D3DXComputeNormals()
or define your own normals (quite easy for a quad):
for an FVF of D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1
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; rectPoly->Unlock();
for an FVF of D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement