Using the Device Material instead of Vertex Color

theHollow

Member
Joined
Jan 4, 2005
Messages
9
Lighting problems

Hi there
I have problems adding lights on my project. I have created a simple cube with different colors on the different sides. Very simple. And it works very well if I have set D3Ddev.RenderState.Lighting = False (my Direct3D device is called D3Ddev).

So I tried to set the Renderstate.Lighting to true. As expected, my object became black. So I added this:
D3Ddev.Lights(0).Type = LightType.Directional
D3Ddev.Lights(0).Diffuse = Color.White
D3Ddev.Lights(0).Direction = New Vector3(0.0F, 0.0F, 1.0F)
D3Ddev.Lights(0).Update() Commit()
D3Ddev.Lights(0).Enabled = True

But it still dont work. I believe I have misunderstood something, and that I must apply the light to something or...I dont know.
I have noticed that the D3Ddev.DeviceCaps.MaxActiveLights = 0.

Can anyone help me? I have VB.NET and DirectX 9c (december 2004). Does anyone have a VB.NET project that I can look at?

- theHollow
Split from http://www.computerhelp.forum/showthread.php?t=72399
 
Last edited by a moderator:
Ah...
I have found out that I have to use PositionNormalColored instead of PositionColored. If anyone can tell me why, and maybe the differences between PositionNormalColored and PositionColored? I dont quite understand all the parameters of PositionNormalColored.

Still learning :rolleyes:

- theHollow
 
IIRC PositionNormalColored tells directx how to handle the light hitting the surface (reflection etc)
clicky is probably worth a read as it makes a lot more sense than my explanation.
 
ThePentiumGuy said:
The Normal (aka rhw) parameter is the perpendicular direction in which you want the light to hit it at. Err.. ok, here:
The normal is NOT the same as the rhw and is not even vaguely related. Rhw is the fourth component of a screen space vertex (Transformed).
 
Back
Top