[source = "csharp"]
Material m = new Material();
m.Ambient = new Color4(1f, 1f, 1f, 1f);
m.Diffuse = new Color4(1f, 1f, 1f, 1f);
device.Material = m;
device.SetRenderState(RenderState.Lighting, true);
device.SetRenderState(RenderState.Ambient, Color.White.ToArgb());
device.SetRenderState(RenderState.AmbientMaterialSource, ColorSource.Material);
device.SetRenderState(RenderState.DiffuseMaterialSource, ColorSource.Material);
Light light = new Light();
light = new Light();
light.Type = LightType.Point;
light.Position = new Vector3(0, 0, -1);
light.Ambient = Color.White;
light.Diffuse = Color.White;
light.Range = 500;
light.Attenuation0 = 1f;
light.Attenuation1 = 0f;
light.Attenuation2 = 0f;
//light.Direction = new Vector3(0, 0, 1f);
device.SetLight(0, light);
device.EnableLight(0, true);
Point light
Hello trying to get a point light to work. My game is 2D so I just have a camera facing a plane of squares.
I have each square a normal that is pointing towards the camera (I guess this is right way). And a material with ambient and diffuse set to white.
here is my code
This just gives me black. I check in PIX and the normals are correct.
The light must be on the same side of the squares as the camera and, since it's a point light, close enough to the squares to illuminate them.
Light light = new Light();
light = new Light();
Not related to your problem...but not good.
light = new Light();
Not related to your problem...but not good.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement