- Home /
Calculating lightmap texel per unit size
Hey there, I'm working on an automated lightmapping process and am trying to fit my entire scene in a single lightmap texture of specified dimensions.
In the scene is a fixed amount of renderers, all with fixed worldspace sizes (they're terrain tiles laid out in a grid) each with Lightmap Scale set to 1. I'm trying to figure out a formula for getting the biggest Texels per Unit value without going out of the specified Lightmap Resolution (1024 in my case).
Logically, if I understand all values correctly, the following formula should do what I want:
(lightmapResolution / tileCount / worldSizePerTile) - padding
I'm not entirely sure how to correct for padding, but even with this or with padding * 2 or whatever, the result of said formula is nowhere near what I need. It's too small for my current usecase, creating a lightmap with some space left. In other usecases with smaller target resolutions, it still creates multiple lightmaps.
Is there any glaring fault in my formula or do I misunderstand some of the lightmap setting values?