To do some real world tests and improve the lightmap generator of irrEdit
a bit, I modeled a small test level and placed a lot of lights into it. Unfortunately after about the 10th import of 3D data and the 20th added light, all new lights started to get 'dark' somehow. But only when using Direct Lighting, lighting without shadows had no problems. It looked like this, the light in the middle has the same brightness as the two in the background, but it influenced the scene only very subtile.
That was pretty strange. Because the level was quite huge already, and in the last 3D data import I had seen some very degenerated triangles in the geometry which I didn't create, I suspected some weired geometry to make the irrEdit collision engine (simply a collision manager optimized for raycasting) go mad. So I plugged it out and replaced it with the irrlicht buit in collision manager
. The result needed some more seconds to calculate, but it was the same. Strange.
Then I reduced the test scenario by creating a new scene, importing the part of the mesh where the problem happened, placing lights at that positions and retried. The problem disappeared. Confusion. I loaded the original scene, reduced it to the same test scene by deleting not used parts but the problem still was there. More confusion.
Ok. So, why the hell didn't the light rays of that single light reach the walls? Idea: Because fortunately we are using a very flexible 3D engine
under the hood and this is possible by adding only one line of code, lets just create a small white cube at the vertices of every triangle hit by the light. Just to see where the light will stop. Result:
Do you see it? All light rays stopped directly near the light! And even more strange: They form the shape of a cube! I mean, I would have understood it if the white cubes where arranged like a sphere or something similar, but a cube exactly enclosing the light? Unlikely.
And now I knew. The problem was not a bug. It was a feature of irrEdit. Stupid me. And somehow I had clicked and enabled it for that light:
In irrEdit it is possible for every object to occlude the light. And 'all objects' of course also includes lights. Which is pretty senseless, a light occluding itself makes it a bit.. ahem, dark. Shadows in irrEdit with directLighting have an adjustable opacity value, and it's at 0.8f by default, which caused that light not to be 100% dark but lighted the scene very subtile.
Conclusion: Cool, I don't even know all the features of the product I wrote myself. To prevent such a situation for users and for my stupid self in the future, and because it doesn't make a lot of sense I now disabled the possibility to enable this feature for lights.