Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Some problems using lights in Managed D3D9

This topic is 5458 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

What I have currently is a single quad(a trip-strip) rotating around the y axis, and its location is at the origin. with a point light at (0,0,-10) , and the view at (0,0,-50). The vertex format of the quad is PositionNormalTextured. The problem is that the light only shows up on one side of the quad, and when the quad is perpendicular to the x axis the light flickers between on and off, on the quad until it rotates a few more degrees. This is how I set the vertices:
vertices[0] = new CustomVertex.PositionNormalTextured(-2.0f,2.0f,0.0f,0.0f,0.0f,1.0f,0.0f,1.0f);
vertices[1] = new CustomVertex.PositionNormalTextured(2.0f,2.0f,0.0f,0.0f,0.0f,1.0f,1.0f,1.0f);
vertices[2] = new CustomVertex.PositionNormalTextured(-2.0f,-2.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f);
vertices[3] = new CustomVertex.PositionNormalTextured(2.0f,-2.0f,0.0f,0.0f,0.0f,1.0f,1.0f,0.0f);
and this is how I set up the lighting and material:
System.Drawing.Color color = System.Drawing.Color.White;

D3D.Material material = new D3D.Material();
material.Ambient	= color;
material.Diffuse	= color;
d3dDevice.Material = material;

d3dDevice.Lights[0].Type = LightType.Point;
d3dDevice.Lights[0].Diffuse = System.Drawing.Color.Red;
d3dDevice.Lights[0].Position = new Vector3(1.0f,1.0f,-10.0f);
d3dDevice.Lights[0].Direction = new Vector3(1.0f,1.0f,1.0f);
d3dDevice.Lights[0].Range	= 200.0f;
d3dDevice.Lights[0].Attenuation1 = 0.0001f;
d3dDevice.Lights[0].Enabled = true;

d3dDevice.RenderState.Ambient = System.Drawing.Color.FromArgb(0x202020);
This is using managed DX9 and C# One thing i''m not sure of is the normals that i''m setting for each vertex.

Share this post

Link to post
Share on other sites
D3D will only light object with normals faceing a light. In order to light both sides you will have to render 2 quads one with normals pointing one way and one with the normals pointing the other. BTW this is some thing you will have to do in any of the API''s, it''s not managed DirectX Specific.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!