Game Development Community

Multiple lightsources & light attenuation

by Kzoink · in Torque X 2D · 07/04/2007 (9:35 pm) · 2 replies

What is the limit on the number of lightsources (specifically, point lights) and how does one attenuate the light? I see what we have is ambient color, diffuse color and radius, but no intensity... I have tried using the radius and distances to scale intensity with not so good results. Having the intensity tied to the position is rather inflexible, as you can't have a close-by light that is dim. And trying to use radius to get a light of less intensity is pointless as unrealistic results can be seen when objects caught in the radius get illuminated very brightly while those outside get absolutely no light due to the inverse square lighting model and the fact that the light is full intensity when close in.

I ask because it is crucial my game have multiple simultaneous point lights (as many as possible) that can be of various intensities and colors. Would it be difficult to give the lights an intensity value?

I am also getting some strange behavior in that multiple lights do not seem to behave well together. Especially mixing the directional light along with a point light. Directional seems to overpower the point lights almost completely and steal away the qualities that make the lighting look interesting.

Point lights seem sometimes to mix properly and sometimes the latest light that has been added causes the others to turn off, leading me to believe there is some sort of limit to the number of active lights that can be rendered on an object at once, but I haven't found the exact cause to that yet. I suspect it has something to do with LightManager.GetBestLights...

#1
07/06/2007 (10:07 am)
Objects support up to 8 lights when using DefaultEffect. The light manager selects the best 8 lights (per-object) if there are more than that in the scene.

The intensity is tied to the diffuse and ambient colors, you can scale them together or independent of each other.

Directional lighting simulates sunlight, if the color and ambient values are high it will wash out other lights. Try reducing the color and ambient values.
#2
07/07/2007 (5:57 pm)
Thanks John. That helps a lot. I didn't realize the color's brightness would translate to brightness of the light source.

Is there any chance of a color picker making its way into TXB? X, Y & Z float values for RGB color values are a little removed from the whole concept of color and it's not very artist/level designer friendly... It would also be nice to be able to set RGB values as integers, and even nicer if there was hue, saturation and brightness either as integer fields or as a color picker like in Photoshop.

Come to think of it, making the integer field solution is just a matter of inheriting from LightInfo class and exposing a couple new fields...

The color picker kind of goes back to my suggestion for a plugin interface for TXB. I really think it is needed, so that we as a community can extend the editors to do things that haven't been implemented yet...

While I'm making a wish list, I might as well add that it would be nice to have a lighting preview in TXB... I don't know how feasible it is, but it would be really nice.