Does anyone know if it is possible to apply Direct3D lights to sprites constructed using the Sprite helper class in Managed DirectX Since the class creates a quad for the sprite, I would have thought it possible to light the quad or rather the quad's texture.
I have tried adding a light to my sprite scene and have tried doing this both before and after drawing the sprites. However, I cannot seem to get the lights to work. I have used the following code:
// This is in my initialise section:
m_Direct3DDevice.RenderState.Lighting = true;
m_Direct3DDevice.RenderState.ZBufferEnable = true;
// This is in my render loop:
m_Direct3DDevice.Clear(Microsoft.DirectX.Direct3D.ClearFlags.Target, Color.Black, 1.0f, 0);
m_Direct3DDevice.BeginScene();
Light l = new Light();
l.Ambient = Color.Green;
l.Diffuse = Color.Green;
l.Type = LightType.Point;
l.Direction = new Vector3(0, -1, 0);
l.Position = new Vector3(0, 10, 0);
l.Range = 50;
m_Direct3DDevice.RenderState.Lighting = true;
m_Direct3DDevice.Lights[0].FromLight(l);
m_Direct3DDevice.Lights[0].Enabled = true;
m_Direct3DDevice.Lights[0].Update();
// code for drawing the sprites is placed in here.... I haven't included it for reasons of space.....
m_Direct3DDevice.EndScene();
m_Direct3DDevice.Present();
// End of render loop
All that happens at the moment is that the sprites draw themselves as normal with no application of any light effects.
If it is not possible to light sprites, can anyone suggest how I might fake lighting I'm imagining some Alpha Blending trickery might do the job....
Thanks,
Damien.