AdmiralSakai and the Quest For Good Interior Lighting

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    Logging in with you Steam ID has now been restored ♥

    • AdmiralSakai and the Quest For Good Interior Lighting

      I've spent a lot of time looking at and working with interior lighting for BMPD, and I thought I'd share both some of the tips and techniques I've discovered, and some of the issues and limitations I'm currently struggling with, in one big post that's part dev journal, part tutorial, part bug report and part feature request. Hopefully other people working on indoor maps will find this useful, and the BM devs can also get the full context on a few issues I've been posting about in a less organized manner for a while now. This post assumes some basic fluency with the fundamentals of Source engine lighting- if terms like "light_spot" versus "point light" and "constant falloff" versus "quadratic falloff" aren't familiar, I'd suggest the Valve Developer Wiki's Intermediate Lighting page and the pages linked from it.

      The Basic Issue With Interiors In Source

      I'll be using Anomalous Materials' first map as an example throughout this discussion, specifically this little corridor- explanations of why I chose here and not somewhere else will trickle in as the thread progresses.



      For now, though, it's pretty much sufficient to say that it's pretty typical of what I'd expect from a generic modern 'interior' area that isn't some giant hangar or factory bay or something- a regularly-trafficked area about 120-160 Hammer units tall, much wider or longer or both (i.e. it's a corridor or a room with significant floorspace), and lit by regularly-spaced fluorescent lights in the ceiling. Interiors like this typically have drop/tile ceilings while this has those tan panels, but it doesn't really matter. Interior areas also tend to have a lot of props and NPCs in them, many of which (desks, tables, control panels, trashcans, benches, cubicle dividers, railings, shelving) reach up to about halfway to the ceiling plus or minus 20 or 30 units- this one does not, and we will see why somewhat later on.


      In comparison, I will be looking at a section of hallway outside the lab where I work (in the Glennan Engineering Building at Case University in Cleveland):

      I've also included a shot of a random interior classroom in the same building as comparison for if/when I look at a room that's not a corridor.


      Reality and Black Mesa differ in two main ways. The first is that in Glennan, and in every single other facility like it I have ever seen, the fluorescent lights have covers over them, while in Black Mesa they are bare. There actually are such things in the Black Mesa asset library, but they are never used in game because they don't quite work:






      I've messed around with the refraction shaders these bad boys use in previous experiments and could probably make them work properly if for some reason other modders want them, but I'm pretty big on the idea of keeping at least some aesthetic continuity with the original BM maps in fan-created content and so since covers never appear in Black Mesa I don't intend to use them and as a result don't intend to put in the time.


      The second issue is the big one- while both of these areas are underground, sterile, and institutional, the real photos look like a reasonably OK place to work while the Black Mesa version just looks too dreary and dismal to spend any amount of time in.



      That's not a big deal in the vast majority of Black Mesa maps which are post-resonance-cascade, where everything is falling apart and operating in low-power mode, but it's of great interest to me in making my pre-disaster maps and would also be of interest to:

      • Modders looking to re-create areas that are at least partially pre-disaster for other reasons- updates of HL1 content like Blue Shift and Decay that had pre-disaster components, original maps, etc.
      • Modders using Black Mesa as a base for maps not set in the BMRF- i.e. stuff like a new version of the original Counter-Strike.
      • People looking to re-create 'Black Mesa' and other indoor areas in Garry's Mod and other Source games- there does not seem to be a good understanding of how to do this in general through the community, resulting in maps like this (from Hunt Down the Freeman, which has other problems with it, but does this look like an actual hospital?):
      Just in general I feel like that very sterile, institutional, late-80s feel of the Black Mesa facility was a big part of the underlying atmosphere of the original Half-Life, and I'd like to be able to re-create it in modern maps. The problem is, this is actually quite difficult.
      Pre-Disaster Planning Thread: Thinking of Restoring a Part of Black Mesa? Come Here First!

      Office Complex PD: I'm the Slowest Pre-Disaster Mapper!

      Pre-Disaster Questionable Ethics: It's here!
    • Color and Accents
      Getting Rid Of The Murky Look
      Looking at our corridor in Hammer, we see that all of the lights actually have the color 145 185 210- which looks about like this: You can make those lights as bright as you want, but all they are going to do is make the corridor more and more blue-green, doing nothing for the aforementioned 'underwater' look. Turning the saturation down to a greyer 162 182 193 does wonders, and going all the way to a completely desaturated 175 175 175 is even better as far as actual livability is concerned.



      In fact, if we go all the way to 255 255 255 (pure white as opposed to neutral gray) we see that the lights here are actually kind of overly bright (especially the light_spots coming down from the ceiling) and I wound up taking the spots' brightness value down from 625 to 100 and increasing the point lights below them from 40 to 80, then moving them down slightly so they were more in the middle of the hall.




      Essentially, we have gone from this


      to this


      This looks very good on the 'livability' scale, but in terms of gameplay it's pretty awful- white doesn't give you much opportunity for different shades or variations so every single map would look basically the same, and just overall it looks extremely bland and almost unfinished, like I didn't add any lighting at all and just set everything to fullbright.


      Enter Accent Lights
      Really, in an indoor area like this what I am ultimately trying to do is balance two competing trends. The first is the one from reality- in both of the screenshots above, there is some obvious illumination coming directly from the lights, but otherwise the rest of the hallway and the conference room is pretty much evenly bright, with even the corners of the room far away from the lights being plenty bright enough to read in. The second is from the game- very evenly-lit rooms look 'fullbright' and unfinished. Fortunately, the human eye is a lot better at recognizing changes in color than in brightness, so I have a whole other channel of information to work with. Thus, I kind of hit on the idea of very evenly lighting an area in white (but making sure no areas are especially bright) and then adding another 'layer' of accent lights overtop, which only reach to near the actual light sources.

      We start just by making this area almost evenly lit in a low-saturation color (I'm using just white), not really bright but not dim either. This is accomplished in this case by making the point lights have a constant term of 1250, a quadratic term of 0.015 (partially so that they leave that slightly darker area away from the lights, and partly to avoid a problem we will discuss much later from manifesting too obviously and ruining pretty much everything in this area), and a brightness of 95; then removing the light_spots by setting them to 0:

      Tune to taste. We'll discuss the details of this sort of ambient lighting somewhat later on, as well as the problem that caused me to deliberately make the actual fluorescent light props come out so dark (it's a long story, and we'll get to it in time).

      Then, we add another set of light_spots with a more saturated version of the original color (26 169 255), a constant attenuation of 10000, a quadratic attenuation of 1, and a brightness of 100, but they're barely visible. Comparing the two screenshots they can in fact be detected, but a player entering this area would just say it was lit in white.
      We could make the accent lights brighter and they show up just fine, but not only does this cause NPCs and props more directly under them to glow, but it turned the entire floor (and props below about the halfway height of the corridor) very bright blue while not really affecting the walls. Furthermore, all that blue light reflects, and as a result that underwater look is creeping back into the map.




      This is at least partially because, seemingly much more than regular point lights, the brightness of a light_spot on a surface is highly affected by the angle of the surface with respect to the light- the more oblique the surface, the less it will be lit. This makes it difficult for a light_spot pointing generally downward to light up the walls of a room.

      (TBC)
      Pre-Disaster Planning Thread: Thinking of Restoring a Part of Black Mesa? Come Here First!

      Office Complex PD: I'm the Slowest Pre-Disaster Mapper!

      Pre-Disaster Questionable Ethics: It's here!
    • To remedy this, I typically set up an arrangement like so:


      Three or four narrow spotlights, some of which face straight down and some of which tilt out to illuminate the walls, together combine to trace out a sort of oval shape.

      These guys, for instance, have brightness 100.

      For the curved sections, I used an arrangement more like this, where there is still only one wide spotlight but it is pointed at the wall in question:


      Just in general, these are set up in a manner heavily contingent on the setup of the room you are trying to light. If the light source is more than about 150-200 units away from the walls, it's probably not worth it to try and accent-light them. There is no need to include sideways-facing lights if there's no wall there to illuminate.

      Advanced Accent And Ambient Lighting
      IRL, fluorescent lights only really shine 'down' because they are recessed into the ceiling, but sometimes game designers add a 'glow' around them like they were incandescent bulbs or something else that stuck outward:

      If you want to replicate this using accent lighting, it's typically better to have a light_spot facing upward than to use a point light- the accent is more concentrated and there is less 'splash' in areas you don't want.

      A common phenomenon when doing this is that it makes the ceiling very bright. A workaround is to split the desaturated ambient lighting into a dimmer series of point lights, and also a series of light_spots with 90-degree angles that will make the walls and floors a little brighter but not light the ceiling.

      In terms of color, it's typically best to give the accent lights a saturation of 240 and a luminosity of ~120- the idea is to make at least one of the R G B components just reach zero and go no further, producing a light that's "all color and no white". Then, the intensity can be altered just by changing the brightness. But this isn't a hard-and-fast rule.


      In terms of hue, I typically just try to match the hue of the map's original lighting. Just in general flourescent lights work best in yellow, cyan, blue, or a sort of purplish pink, but I suppose you could do red or green too if you wanted.


      I've been talking about the ambient base lights as white, but there's no real reason they have to be. However, adding a slight tint to them works in kind of a counter-intuitive way. Players' eyes will quickly adjust to the ambient tint since it affects every surface, and it won't really be directly perceived, but it will either contrast or mix with the accent lighting (the thing that more directly assigns 'color' to the scene). Thus, making the ambient light in the corridor up above cyan will actually make the cyan accent lighting less obvious, while making it magenta will make it more obvious (within certain limits, after about 20 ticks on the RGB scale the ambient color starts to assert itself directly).




      So, to summarize:

      Technique- Ambient And Accent Lighting: Instead of lighting the entire map in one solid color, include very desaturated ambient lights that cover most of it, and very targeted lights in certain areas that are much more saturated.

      • Good ambient lighting is typically almost fullbright or completely constant, but fades out a little away from the actual light source. Tune to taste.
      • Ambient lighting needn't be pure white, but making it the same color as the accent lighting will probably deemphasize the accents, while making it a contrasting color will emphasize them.
      • Instead of trying to cover the walls and floor with one big light_spot, use multiple small ones that are angled towards the walls they need to light, although if there's only one broad wall (typically curved, but not always) it may be better to angle a single wide light_spot towards it.
      • Good accent lights are typically very rich colors, with 240 saturation and ~120 luminosity. This allows their impact on the world to be controlled through brightness, but fine-tune to taste.
      • Similarly, it's better to use a light_spot facing towards the light source prop as opposed to a point light in order to generate a 'glow' around outward-facing lights. If this makes the ceiling too bright, consider splitting the ambient light into point lights (that illuminate the ceiling and everything else) and downward-facing light_spots (that just illuminate everything else).
      Pre-Disaster Planning Thread: Thinking of Restoring a Part of Black Mesa? Come Here First!

      Office Complex PD: I'm the Slowest Pre-Disaster Mapper!

      Pre-Disaster Questionable Ethics: It's here!
    • A lot of this was actually informed by the way outdoor areas are typically lit- a light_env that provides ambient illumination over the whole map/area, with contrasting accent lights around actual light sources. An example of a more direct application of this to an outdoor map might be a road lit by streetlights at night- ambient lights covering the whole area of the road (probably pretty dim ones, and probably relatively narrow light_spots so as not to light up the whole countryside as well), with other, even narrower light_spot accents illuminating/tinting the area directly underneath the streetlights.
      Pre-Disaster Planning Thread: Thinking of Restoring a Part of Black Mesa? Come Here First!

      Office Complex PD: I'm the Slowest Pre-Disaster Mapper!

      Pre-Disaster Questionable Ethics: It's here!
    • Lighting Bugs
      The Static Prop Bug
      Static props light much brighter than brushes or most other elements- this dates back to around the time of the CSM update, I think, but I'm not really sure when it started appearing exactly.

      I have here a bunch of identical 'corridors' separated by block_lights. Each has a quadratic brightness 50 light in the same place, and from left to right a prop_static printer, a brush with the printer texture, a prop_dynamic, and a prop_physics_override. In-game, note how the static one is much brighter than the others.


      This was done with the default lighting settings in VRAD. To cover all of my options, I replaced the prop_dynamic and prop_physics_override printers with four prop_statics, keeping the brush in the center as a reference, and from left to right made them:

      Vertex Lighting enabled, Lightmaps disabled -- Vertex Lighting enabled, Lightmaps Enabled -- (Brush) -- Vertex Lighting disabled, Lightmaps disabled -- Vertex Lighting disabled, Lightmaps enabled

      Then I compiled the map with the following options
      (no options, default):

      -staticproplighting


      -staticproplighting3

      While some compile options alter the intensity of the effect, none remove it. It seems the only thing that works is disabling per-vertex lighting in Hammer (which is not ideal, as it results in somewhat flatter-looking static props overall).

      I remember a while back that props without normal maps were much brighter than ones with normal maps, but this seems to have gone away.

      It's interesting to note that the effect disappears if r_meshstaticlighting is turned to 0, but persists if r_ambientlightingonly is turned to 1. As I understood it static and ambient lighting are the two components of prop lighting in Source, so it seems like these commands should do the same thing.

      I suppose that r_meshstaticlighting 0 command provides a temporary workaround for this issue, but disabling static lighting for props just in general pretty negatively impacts their appearance in-game so I wouldn't call it a fix.

      It's hard to tell because lighting isn't as controlled there as it is here, but I'm pretty sure this issue exists in canon maps; the brighter, more even lighting of the style outlined above just makes it more obvious:





      The Curious Light_spot Problem

      Observed this in OCPD:

      I had some light_spots for ambient lighting in another area with a protruding section between them.

      The lighting did not seem to be stopped by the brush section, and furthermore seems to be multiplied similarly to the static props above- only this time, it's dynamically-lit models like func_doors and prop_physics that are affected (and also some static props for... some reason).

      Some additional testing with the 'printer room' map revealed the following:
      1. The effect is caused by light_spots but not point lights.
      2. The effect is present with only a single light_spot, but multiple lights "stack".
      3. The effect is more pronounced with lights where the inner and outer angles are closer together, but always present.
      4. Light_spots don't really cut through solid brushes to a noticeable degree so much as they do not attenuate properly- the props in the screenshot are lit through the windows in the intervening space, but at a much higher brightness than the surrounding wall.


      In summary:

      Bug - Static Prop Brightness: Static props render much more brightly unless per-vertex lighting is disabled.


      Bug - Light_Spot 'Leakage': Light_spots don't attenuate the way they should, and light non-static props too brightly.
      Pre-Disaster Planning Thread: Thinking of Restoring a Part of Black Mesa? Come Here First!

      Office Complex PD: I'm the Slowest Pre-Disaster Mapper!

      Pre-Disaster Questionable Ethics: It's here!