About normal map light manager

Post your questions, suggestions and experiences regarding to Image manipulation, 3d modeling and level editing for the Irrlicht engine here.
Post Reply
fskqj
Posts: 4
Joined: Sat Jun 07, 2025 10:46 pm

About normal map light manager

Post by fskqj »

When the normal map nodes are made, if the light count is not so many, and the world is small, everything works perfect; however if I add more lights and make the world more big, the lights will be automatically switched on and off when I (camera) walk away or close to a place in 3d world, and the node color is changed unexpectedly, at same time the world is stuck slightly (performance is downgraded).

At first, I didn't know why. Then I guessed the irrlicht engine will do automatical special light management for normal map.

So I made an empty light manager to override it when using normal map:

Code: Select all

// An empty light manager to override system light manager
class my_light_manager: virtual public irr::scene::ILightManager
{
};

auto * lm = new my_light_manager;
smgr->setLightManager(lm);
lm->drop();
lm = nullptr;
Then the performance is back, and the normal map rendering result is not unexpected.

I feel this solution is a hacking way, is there a direct and not hacking way?
CuteAlien
Admin
Posts: 9934
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: About normal map light manager

Post by CuteAlien »

Hm, only difference should be that lights are sorted by distance to the camera. Maybe if that isn't done the lights which are used in your scene are so far away they don't even have any influence? That might explain speed difference (not sure). Light sorting should be fast unless you have thousands of lights.

You can check what it does exactly if you look at the CSceneManager::drawAll() function a bit, it's pretty simple, basically just doing all the render-stages one by one.

One thing to note about the build-in normal-map shader is that it only uses 2 lights to my knowledge. So one solution might be to write your own shader. Other solution is making sure your scene is modeled in a way that you generally only have 2 active lights per room and make sure they are the closest ones.

And you already found last solution - write your own light-manager.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply