[GUIDE] Prop Lightmaps

Discussion in 'Tutorials & Resources' started by sevin, Jun 18, 2015.

  1. sevin

    aa sevin

    Messages:
    943
    Positive Ratings:
    636
    September 10th of last year Valve added the ability to generate lightmaps for static props in Hammer when they began artpassing Asteroid. I don't think a whole lot of people know about it still, so I thought I'd write a little guide on it. If you don't know what lightmaps are, read about them on the VDC or in Shmitz's guide.

    So you've compiled with -staticproplighting, -staticproppolys, and -textureshadows. You've reset the lighting origin and disabled vertex lighting but that one barrel still looks like this:

    [​IMG]

    Pre-Asteroid, you'd just have to delete the prop, try to move it to a lower contrast area, or just suck it up. But now you can generate extremely accurate lighting information per-prop depending on the resolution you set for it - just like on brushes - and make your barrel look more like this:

    [​IMG]

    Generating these lightmaps in Hammer is simple:
    1. Select your prop and open its properties.
    2. Set "Generate (and use) lightmaps for this static prop" to yes.
    3. Set the X and Y resolutions to a power of 2 value (you can set the values to be different, but there is not really any reason to)
      *note - the default lightmap resolution for props is 32x32, increasing the value will increase the accuracy of the lighting calculated​
      [​IMG]

    Now that you've seen the power of prop lightmaps, you may be asking yourself: "Why wouldn't I just use this everywhere?" The answer lies in this famous quote by Voltaire: with great power comes great responsibility. Or in this case, great amounts of file size.

    Each prop's lightmap data is stored as a .ppl file in the root directory of your compiled .bsp. The file size added from each prop you give lightmaps is double whatever resolution you set it to. If you set your prop to have lightmaps at 128x128, then the filespace used will be 256.5kb (it seems to add .5kb on any resolution for some reason). The resolution appears to be shaded pixels on top of the models' texture, so lower resolutions will just be blurry versions of higher resolutions as the only thing different is the pixel density.

    [​IMG]

    Doesn't seem like much, but after a few props you'll be adding several mb to your map, especially when using higher resolutions. Be smart and only use prop lightmaps on props that are stuck in shadow transitions and in high-traffic areas where they'll be seen a lot. You can generally skip out on props that are in non-playable areas where people won't look at them too much. Also, UVs with shared space will break lightmaps and cause them to do weird things (image courtesy of Fantasmos), so if something like this appears in your compile you'll just have to disable the lightmaps as getting the modeler to remove the shared space is usually not going to be worth the trouble. Models compiled with phong shading also seem to not respond at all to lightmaps no matter what resolution you give them.

    Here is a comparison of various lightmap resolutions used on a few corrugated sheetmetal props in Goldtooth. Starting from 32x32, I increased all 3 props at the same rate.

    [​IMG]
    [​IMG]

    In this particular example we can also see that higher resolutions won't necessarily look natural, especially when coinciding with brushes with lower res lightmaps.

    Also important to note is that compiling with prop lightmaps significantly increases compile time. With just these 3 props, a 32x32 full compile of this cordoned section of Goldtooth with -staticproplighting, -staticproppolys, -textureshadows and LDR+HDR (-both) took 1 minute 58 seconds in total. At 1024x1024 each, the total was 3 minutes 30 seconds. I changed nothing except the lightmap resolutions between compiles.
     
    • Thanks Thanks x 17
    Last edited: Jun 21, 2015
  2. iiboharz

    aa iiboharz Meme Queen

    Messages:
    667
    Positive Ratings:
    964
    Don't forget to mention that this does not work on models with phong for whatever reason.
     
    • Thanks Thanks x 1
  3. sevin

    aa sevin

    Messages:
    943
    Positive Ratings:
    636
  4. Pocket

    aa Pocket When all you have is Hammer...

    Messages:
    4,334
    Positive Ratings:
    2,096
    Same reason that true vertex lighting doesn't, I imagine. Phong shading is a fundamentally different type of lighting than other forms, so you can't really combine them; if you could, we could have phong shading on brushwork as well. (Although that doesn't seem to stop the Unreal Engine from managing somehow.)
     
  5. sevin

    aa sevin

    Messages:
    943
    Positive Ratings:
    636
    CS:GO can have phong shading on world brushes.
     
  6. Pocket

    aa Pocket When all you have is Hammer...

    Messages:
    4,334
    Positive Ratings:
    2,096
    Really, now? Do tell. I haven't played it since the beta and I certainly didn't notice anything that looked like phong shading at the time.
     
  7. sevin

    aa sevin

    Messages:
    943
    Positive Ratings:
    636
    I haven't experimented with it, but I read about it on MapCore. It was added a couple months ago.
     
    • Thanks Thanks x 1
  8. YM

    aa YM LVL100 YM

    Messages:
    7,099
    Positive Ratings:
    5,731
    Totally forgot this was even a thing. tbh even at 32x32 those metal panels look infinitely better than their vertex lighting. I bet even 16x16 would be enough
     
  9. sevin

    aa sevin

    Messages:
    943
    Positive Ratings:
    636
    You're right, doing that gif made me realize lower resolutions typically look more natural and coherent in TF2 where shadows are far more diffuse than in CS:GO or Insurgency.

    EDIT: I think I missed your point initially, but yes, prop lightmaps even at low resolutions are much more accurate than anything else Source can do to light props.
     
  10. Pocket

    aa Pocket When all you have is Hammer...

    Messages:
    4,334
    Positive Ratings:
    2,096
    Provided that it has the appropriate UV mapping for it. Anything more complex than a cylinder will probably end up looking a bit shite, and introduce visible seams that weren't there normally. Even some of the buildings in Asteroid suffer from this already.

    It's a pity they didn't make lightmap capability a material parameter, so we could split some props into multiple materials and have both types of lighting in a single prop where appropriate. The busted wall from ctf_sawmill is a good example; the flat wall part could be lightmapped while the craggy edges of the hole could remain vertex lit. What we'd have to now to achieve that effect is split it into two separate props altogether.
     
  11. sevin

    aa sevin

    Messages:
    943
    Positive Ratings:
    636
    Those metal sheets aren't exactly simple; they are corrugated. I have only come across one instance of prop lightmaps not working beautifully and that's been with one of the junction box props in an awkward position between 2 shadow transitions, but honestly you can just turn the resolution down to 16x16 or 32x32 to mask its inexactness and it still looks better than what vertex lighting could do with the same situation.
     
  12. Idolon

    aa Idolon the worst admin

    Messages:
    1,373
    Positive Ratings:
    3,942
    I've actually come to prefer vertex lighting on the corrugated metal. Lightmaps reduce the contrast between light and shadow on them, and they turn out looking flat. Vertex lighting vs. 32x32 lightmap:

    [​IMG]

    Granted, vertex lighting can get you some weird results when you have more complex shadows going on.
     
    • Thanks Thanks x 4
  13. YM

    aa YM LVL100 YM

    Messages:
    7,099
    Positive Ratings:
    5,731
    If you were to increase your lightmap scale to one where the density of luxels is equal or higher than the vertex density it would look as good.

    The corrugated sheets are unusual in that they have unusually high vertex density, so anything other than a large lightmap won't offer an improvement.

    This is of course until you have some shadow across it, then the lengthways vertex density is low enough for things to look janky and using a lightmap (even a small one) might look better due to the more uniform luxel shape.

    Just goes to show, most of these lighting options available to us are not always better than others.