DX9 Uneven lighting

Started by
18 comments, last by Koobazaur 17 years, 1 month ago
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.
Comrade, Listen! The Glorious Commonwealth's first Airship has been compromised! Who is the saboteur? Who can be saved? Uncover what the passengers are hiding and write the grisly conclusion of its final hours in an open-ended, player-driven adventure. Dziekujemy! -- Karaski: What Goes Up...
Advertisement
try Diffuse lighting using shaders...
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?
Comrade, Listen! The Glorious Commonwealth's first Airship has been compromised! Who is the saboteur? Who can be saved? Uncover what the passengers are hiding and write the grisly conclusion of its final hours in an open-ended, player-driven adventure. Dziekujemy! -- Karaski: What Goes Up...
not that i know of... maybe someone else knows...
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).
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.
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 :)
Comrade, Listen! The Glorious Commonwealth's first Airship has been compromised! Who is the saboteur? Who can be saved? Uncover what the passengers are hiding and write the grisly conclusion of its final hours in an open-ended, player-driven adventure. Dziekujemy! -- Karaski: What Goes Up...
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.
Issues with shaders aside, it looks to me like you simply aren't calculating your vertex normals correctly.
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?
Comrade, Listen! The Glorious Commonwealth's first Airship has been compromised! Who is the saboteur? Who can be saved? Uncover what the passengers are hiding and write the grisly conclusion of its final hours in an open-ended, player-driven adventure. Dziekujemy! -- Karaski: What Goes Up...

This topic is closed to new replies.

Advertisement