Archived

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

Oldfella

DX9 Lighting Questions

Recommended Posts

Gidday, Hope you are all well. I have been studying the SDK demo on lighting,and have implemented it successfully into my test Engine. I know how to use the types of lights and how to set them up. My question is- Say I have a hallway with 12 animated fires/torches on the walls ,I want to illuminate these individually. Should I Create D3DLight light_1,light_2 through to 12. As far as I know, I cannot get 12 lights out of Light_1 ? If I needed 30 lights for a level, without using lightmaps, ect what would be the best way to do this ? Gforce2 64Mb Thanks for your time TakeCare.

Share this post


Link to post
Share on other sites
I think you want to create all 30 lights upon initialization, but only enable the lights that will be visible to the player in any given frame. I''ve heard "The first ten lights are given" as far as resources go, but I''m sure that number changes with technology being used.

Chris

Share this post


Link to post
Share on other sites
If you check the CAPS there is a MaxActiveLights member. If you''re using Software Vertex Processing this will be 0, which means there is no limit. However the more lights that are active, the slower your performance.

For HardwareVertexProcessing, 8 is a very common limit but you should check it at runtime and act accordingly.

Alternately you can fake the lighting. Google for Light Maps.


Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Use pixel shaders! you can get real time per pixel flickering torch light at blazing speeds!

Share this post


Link to post
Share on other sites
you can use spherical harmonics to project a lot of light sources in a single pass. Tom forsyth uses this technique to simulate 20 light sources.I think he has papers about this but I am not sure. you can see the directx sample.

Share this post


Link to post
Share on other sites
Hi,
Thanks for the quick responses and good information.
I am using SoftwareVertexProcessing at the moment, so I will see how many lights I can get away with.
Is the 8 Light Max Total or per Object rendered with lights,whielst using HardwareVertexProcessing?
I noticed in the SDK that 2 lights are made from D3DLIGHT light;
SetLight( 0, &light );
SetLight( 1, &light );
Is this the same as I was to create D3DLIGHT light1,light2;
SetLight( 0, &light1 );
SetLight( 1, &light2 );
If not what are the differences.

I have also learnt that the higher the Poly count, the better the lighting effect.
Out of the methods that have allready been suggested to me, which would give the best result on low poly objects ie large single poly wall, especially if I was trying to "spotlight" the wall?
I only have a GeForce2 64Mb so I dont thinck it will support
pixel shaders.
That Spherical Harmonics sound interesting, I''ll see what I can Google about it as well.
Thanks
TakeCare

Share this post


Link to post
Share on other sites
It is the hardware that limits the lights to 8 so you can actually create as many D3D lights as you want but only have 8 turned on at once. A nice manager class would be called for here to choose which are on and off. Ultimately, as you say, the polygon density is going to have a big effect on how good your lights are as these lights work by altering colours at each vertex. To avoid this, as someone else suggested, lightmaps can be used but they lose the dynamic nature of the lights. Pixel shaders are the future but with your hardware may be impractical. I would probably suggest precomputing as much lighting as you can and then use your D3D lights for dynamic situations.

Share this post


Link to post
Share on other sites
quote:

SetLight( 0, &light );
SetLight( 1, &light );
Is this the same as I was to create D3DLIGHT light1,light2;
SetLight( 0, &light1 );
SetLight( 1, &light2 );



They''re not quite the same--the first method will give you two different lights, yes--but both lights will have exactly the same location, direction, attenuation, etc. Your 2nd method will allow you to create lights with individual properties.

Share this post


Link to post
Share on other sites
Thanks Guys,
I have a pretty good understanding now.
For the time being I will write a light manager.
I have started researching lightmaps. Looks like mixing light maps and Dynamic lighting mix, may be the way for me to go until I get around to getting a decent Video Card.

TakeCare.

Share this post


Link to post
Share on other sites
If a single mesh is affected by more than 8 lights (the max on most hardware) then you could always draw the mesh multiple times using the different lights.

Share this post


Link to post
Share on other sites