Annoying CSM

I first noticed these issues in QEPD where the brighter lighting makes them more obvious, but they exist in the canon bm_c2a4h map as well.


The big problem is that indoors, the CSM seems to put a single giant “shadow” over everything, resulting in the floors and some walls being covered by this horrible brown patina. You can see here how it discolors the light falling onto the floor, turning it “underexposed” and brown where the “bio labs” sign reveals it to in fact be a bright blue-white.


This patina-shadow does not affect props, causing them to in some cases appear to be “glowing”, or, due to the lack of a shadow specifically for them as opposed to everywhere, “floating”.


The patina-shadows do not seem to synch up with the walls quite right in concave interior rooms- there is often a little strip of white in the corners where the floor meets the wall, which from a distance looks very similar to a hole to nodraw.


Also observed this strange effect, where the lightmap shadow of the console seems to “blend out” the patina-shadow, producing a darker but more bluish area under the panels.

Since (to my knowledge) I’m the first modder to actually interact with CSM, I’m wondering if there’s any way to ‘fix’ this, for instance by turning the CSM entity itself on or off- none of the other topside maps seem to have the problems c2a4h does, so is there something I’m missing about how to control these entities? Just in general, can we get some more information at some point relating to how CSM works and how to control it in custom maps?

I did some testing and found that the “patina-shadows” go away if you set the SkipLightMapEnabled property in the env_cascade_light entity to 0 (false). It’s set to 1 in the stock bm_c2a4h map.

The help text for this property says: “If true, CSM will work even on maps compiled without -cascadeshadows. Workaround for lightstyles.”

[attach=4900,none,1920][/attach][attach=4901,none,1920][/attach][attach=4902,none,1920][/attach][attach=4903,none,1920][/attach]




It seems to me that they do. Every map that has the CSM entity in it gets this giant dark shadow cast indoors. But it’s not as apparent in other maps–the floors and walls mostly just look darker than they should. You can see the difference by toggling the [tt]cl_csm_enabled[/tt] convar on and off.

I looks like it’s set to 1 in every map that has the CSM entity in it, while the default value for this property is 0.

I’ve experimented a bit more and found that you could also get rid of the brownish cast by setting the LightBlendMode property to 0 (while leaving the SkipLightMapEnabled at 1), which makes the shadows greyish. Another thing you can do is to set the “Light Color” to a more neutral color, and increasing the ShadowColorIntensity from 0.25 to something like 0.7 also makes it better. But none of these tweaks change the fact that the giant shadow is still present indoors. And any tweaks to the CSM settings will also change the way the shadows look outside.

The best “fix” seems to be to just set the SkipLightMapEnabled to 0. But I don’t know of there could be side-effects to doing so.

You can control the CSM settings in-game via convars. First you need to set the [tt]cl_csm_convar_override[/tt] to 1. You can see all the csm convars by typing [tt]find cl_csm[/tt] into the console. Note that the CSM convars don’t seem to match the values set in the CSM entity in the map. Instead, they use their own default values, so the shadows will instantly change when you enable the [tt]cl_csm_convar_override[/tt].


I found a blog post by one of the devs who worked on the CSM code. It provides interesting insight into how their CSM implementation works and the challenges they had in implementing it. It also explains some of the convars/properties that control the various aspects of CSM:

https://chetanjags.wordpress.com/2016/05/12/sourceengine-csm-soft-shadows/

Skiplightmap makes CSM skip the reading of the alpha in the lightmap. What this means is that the engine can no longer determine which parts of the map are in direct sunlight, and which parts aren’t.

It’s a workaround to make lightstyles work with CSM. Lightstyles = switchable, named lights which take up lightmap pages in VRAD. A map with switchable lights has different pages in the lightmap alpha, so CSM does not work with it usually. This would normally mean that maps with CSM cannot have switchable lights, which is bad for obvious reasons - and was a serious limitation of the CSM present in CS:GO.

When skiplightmap is enabled, the engine will instead approximate the areas which are in shadow and which aren’t, which is why you get that slight darkening effect indoors. It’s a visual issue indeed, but it’s preferable to us not being able to have CSM on maps with switchable lights, which is the alternative. Chetan tried a bunch of ways to resolve this but ultimately this workaround is the only solution we have currently.

You basically have 2 options:

  1. Live with it.

  2. Remove any named lights and turn off skiplightmaps in the CSM entity.

We may be able to resolve the issue in the future, but for now, this is how it is after months of work.

To my knowledge pd_c2a4h has no named lights in it currently, and none are planned. I am perfectly fine knowing that the problem is being worked on, as there are other reasons why I won’t be able to update pd_c2a4h to use a lot of the new functionality for a while yet.

Founded in 2004, Leakfree.org became one of the first online communities dedicated to Valve’s Source engine development. It is more famously known for the formation of Black Mesa: Source under the 'Leakfree Modification Team' handle in September 2004.