Lightmapping frustration

Blitz3D Forums/Blitz3D Programming/Lightmapping frustration

"LightBulb(Demo) to 40 minutes to lightmap the same model, then light bleeds under the walls!"

I'm not saying lighbulb is good or not... I haven't looked at it lately. But I'm pretty sure I've seen a screenshot form giles with light bleeding under a walkway connected to a wall in a red room.

But worse, Giles has problems with shadows leaking everywhere. Ie, every corner is darker than it should be. Looks wrong. Looks like Unreal actually. Gives it kind of a cartoonish look.

The problem is sampling texels from only one point.

If you sample with one point, either you can look to see if the texel can see the light, which results in light bleed, but no dark corners, or you look to see if the light can see the texel, which results in shadow bleed, which ends up being a much worse problem than light bleed because every single corner in the level has texels that are half in shadow. Of course some people like the look of shadow bleed, but nobody seems to like the look of light bleed, because light bleed makes the level seem non-solid.

The only way to solve this problem is to sample texels from multiple points, or to create a frustum that contains each texel and then determine if all of the frustrum is blocked from the light source.

I don't know if one could make a frustum method run at an acceptable speed... I'm not even sure how one would do it really... determining how much of the frustum is blocked I mean. But I do know that sampling from multiple points will only increase the time by the number of extra samples you take. So if you take four samples at each corner then you could quadruple the amount of work you have to do... OR DO you? But before I go into that... One problem with sampling only at the corners is that ligth can still bleed under walls in extreme cases, like a sharp corner poking into a texel of a lightmap which is low res. But it greatly reduces the problem.

Now... how does one take more samples of each texel without doing extra work?

Well, consider this. Each corner of each texel is shared by four texels. There's no reason to sample the same point four times. So, if one works from the lightmap, one can sample just the corners of texels and transform that point to the world, and then figure out whether or not the texels that surround that point are lit or not. And in this case you would go from light to texel, not texel to light. Doing that, if the light sees the texel corner, then all four texels that surround that corner are lit. Once you know that, you can figure out how bright each is by interpolating between the color of each corner after you've calculated all four corners for that texel.

Of course I've gone way off track here with this discussion but maybe some of the lightmapping folks will find it useful to improve their lightmappers.