Skip to main content
GameDev.net gamedev.net
🔒 Locked

DX lightning problem

Started by Radan Mar 14, 2003 at 1:03 PM 7 replies 350+ views
Original Post
Radan
Radan
I create some cubes. Each triangle vertices have the same normal as the face, perpendicular to it. Then I put a single directional light to shine on them and set to Goraud shading mode. Something very wierd happens. Every side of the cube gets shaded diferently. I.e. top face of the cube gets shaded in roughly the direction of my light, but side faces get shaded as if the light is coming from a opposite direction. My first guess is that the problem is with Triangle normals but I can''t see why. Does anyone have any idea whats the problem, at least get me started. I''d post some code but I''m not using VC but Delphi with DelphiX (Delphi library for DirectX).
-----------------Always look on the bright side of Life!
Radan
Radan
Let me just check something.

Normals are nomarlized when total length of the normal vector is 1. Am I right?

If that's the case then my normals are normalized.
I know they all point out of the cube because Face culling is enabled.

Any ideas, anyone, I'm really puzzled by this problem.


[edited by - A Guy from CRO on March 20, 2003 5:15:30 PM]
-----------------Always look on the bright side of Life!
Radan
Radan
final bump

Any idea to get me goin will be appreciated.
Post anything you think off. If you point me in right direction, even by accident, I''ll probably be able to solve it myself.

cheers
-----------------Always look on the bright side of Life!
Osc
Osc
This sounds very odd if you're using D3DLIGHT_DIRECTIONAL, but perfectly normal for D3DLIGHT_POINT.

Are you sure that your materials are set up properly (including D3DRS_DIFFUSEMATERIALSOURCE and D3DRS_SPECULARENABLE)?

I've only used DX with C/C++, so apologies if these things don't apply in DelphiX.


[edited by - Osc on March 19, 2003 7:37:54 AM]
Syrillix
Syrillix
are you using indexed triangles? if so, and your only specifying the vertices once, then there only gonna have 1 normal. youve got to know which face you are using the normal from for the vertex.. either that or calculate per-vertex normals.
Get busy livin' or get busy dyin'... - Shawshank RedemptionIf a man is talking in the forest, and no woman is around to hear him, is he still wrong? - UnknownFulcrum
Radan
Radan
I a single light D3DLIGHT_DIRECTIONAL, that''s why its so odd. But I don''t see why woould it be normal with D3DLIGHT_POINT. I have a case of two adjacent faces being lighted as if the light is coming from two opposite directions.

All of the things from C/C++ DX should apply as DelphiX is just a wrapper.

A.P. I am not using indexed triangles. I am storing vertices per triangle, i.e. I store a face as 3 vertices, so there shouldn''t be a problem of wrong normals being used on face''s vertecies.

I know that''s inefficient but I will deal with it later.
-----------------Always look on the bright side of Life!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.