Jump to content
  • Advertisement
Sign in to follow this  
Koobazaur

DX9 Uneven lighting

This topic is 4237 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 working with the fixed DirectX9 pipeline and the vertex lighting is producing some really shoddy results. That is, when one brush ends and another begis, the two surfaces are light completly differently giving some pretty bad looking results. Now, I understand why this happens (for instance in the picture, the floor in the hallway is narrower than in the room thus the vertexes are closer to light source and end up being brighter), but is there any way around this? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by perkbrian
try Diffuse lighting using shaders...


I have not yet learned how to use shaders and I wanted to hold off for a bit still, is there any way I can fix this problem without resolving to them?

Share this post


Link to post
Share on other sites
The link doesn't work.

Anyway, you could always use a flat normalmap and use DOT3 bumpmapping, which will give you per pixel lighting. With the added bonus of being able to use bumpmaps as well, of course ;)
No idea how you would go about transforming the light vector into tangent space without shaders, but I'm sure it can be done (hopefully without one draw-call per triangle).

Share this post


Link to post
Share on other sites
Oh, just remembered what I used to do. I calculated the light-vector for each vertex, transformed it into texture space, and stored it in the vertices.
As long as the light-source doesn't move you can simply transform the stored vector the same way as the normal. When the lightsource moves you have to recalculate it.

Share this post


Link to post
Share on other sites
I was looking into this and it looks like a very useful technique. Could you, by any chance, point me to some tutorials about bumpmapping/DOT3 ? I was googling it and all I could find were poorly documented source codes for a program at code-sampler. I could go ahead and steal that, but I'd rather know how the thing actually works :)

Share this post


Link to post
Share on other sites
If you check the papers on Nvidia's developer pages there are tons :)

I would really encourage you to get started with shaders though. Using HLSL and the D3DX Effect interface it's quite easy, and it allows you to do things like this MUCH easier.

Share this post


Link to post
Share on other sites
Issues with shaders aside, it looks to me like you simply aren't calculating your vertex normals correctly.

Share this post


Link to post
Share on other sites
Quote:
Original post by gharen2
Issues with shaders aside, it looks to me like you simply aren't calculating your vertex normals correctly.


well, I am using D3DXComputeNormals(mesh, 0)... maybe it screws up due to how the mesh is structured?

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!