Short question about light grid

  • If you're asking a question make sure to set the thread type to be a question!
Mar 23, 2013
1,013
347
Why should I make the light grid always a power of 2? I think I used 6 or 12 sometimes. Is that bad? >:
Or does that work as well?
 

Freyja

aa
Jul 31, 2009
2,994
5,813
If you mean the lightmap scale, then 16 is the default value which is usually a pretty safe fallback.

The smaller number you make, the higher your shadow detail will be, but at the cost of compile time and fizesize. An entire map of 16 can have almost 20mb of lightmap data, if you make it all 8, that's 40mb, 4 is 80mb, 2 is 160mb!! Of course this works in reverse too, so making faces that have no need for detailed shadows higher values will reduce compile time and filesize.

I'm not sure where you got the idea of make it all scale 2, or 6 or 12, but that's very bad practice unless you know what your doing. For most maps, you should never need to change it from 16.

Also it's best to keep it a power of 2 (2, 4, 8, 16, 32, 64) because texture sizes etc etc binary space partition etc etc.
 

xzzy

aa
Jan 30, 2010
815
531
The reason to use powers of two is so that neighboring lightmaps will merge properly and not create seams. It's analogous to the way displacements have to line up for the sew function to work.

Technically, there is no reason to not use "weird" numbers. You can make your entire map use a scale of 15 and it'll work fine.
 

xzzy

aa
Jan 30, 2010
815
531
But powers of 2 are pretty and mathematically nice :(

Definitely, which is why your scale should always be a power of two. It prevents many issues.

(except maybe displacements as we beat to death in that other thread last week because apparently displacements get to make their own rules)
 

YM

LVL100 YM
aa
Dec 5, 2007
7,135
6,056
An entire map of 16 can have almost 20mb of lightmap data, if you make it all 8, that's 40mb, 4 is 80mb, 2 is 160mb!!

Have you actually tested that? because it looks like you've done your maths wrong.
Given a power 8 is 4x as much as a power 16, not 2x, your 20mb at 16 example map at 8 would be 80mb. Making it entrely 4 would make it 320mb and 2 would make it 1.2gb

If the vtf compression does something to it that'll be wrong, but lightmap power is a length, and lightmap data is an area, so it's not a linear relationship but a square one.

The reason to use powers of two is so that neighboring lightmaps will merge properly and not create seams. It's analogous to the way displacements have to line up for the sew function to work.

Technically, there is no reason to not use "weird" numbers. You can make your entire map use a scale of 15 and it'll work fine.

Powers of 2 also divide nicely into brushes that are on powers of 2, so you never have a thin row of barely used luxels at the edge of a brush. Which you would get if you made them 15.
 

Freyja

aa
Jul 31, 2009
2,994
5,813
Actually I just did a quick estimation in my head, I didn't really check it. Thanks.

Lightmaps are not uncompressed entirely though, I assume to assist loading times.