Env cascade light: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
Line 1: Line 1:
{{langsp}}
{{langsp}}
It is also available in {{Bms|4}}


{{asd|4}}'s counterpart to this entity is [[Light_deferred_global]]{{also|{{lw}}}}
[[File:CSM Example.jpg|thumb|CSM in {{csgo|4.1}}]]
[[File:CSM Example.jpg|thumb|CSM in {{csgo|3.1}}]]
[[File:Env_cascade_light_-_BMS_CSM_comparison.gif|thumb|Comparison of CSM and without CSM in {{bms|3.1}}<br>(Click to preview)]]
[[File:Env_cascade_light_-_BMS_CSM_comparison.gif|thumb|Comparison of CSM and without CSM in {{bms|3.1}}<br>(Click to preview)]]
It casts an extremely accurate shadow map via the <code>tools/[[skybox]]</code> texture, acting as a real-time variation of {{ent|light_environment}}. This form of lighting is known as [https://learn.microsoft.com/en-us/windows/win32/dxtecharts/cascaded-shadow-maps Cascaded Shadow Maps], or CSM, which works by rendering very detailed shadow maps which becomes a lower and lower resolution depending on the distance the viewer is from the surface, similar to [[mipmaps]]. Some games automatically add this entity to the map, but it can be placed manually as well.
It casts an extremely accurate shadow map via the <code>tools/[[skybox]]</code> texture, acting as a real-time variation of {{ent|light_environment}}. This form of lighting is known as [https://learn.microsoft.com/en-us/windows/win32/dxtecharts/cascaded-shadow-maps Cascaded Shadow Maps], or CSM, which works by rendering very detailed shadow maps which becomes a lower and lower resolution depending on the distance the viewer is from the surface, similar to [[mipmaps]]. Some games automatically add this entity to the map, but it can be placed manually as well.


{{note|Due to lighting changes in {{bms}}, this entity has additional parameters.}}
{{note|Due to lighting changes in {{Xe|4}}, this entity has additional parameters.}}
{{important|{{bms|4}}'s implementation requires <code>-CascadeShadows</code> and <code>-StaticPropLighting</code> parameters for [[VRAD]], this for CSM to work correctly.}}
{{important|{{Xe|4}}'s implementation requires <code>-CascadeShadows</code> and <code>-StaticPropLighting</code> parameters for [[VRAD]], this for CSM to work correctly.}}


{{bug|In {{insurgency}}, shadows will be very faint if the map hasn't been compiled with [[HDR]].}}
{{bug|In {{insurgency}}, shadows will be very faint if the map hasn't been compiled with [[HDR]].}}
Line 17: Line 15:


{{note|Older games like {{hl2}} don't have this entity, but there is an [https://github.com/celisej567/Fake-CSM-Source-2013 attempt] of porting it.}}
{{note|Older games like {{hl2}} don't have this entity, but there is an [https://github.com/celisej567/Fake-CSM-Source-2013 attempt] of porting it.}}
{{note|You alternatively can implement {{lw|4}}'s Deferred lighting as it is the most robust implementation currently being available to the public.{{todo|Make tutorial on how to implement deferred lighting in your source engine project.}}}}
{{note|{{asd|4}}'s counterpart to this entity is {{ent|Light_deferred_global}}{{also|{{lw}}}}}}
{{note|You alternatively can implement {{lw|4}}'s Deferred lighting as it is the most robust implementation currently being available to the public.{{todo|Make a tutorial on how to implement deferred lighting in your source engine project.}}}}


{{csgo}} Represented by class <code>CCascadeLight</code>.
{{csgo}} Represented by class <code>CCascadeLight</code>.
Line 25: Line 24:
{{KV|Max shadow distance|intn=maxshadowdistance|float|Maximum dynamic shadow distance. Higher values are slower, default on PC is 400 units.}}
{{KV|Max shadow distance|intn=maxshadowdistance|float|Maximum dynamic shadow distance. Higher values are slower, default on PC is 400 units.}}
{{KV|Use light_environment's angles|intn=uselightenvangles|bool|If true, the CSM shadow angles are automatically taken from a {{ent|light_environment}}'s angles. If false, this entity's '''Pitch Yaw Roll''' is used.}}
{{KV|Use light_environment's angles|intn=uselightenvangles|bool|If true, the CSM shadow angles are automatically taken from a {{ent|light_environment}}'s angles. If false, this entity's '''Pitch Yaw Roll''' is used.}}
{{KV|LightRadius1|to=LightRadius3|intn=LightRadius1|float|Used for controlling shadow softness in cascades 1, 2, and 3.|only=BMS}}
{{KV|LightRadius1|to=LightRadius3|intn=LightRadius1|float|Used for controlling shadow softness in cascades 1, 2, and 3.|only={{Xe}}}}
{{KV|Depthbias1|to=Depthbias3|intn=Depthbias1|float|DepthBias for cascades 1, 2, and 3.|only=BMS}}
{{KV|Depthbias1|to=Depthbias3|intn=Depthbias1|float|DepthBias for cascades 1, 2, and 3.|only={{Xe}}}}
{{KV|Slopescaledepthbias1|to=Slopescaledepthbias3|intn=Slopescaledepthbias1|float|Slope DepthBias for cascades 1, 2, and 3.|only=BMS}}
{{KV|Slopescaledepthbias1|to=Slopescaledepthbias3|intn=Slopescaledepthbias1|float|Slope DepthBias for cascades 1, 2, and 3.|only={{Xe}}}}
{{KV|ViewModelDepthbias|intn=ViewModelDepthbias|float|DepthBias for viewmodel cascade.|only=BMS}}
{{KV|ViewModelDepthbias|intn=ViewModelDepthbias|float|DepthBias for viewmodel cascade.|only={{Xe}}}}
{{KV|ViewModelSlopescaledepthbias|intn=ViewModelSlopescaledepthbias|float|DepthBias for viewmodel cascade.|only=BMS}}
{{KV|ViewModelSlopescaledepthbias|intn=ViewModelSlopescaledepthbias|float|DepthBias for viewmodel cascade.|only={{Xe}}}}
{{KV|CSM_Volume_Mode|intn=CSMVolumeMode|choices|Use Manual mode for better quality and performance. In near future Auto mode will be removed from the game.|only=BMS|}}
{{KV|CSM_Volume_Mode|intn=CSMVolumeMode|choices|Use Manual mode for better quality and performance. In near future Auto mode will be removed from the game.|only={{Xe}}|}}
:*0: Auto: Static cache will update once every 10 frames (approx) covering max shadow distance or whole map around player.
:*0: Auto: Static cache will update once every 10 frames (approx) covering max shadow distance or whole map around player.
:*1: Manual : Static cache area coverage and updates are managed via CSM Volumes' I/O.
:*1: Manual : Static cache area coverage and updates are managed via CSM Volumes' I/O.
Line 40: Line 39:
{{note|Effects nothing.}}
{{note|Effects nothing.}}
{{IO|LightColor|Changes color of the sunlight.|param=color255}}
{{IO|LightColor|Changes color of the sunlight.|param=color255}}
{{bug|Doesn't work as expected. With {{csgo|4}}'s implementation, the color only changes on static props, not on world geometry or dynamic objects. It only changes the shadow color (only in world geometry, not in models), with no change upon reloading the game. With {{bms|4}}'s implementation, the only thing you can do is change shadows color to turquoise and change the intensity of these shadows, however this doesn't effects shadows on the [[viewmodel]].
{{bug|Doesn't work as expected. With {{csgo|4}}'s implementation, the color only changes on static props, not on world geometry or dynamic objects. It only changes the shadow color (only in world geometry, not in models), with no change upon reloading the game. With {{Xe|4}}'s implementation, the only thing you can do is change shadows color to turquoise and change the intensity of these shadows, however this doesn't effects shadows on the [[viewmodel]].
{{expand|title=Examples|noborder=1|1=
{{expand|title=Examples|noborder=1|1=
{{note|{{p2ce|1}} uses {{csgo|1}}'s implementation of CSM}}
{{note|{{p2ce|4.1}} uses {{csgo|4.1}}'s implementation of CSM}}
{{csgo|2}} ({{p2ce|2}}):
{{csgo|2}} ({{p2ce|2}}):
<br>
<br>
Line 49: Line 48:
File:afterCSMLC.jpg| thumb | left |After <code>ent_fire env_cascade_light lightcolor 255 0 0 255</code>.  
File:afterCSMLC.jpg| thumb | left |After <code>ent_fire env_cascade_light lightcolor 255 0 0 255</code>.  
</gallery>
</gallery>
{{Bms|2}}:
{{Xe|2}}:
<gallery mode=packed heights=250px>
<gallery mode=packed heights=250px>
File:beforeBMS,jpg.jpg| thumb | left |Before <code>ent_fire env_cascade_light lightcolor 255 0 0 255</code>.  
File:beforeBMS,jpg.jpg| thumb | left |Before <code>ent_fire env_cascade_light lightcolor 255 0 0 255</code>.  
Line 57: Line 56:
}}
}}
{{IO|LightColorScale|Boosts the color of the sunlight. Non-functional, only resets the Light Color.|nofgd=1|deprecated=1}}
{{IO|LightColorScale|Boosts the color of the sunlight. Non-functional, only resets the Light Color.|nofgd=1|deprecated=1}}
{{bug|Effects nothing in {{bms|4}}.}}
{{bug|Effects nothing in {{Xe|4}}.}}
{{IO|SetCSMVolume|Set CSM Volume via trigger volume.|only=BMS}}
{{IO|SetCSMVolume|Set CSM Volume via trigger volume.|only={{Xe}}}}
{{IO|SetCSMVolumeToSceneBounds|Set CSM Volume to scene bounds.|only=BMS}}
{{IO|SetCSMVolumeToSceneBounds|Set CSM Volume to scene bounds.|only={{Xe}}}}
{{IO|SetCSMVolumeViaCSMVolumeEntity|param=targetname|Set CSM Volume to CSM Volume Entity.|only=BMS}}
{{IO|SetCSMVolumeViaCSMVolumeEntity|param=targetname|Set CSM Volume to CSM Volume Entity.|only={{Xe}}}}
{{IO|Disable|param=void|Disable this entity.}}
{{IO|Disable|param=void|Disable this entity.}}
{{note|Only in {{bms|4}} work as expected. {{csgo|4}}'s implementation only disable blobby shadows and lighting in [[viewmodel]], also cause freeze for some seconds.}}
{{note|Only in {{Xe|4}} work as expected. {{csgo|4}}'s implementation only disable blobby shadows and lighting in [[viewmodel]], also cause freeze for some seconds.}}
{{IO|Enable|param=void|Enable this entity.}}
{{IO|Enable|param=void|Enable this entity.}}
{{note|Only in {{bms|4}} work as expected. {{csgo|4}}'s implementation only enable blobby shadows and lighting in [[viewmodel]], also cause freeze for some seconds.}}
{{note|Only in {{Xe|4}} work as expected. {{csgo|4}}'s implementation only enable blobby shadows and lighting in [[viewmodel]], also cause freeze for some seconds.}}
{{I BaseEntity}}
{{I BaseEntity}}



Revision as of 12:54, 29 February 2024

English (en)Translate (Translate)
Comparison of CSM and without CSM in Black Mesa
(Click to preview)

It casts an extremely accurate shadow map via the tools/skybox texture, acting as a real-time variation of light_environment. This form of lighting is known as Cascaded Shadow Maps, or CSM, which works by rendering very detailed shadow maps which becomes a lower and lower resolution depending on the distance the viewer is from the surface, similar to mipmaps. Some games automatically add this entity to the map, but it can be placed manually as well.

Note.pngNote:Due to lighting changes in Xengine Xengine, this entity has additional parameters.
Icon-Important.pngImportant:Xengine Xengine's implementation requires -CascadeShadows and -StaticPropLighting parameters for VRAD, this for CSM to work correctly.
Icon-Bug.pngBug:In Insurgency, shadows will be very faint if the map hasn't been compiled with HDR.  [todo tested in ?]
Icon-Bug.pngBug:In Insurgency, Lightstyles will break when this entity exists.  [todo tested in ?]
Note.pngNote:You still need to have a light_environment in your map as well to create lightmap based lighting, which is not done by this entity.
Note.pngNote:Older games like Half-Life 2 don't have this entity, but there is an attempt of porting it.
Note.pngNote:Alien Swarm Deferred Alien Swarm Deferred's counterpart to this entity is Light_deferred_global(also in Lambda Wars)
Note.pngNote:You alternatively can implement Lambda Wars Lambda Wars's Deferred lighting as it is the most robust implementation currently being available to the public.
Todo: Make a tutorial on how to implement deferred lighting in your source engine project.

Counter-Strike: Global Offensive Represented by class CCascadeLight.

Keyvalues

Light Color (color) <color255>
This is the color of the sunlight. For Counter-Strike: Global Offensive, the color is automatically copied from the light_environment.
Max shadow distance (maxshadowdistance) <float>
Maximum dynamic shadow distance. Higher values are slower, default on PC is 400 units.
Use light_environment's angles (uselightenvangles) <boolean>
If true, the CSM shadow angles are automatically taken from a light_environment's angles. If false, this entity's Pitch Yaw Roll is used.
LightRadius1 (LightRadius1) to LightRadius3 <float> (only in Xengine)
Used for controlling shadow softness in cascades 1, 2, and 3.
Depthbias1 (Depthbias1) to Depthbias3 <float> (only in Xengine)
DepthBias for cascades 1, 2, and 3.
Slopescaledepthbias1 (Slopescaledepthbias1) to Slopescaledepthbias3 <float> (only in Xengine)
Slope DepthBias for cascades 1, 2, and 3.
ViewModelDepthbias (ViewModelDepthbias) <float> (only in Xengine)
DepthBias for viewmodel cascade.
ViewModelSlopescaledepthbias (ViewModelSlopescaledepthbias) <float> (only in Xengine)
DepthBias for viewmodel cascade.
CSM_Volume_Mode (CSMVolumeMode) <choices> (only in Xengine)
Use Manual mode for better quality and performance. In near future Auto mode will be removed from the game.
  • 0: Auto: Static cache will update once every 10 frames (approx) covering max shadow distance or whole map around player.
  • 1: Manual : Static cache area coverage and updates are managed via CSM Volumes' I/O.
Start Disabled (StartDisabled) <boolean>
Stay dormant until activated (with theEnableinput).


Inputs

SetAngles <stringRedirectInput/string>
Sets the direction shadows cast in.
Note.pngNote:Effects nothing.
LightColor <color255RedirectInput/color32>
Changes color of the sunlight.
Icon-Bug.pngBug:Doesn't work as expected. With Counter-Strike: Global Offensive Counter-Strike: Global Offensive's implementation, the color only changes on static props, not on world geometry or dynamic objects. It only changes the shadow color (only in world geometry, not in models), with no change upon reloading the game. With Xengine Xengine's implementation, the only thing you can do is change shadows color to turquoise and change the intensity of these shadows, however this doesn't effects shadows on the viewmodel.
Examples

Counter-Strike: Global Offensive Counter-Strike: Global Offensive (Portal 2: Community Edition Portal 2: Community Edition):

Xengine Xengine:

  [todo tested in ?]
LightColorScale  !FGD Obsolete
Deprecated.
Boosts the color of the sunlight. Non-functional, only resets the Light Color.
Icon-Bug.pngBug:Effects nothing in Xengine Xengine.  [todo tested in ?]
SetCSMVolume  (only in Xengine)
Set CSM Volume via trigger volume.
SetCSMVolumeToSceneBounds  (only in Xengine)
Set CSM Volume to scene bounds.
SetCSMVolumeViaCSMVolumeEntity <targetnameRedirectInput/string> (only in Xengine)
Set CSM Volume to CSM Volume Entity.
Disable <void>
Disable this entity.
Note.pngNote:Only in Xengine Xengine work as expected. Counter-Strike: Global Offensive Counter-Strike: Global Offensive's implementation only disable blobby shadows and lighting in viewmodel, also cause freeze for some seconds.
Enable <void>
Enable this entity.
Note.pngNote:Only in Xengine Xengine work as expected. Counter-Strike: Global Offensive Counter-Strike: Global Offensive's implementation only enable blobby shadows and lighting in viewmodel, also cause freeze for some seconds.


Outputs

See also

External links