Pointlight looking bad in low-poly environnements


I added pointlights as headlights to a car in my game. They work fine in most areas, but when I drive trough an area in which the polygons that make up the level are very big, it looks bad. It looks like the light is fading from a high intensity too a low intensity and back. I tried making the material high-quality, but it didn’t work. Vertex lighting is off.

Here’s a video too show what I mean:


How can this be solved?

Did you just add them and do not moddify them during gameplay?

If so then what did you attach them too? Maybe it’s attached to a wheel, thus the rotation…

Others with more knowledge will have to chime in appropriately, but since potentially misleading paths (potentially) are being offered, I thought I’d offer what might really be going on… even if incomplete.

Even though lighting is calculated per pixel it is based on values that are setup per vertex… even for non-vertex lighting. The varying variables that are used to paint the pixels are interpolated linearly. A lot them are renomalized but I think things like light distance, etc. are at best going to be a loose approximation… at worst will be just plain wrong (as in your case).

It’s probably the case that point lighting will do better if you have more polygons. Fortunately, any graphics card in the last decade can tear through a few extra polygons without issue… so increasing your poly count won’t be as much of a negative as you might think.

@beniboy: The new lighting system (in issue 510) will have an option to compute the light direction in the fragment shader to alleviate such issues.

You could also give the MultiPassParallelLightingRenderer of Project: RealSlimShader a try. It calculates lighting in the fragment shader (in parallel). PointLights and SpotLights are looking good even on a single large triangle.

Edit: RealSlimShader also doesn’t calculate the lighting direction in the fragment shader. Sorry for writing nonsense. But… nice idea. :smiley: