🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Smoothing out baked lightmaps

Started by
1 comment, last by MJP 3 years, 3 months ago

I'm using baked lighting in my renderer, which is calculated by ray testing from a point on a surface to every light. If the ray doesn't hit anything, calculate lighting for that point. If the ray is blocked, store a black pixel for that point in the surface's lightmap texture. Points are evenly distributed in world-space units.

I want to use lightmaps over dynamic lighting, but it's very hard to find good resources on baked lighting other than generating the lightmap itself, which I've been able to figure out.

One problem I'm facing now is hard edges between colors. The texels of the lightmap are very large when placed on a surface which gives this blocky look:

Obviously, reducing the lightmap resolution will improve it, but not without using a huge amount of memory (and it still looks bad). I assume I need to do something in the pixel shader to smooth this out properly, but I'm not sure what. Does anyone know what I can do to improve this?

Another problem which might only be solvable by increasing the resolution is this:

The circled area is unshadowed because the lightmap resolution isn't high enough to consider it, so it bleeds through. The piece of geometry casting the shadow is touching the one beneath it, so there is no opening between them.

If anyone has any insight, or knows of any good books or resources for the rendering step of baked lighting, I'd appreciate it.

Advertisement

Looks like multisampling is the first thing to try. Your lightmaps look aliased. Either try rendering at 4 times resolution and sample down, or trace 4x4 samples per texel and use the average.

Are you sampling the lightmap with point filtering? Using bilinear will certainly smooth it out, and higher-order filtering can smooth it out even further while adding more sampling cost.

Typically you also don't want to bake hard shadows into your lightmaps. I would look into treating your light source as an area light, and shooting N rays instead of a single ray.

This topic is closed to new replies.

Advertisement