Jump to content
  • Advertisement
Sign in to follow this  
compiler

Lightning without normals?

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

i just rendered a little scene with a spotlight and a cube, which is in the light cone. the cubes vertices doesnt include a normal vector and are rendered with these lines: device.SetTexture(0, cubeTexture); device.VertexFormat = CustomVertex.PositionTextured.Format; device.Transform.World = Matrix.Scaling(0.7f, 0.7f, 0.7f) * Matrix.Translation(0, 0.7f, 0); device.DrawUserPrimitives(PrimitiveType.TriangleList, 12, vCube); althought the vertices doesnt include normals and i never set a vertexformat with normals on the device the cube is lit by the spotlight! how is this possible? i always thought normals are necessary to get correct lightning.

Share this post


Link to post
Share on other sites
Advertisement
Hi,

I see 2 things possible,

1. You have not enable lighting? SetRenderState(D3DRS_LIGHTING, TRUE);
2. You're using a Shader to do it.

Else i dont know, and it's pretty weird :P

Don't count on it to be always working...

Good Luck,
Jonathan

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Since your vertices do not include normals, lighting will not work. This is because the lgihting is simply the dot product of the light vector and normal vectors of your object. If you do not include this information the lighting pipeline has nothing to calculate the lighting from.

The cube is not shaded at all, purhaps yo think it is being lit (because there is no lighting) and therefore at full brightness? Or purhaps it could be undefined behavior (using lighting on a traingle with no normals). However I would say something is going on - Purhaps when you create a cube via the D3DX function it assigns normals? Do you render the scene with your FVF format correctly (the one without normals)? There are many things it could be.

Quote:

Don't count on it to be always working...


exactly

Share this post


Link to post
Share on other sites
Does ambient lighting still work without normals? Maybe you've got that set somewhere. Its been a while since I've done any fixed-function lighting. But yeah, check that, and check if lighting is enabled or not.

Share this post


Link to post
Share on other sites
There are many things that could be contributing to what you're seeing.

For instance, since you're texturing the cube, it could be that you've set the texture blending mode to COPY instead of MODULATE, in which case the color of the texel alone will be used to fill the triangle.

If lighting is disabled, the vertex color will be passed through to the texturing unit. Since your vertex doesn't contain a color, the default value of opaque white (0xffffffff) will be used.

If lighting is enabled, and since you don't have a normal in the vertex, the vertex won't be lit with either diffuse or specular lighting calculations. However the ambient light could still come into play. Whether or not the ambient would have any effect would depend on whether you've set D3DRS_AMBIENT (default is 0) and whether your current material has nonzero ambient values.

The short of it is, we'd need to see the rest of your code or a dump of the current renderstate settings to tell you exactly what's going on.

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.

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!