Jump to content
  • Advertisement
Sign in to follow this  
Meowza

Point light

This topic is 3216 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
[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);

This just gives me black. I check in PIX and the normals are correct.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!