DX9 Lighting Questions
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.
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
Chris
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
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
Use pixel shaders! you can get real time per pixel flickering torch light at blazing speeds!
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.
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
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
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.
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.
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement