Archived

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

Carlo Comino

Can't understand spot lights !!!!!!!

Recommended Posts

Carlo Comino    122
Hi everyone, I''m new about direct3D programming, I have some questions about spot lights usage: 1) first of all: where can I find a complete documentation about lights usage ? 2) I created a 2d Wall, the vertices are placed along the z Axis: for example: -100, 100, 100 100, 100, 100 100, -100, 100 -100, -100, 100 the spot light is placed at 0, 0, 0 with orientation 0, 0, 1 and up normal 0, 1, 0, Umbra cone angle = .2 and penumbra cone angle = .4 My problem is that the 2d wall is not illuminated by the spot, but if I rotate the spot (same position) The wall is illuminated when the spot has strange and non realistic orientations. Where do I wrong ? Does someone have an example on using spot lights ???? I know that perhaps my post is too generic, but I''dont know which other informations to give to be more clear...

Share this post


Link to post
Share on other sites
neneboricua19    634
As far as complete documentation on lighting, the DX SDK has a section on the different kinds of lights there are and how to use them.

The problem you''re seeing is that D3D calculates lighting at the vertices of each triangle. So if you have a big wall and point your light at the middle of the wall, then you may not even see the effects of the spot light because the light is calculated at each vertex of your wall and then interpolated across.

If this seems a little confusing, there is a sample in the DX SDK called LightVS. The sample uses vertex shaders to illustrate some lighting principles. I''m not telling you to go through the code and figure out how to use shaders (though it would be good for you to do in the future).

Just run the sample and play with the parameters it gives you. Specifically, change the type of light it uses to "spot light" and switch to wireframe mode. Then increase an decrease the number of triangles in the scene. You''ll see how the lighitng changes depending on how many triangles are in the scene.

neneboricua

Share this post


Link to post
Share on other sites
dave    2187
To provide a helpful answer.

I had the same problem. To Get effective lighting effects i''d say you need to use a mesh for the panel you have described. With a mesh that uses a vertex buffer u can simply calculate the coordinates of a panel.

I wrote an algroythm that filled a vertex buffer with panel vertices for any size panel and for any density of vertices.

I have found it really useful.

If you''re interested email me at ace_lovegrove@hotmail.com.

ace

Share this post


Link to post
Share on other sites