1 Attachment(s)
Can somone help me fix this bug?
I've been following the DirectXGraphics tutorials at www.directx4vb.com But I can't seem to implement lighting in my engine. I've been slaving over this code for a few days now but I can't find the bug. Lighting works in the tutorial's example project but I can't get it to work in mine. Basically I have this:
VB Code:
D3DDevice.SetVertexShader D3DFVF_XYZ Or D3DFVF_NORMAL Or D3DFVF_TEX1
D3DDevice.SetRenderState D3DRS_LIGHTING, 1
D3DDevice.SetRenderState D3DRS_AMBIENT, &H202020
With MainMaterial.Ambient 'mainmaterial is a d3dmaterial8
.A = 1: .B = 1: .G = 1: .R = 1
End With
With MainMaterial.Diffuse
.A = 1: .B = 1: .G = 1: .R = 1
End With
D3DDevice.SetMaterial MainMaterial
in my init proc and I set my light up like this:
VB Code:
Dim Light as d3dlight8
D3DDevice.SetLight 0, Light
Light.LightType = Directional
Light.Diffuse.R = 1
Light.Diffuse.G = 1
Light.Diffuse.B = 1
Light.Range = 1
Light.Direction = vector(0, -1, 0)
D3DDevice.SetLight 0, Light
D3DDevice.LightEnable 0, 1
Then I set up my mesh and start rendering, but the light doesn't work. I generated normals for my mesh as the tutorial said but it does nothing. BTW, it isn't done exactly like that, but the sequence is the same.