Short question about light grid

Discussion in 'Mapping Questions & Discussion' started by Lampenpam, Mar 26, 2014.

  1. Lampenpam

    aa Lampenpam

    Messages:
    1,019
    Positive Ratings:
    337
    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?
     
  2. Freyja

    aa Freyja ¯\_(ツ)_/¯

    Messages:
    2,877
    Positive Ratings:
    4,946
    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.
     
    • Thanks Thanks x 1
  3. xzzy

    aa xzzy

    Messages:
    815
    Positive Ratings:
    393
    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.
     
    • Thanks Thanks x 1
  4. Freyja

    aa Freyja ¯\_(ツ)_/¯

    Messages:
    2,877
    Positive Ratings:
    4,946
    But powers of 2 are pretty and mathematically nice :(
     
    • Thanks Thanks x 1
  5. Lampenpam

    aa Lampenpam

    Messages:
    1,019
    Positive Ratings:
    337
    I'm not a noob Aly, no need to explain the basics to me ^^'
    But thanks you two
     
  6. xzzy

    aa xzzy

    Messages:
    815
    Positive Ratings:
    393
    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)
     
  7. YM

    aa YM LVL100 YM

    Messages:
    7,099
    Positive Ratings:
    5,744
    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.

    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.
     
  8. Freyja

    aa Freyja ¯\_(ツ)_/¯

    Messages:
    2,877
    Positive Ratings:
    4,946
    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.