Animated Lights + getDynamicLight bug ?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
sobieh
Posts: 54
Joined: Sat Feb 09, 2008 11:12 pm

Animated Lights + getDynamicLight bug ?

Post by sobieh »

I have noticed that all dynamic lights are sorted by distance between them and the camera by code:
CSceneManager.cpp
...
if(LightManager)
{
LightManager->OnRenderPassPreRender(CurrentRendertime);
}
else
{
// Sort the lights by distance from the camera
core::vector3df camWorldPos(0, 0, 0);
if(ActiveCamera)
camWorldPos = ActiveCamera->getAbsolutePosition();

core::array<DistanceNodeEntry> SortedLights;
SortedLights.set_used(LightList.size());
for(s32 light = (s32)LightList.size() - 1; light >= 0; --light)
SortedLights[light].setNodeAndDistanceFromPosition(LightList[light], camWorldPos);

SortedLights.set_sorted(false);
SortedLights.sort();

for(s32 light = (s32)LightList.size() - 1; light >= 0; --light)
LightList[light] = static_cast<ILightSceneNode*>(SortedLights[light].Node);
}
...
Setps needed to recreate situation:
1. Create 2 dynamic lights (irrlicht shaders support only 2 lights so we need 2 only)
2. Create any mesh and set its MaterialType to NormalMap or ParallaxMap or any other Type which uses getDynamicLight method
3. Add any animator to your lights

What do i mean:
I mean that when your lights are moving they are sorted by their distance to a camera and it wents to a different LightList place (0,1,2...) each time one light get closer or farther to camera than other lights. In the effect the lights will flicker because of change their list index.

The more lights you use the worse it works. More flickering.
This situation doesn't happen with 1 light or static lights.

My question is:
Is that a bug or it should work that way ?
It can be easly fixed by adding LightManager to scene so im just asking.

@thx
Last edited by sobieh on Wed Aug 05, 2009 9:35 pm, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, you have to use the LightManager.
Post Reply