NewLight Point: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
 
(99 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{This is a|name=newLight_Point|e0|game=Black Mesa|sprite=NewLight Point.png}} It is one of the many new lighting entities available. Black Mesa incorporates a new lighting system which utilizes {{wiki|Deferred lighting}} to create dynamic lighting system with dynamic shadows, which allows to complement and quite enliven some scenes, it is also nice effect for moving objects, such as trains. It is also include fine tuning Godrays and lightcookies.
{{this is a|point entity|name=newLight_Point|game=Black Mesa|sprite=NewLight Point.png}} It creates an invisible [[Deferred lighting|deferred light]] source that shines in all directions, includes godrays and lightcookies.
[[File:GiffromBlackMesaDefinitiveEditionbetaSmaller.gif|frame|right|Gif from Black Mesa Definitive Edition beta announcement.]]
{{CDA|CNewLightPoint|CBaseEntity|}}
{{back | Black Mesa Level Creation}}
[[File:NewLight_PointMain.jpg|720px||thumb|right|NewLight_Point in {{code|End Game}} chapter (used for the portal).]]  
{{Note|You can have only 512 point light entities placed in the map editor.}}
{{todo|Rework this page.}}


==Keyvalues==
==Keyvalues==
{{KV|Name|intn=targetname|target_source|The name that other entities refer to this entity by.}}
{{KV Targetname}}
{{KV|Parent|intn=parentname|target_destination|The name of this entity's parent in the movement hierarchy. Entities with parents move with their parent.}}
{{KV|Pitch Yaw Roll (Y Z X)|intn=angles|angle|nofgd=1|This entity's orientation in the world. Pitch is rotation around the Y axis, yaw is the rotation around the Z axis, roll is the rotation around the X axis.
{{KV|Pitch Yaw Roll (Y Z X)|intn=angles|angle|nofgd=1|This entity's orientation in the world. Pitch is rotation around the Y axis, yaw is the rotation around the Z axis, roll is the rotation around the X axis.}}
:{{note|There is almost no differences if you're using point light with no texture. Things changes if you're using textures.}}
{{Important|Have huge differences if you use texture for your {{ent|newLight_Point}}.}}
{{KV|Enabled|intn=Enabled|Choices|Enable/Disable this Entity.
Determines if the light is off at level start.
*0: Enabled
*1: Disabled}}
{{KV|Appearance|intn=FlareStyle|Choices| 
{{Light appearances}}}}
{{KV|Light Color|intn=LightColor|color255|This is the color of the sunlight.
Determines color of light.}}
{{KV|Light Ambient Color|intn=LightColorAmbient|color255|This is the ambient color of the sunlight.
Determines color of shadows that light source creates.}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=500px>
File:ShadowC1.png| thumb | left | 510px | 0 0 0
File:ShadowC2.png| thumb | left | 510px | 255 0 0
File:ShadowC3.png| thumb | left | 510px | 255 128 128
</gallery>
}}
{{KV|Light Intensity|intn=Intensity|float|RGB * Intensity.
Brightness of the light.}}
{{Note|With 0 will not draw, process and specular shader be disabled.}}
{{KV|SpecularMultiplier|intn=SpecMultiplier|float|0 to 1 RGB * Intensity * SpecularMultiplier.
Brightness of the specular shader from this light source.}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=500px>
File:BS IN1.png| thumb | left | 510px | SpecularMultiplier - 1
File:BS IN10.png| thumb | left | 510px | SpecularMultiplier - 10
File:BS IN20.png| thumb | left | 510px | SpecularMultiplier - 20
</gallery>
}}
{{KV|Range|intn=Range|float|Range.
How far the light source illuminates. Measured in Hammer Units.}}
{{Important|It greatly affects optimization, less is better.}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=500px>
File:L1.png| thumb | left | 510px | Range - 150
File:L2.png| thumb | left | 510px | Range - 300
File:L3.png| thumb | left | 510px | Range - 500
</gallery>
}}
{{KV|Light Type|intn=LightType|choices|
Determines the light type.
*0: Static - shadows are cast only by static objects ([[prop_static]], geometry, etc.). Lighting does not update if it has parent (use if part scene has no large moving parts, or shadow accuracy is not important).
*1: Stationary - shadows are cast by static and dynamic objects, lighting does not update if it has a parent. {{Important|Shadows for dynamic props update, but not dynamic geometry!}}
*2: Dynamic - shadows are cast by static and dynamic objects, lighting updates if it does have a parent. This light is quite expensive, and should only be used for moving light sources, and if your scene have moving geometry.}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=420px>
File:B-1.gif|| thumb | left | 510px | Light Type - Static
File:B0.gif| thumb | left | 510px | Light Type - Stationary
File:B1.gif| thumb | left | 510px | Light Type - Dynamic
</gallery>
}}
{{KV|HasShadow|intn=HasShadow|choices|Do you want this light to have shadows?
Determines whether the light source will cast shadows. Remember that default choices is No.
*0: No
*1: Yes}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=410px>
File:BM NO.png| thumb | left | 510px | Has Shadow - NO
File:BM YES.png| thumb | left | 510px | Has Shadow - YES
</gallery>
}}
{{Note| Shadows are cast and update even with closed [[areaportals]].}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=710px>
File:Black Mesa Screenshot 2023.10.23 - 19.02.36.87.png| thumb | left | 510px | 
</gallery>
}}
{{KV|ShadowMapLOD|intn=ShadowLod|choices|Resolution of ShadowMap used by this light.
Determines quality of shadows. 1024 is very expensive, use it only in places where it's really needed, in most cases 512 is good alternative. 256 produces the blurriest shadows, but it is also the cheapest.
*0: 256
*1: 512
*2: 1024}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=500px>
File:LOD256.png| thumb | left | 510px | 256
File:LOD512.png| thumb | left | 510px | 512
File:LOD1024.png| thumb | left | 510px | 1024
</gallery>
}}
{{Important|In one level you can have only 8 light spot/points with shadows which use one and same shadow lod, even if you don't use all them simultaneously. If this limit is not respected - 9-th and next lights will not cast shadows. However - you can rise up this limit with {{ent|point_template}}, just kill past lights with kill input and spawn new when you need it. Also use different shadow lods.}}
{{KV|ShadowFaceX|intn=ShadowFaceX|choices|Shadow Enabled for this Face ?
Determines whether the given side lighting will display shadows.
*0: Enabled
*1: Disabled}}
{{KV|ShadowFaceX_Minus|intn=ShadowFaceX_Minus|choices|Shadow Enabled for this Face ?
Determines whether the given side lighting will display shadows.
*0: Enabled
*1: Disabled}}
{{KV|ShadowFaceY|intn=ShadowFaceY|choices|Shadow Enabled for this Face ?
Determines whether the given side lighting will display shadows.
*0: Enabled
*1: Disabled}}
{{KV|ShadowFaceY_Minus|intn=ShadowFaceY_Minus|choices|Shadow Enabled for this Face ?
Determines whether the given side lighting will display shadows.
*0: Enabled
*1: Disabled}}
{{KV|ShadowFaceZ|intn=ShadowFaceZ|choices|Shadow Enabled for this Face ?
Determines whether the given side lighting will display shadows.
*0: Enabled
*1: Disabled}}
{{KV|ShadowFaceZ_Minus|intn=ShadowFaceZ_Minus|choices|Shadow Enabled for this Face ?
Determines whether the given side lighting will display shadows.
*0: Enabled
*1: Disabled}}
{{KV|NearZ|intn=NearZ|float|NearZ used by shadowmap camera for this light.
Determines distance at which light source will cast shadows.}}
{{KV|DepthBias|intn=DepthBias|float|DepthBias - Offset added to depth values in shadowmaps.}}
{{KV|SlopeDepthBias|intn=SlopeDepthBias|float|Slope Depth Bias - For surfaces having aliasing due to steep angles with light}}.
{{KV|NormalBias|intn=NormalBias|float|While rendering objects into shadow maps, each vertex will be moved along -ve Normal direction, giving it an appearance of shrinking while rendering to shadow maps. This property determines the amount of Units to be moved. Helps with shadow aliasing.}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=500px>
File:NB1.png| thumb | left | 510px | NormalBias - 1
File:NB2.png| thumb | left | 510px | NormalBias - 5
File:NB3.png| thumb | left | 510px | NormalBias - 10
</gallery>
}}
{{bug|Numbers lower than 0.8 can cause huge graphics problems.}}
{{expand|title=The bug example|
<br>
<gallery mode=packed heights=720px>
File:NormalBiasBug.gif| frame | NormalBias - 0
</gallery>
}}
{{KV|ShadowRadius|intn=ShadowRadius|float|Radius of shadow edges for soft shadows. If its value is negative, code will auto assign a value depending on shadowlod. These code based values can be adjusted via convars nr_shadow_rad_High,nr_shadow_rad_Med and nr_shadow_rad_Low.}}
Determines shadow blur. Low numbers are expensive to render.
{{expand|title=Examples|
<br>
<gallery mode=packed heights=500px>
File:BLUR1.png| thumb | left | 510px | ShadowRadius - 0.0001
File:BLUR2.png| thumb | left | 510px | ShadowRadius - 1
File:BLUR3.png| thumb | left | 510px | ShadowRadius - 5
</gallery>
}}
{{KV|Enable Texture Light|intn=bTexLight|choices|Enable Texture Ligh.
Determines whether the given light source uses .vtf texture from game files (just like {{ent|env_projectedtexture}}). With NewLight_Point, this technically works like a cube. A great example is the batteries that use lights/lightcookie_battery.vtf.
*0: Disabled
*1: Enabled}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=410px>
File:TEDisabled.png |Disabled
File:TEEnabled.png |Enabled
File:lightcookie battery.png |Texture that use batteries.
</gallery>
}}
{{Note|One of the most expensive features, use wisely. If shadows enabled - it can work with lags even with powerful PC.}}
{{KV|Texture name for TexLight|intn=texName|string|Texture name for Texture shadows.
Determines which texture will use light source. It use .vtf files, not .vmt.}}
{{KV|.Enable Prop Only Mode|intn=bNegLight|choices|Enable Prop Only Mode.
{{todo|Document what it does.}}
*0: Disabled
*1: Enabled}}
{{KV|LightnGodRayMode|intn=LightnGodRayMode|choices|0:Light 1:Godrays 2:Both Light and GodRays.
*0: Light
*1: Godrays
*2: Both Light and GodRays}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=500px>
File:GAL1.png| thumb | left | 510px | LightnGodRayMode - Light
File:GAL2.png| thumb | left | 510px | LightnGodRayMode - Godrays
File:GAL3.png| thumb | left | 510px | LightnGodRayMode - Both Light and GodRays
</gallery>
}}
{{KV|EnableGodRays|intn=EnableGodRays|choices|Enable GodRays.
Determines whether godrays are enabled or not at map start.
*0: Disabled
*1: Enabled}}
{{warning|You can have only 40 point lights with godrays enabled simultaneously, otherwise game will crash with this error message.}}
<br>
<gallery mode=packed heights=180px>
File:RaysLimit.png| thumb | left | 510px | If you'll try to enable forty-first light point with enabled Godrays.
</gallery>
{{note|Godrays are draw and process even with closed [[areaportals]].}}
{{expand|title=Example|
<br>
<gallery mode=packed heights=710px>
File:RaysDraw.png| thumb | left | 510px | 
</gallery>
}}
{{KV|Density|intn=Density|float|Density Controls the length of rays/volumetric shadows. 1.0 should work in 99% cases. Good values to start from: 0.5 to 1.5.}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=410px>
File:DEN1.gif| thumb |Density - 1.0
File:DEN2.gif| thumb |Density - 2.0
File:DEN3.gif| thumb |Density - 0.5
</gallery>
}}
{{KV|Weight|intn=Weight|float|Weight Controls the intensity of volumetric shadow. Blocking of rays by geometry. Good values to start from: 0.1 - 10.0.}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=410px>
File:WEI10.gif| thumb |Weight - 1.0
File:WEI2.gif| thumb |Weight - 2.0
File:WEI3.gif| thumb |Weight - 5.0
</gallery>
}}
{{KV|Decay|intn=Decay|float|Decay NOT being used.}}
{{todo|Document what does it change.}}
{{KV|Exposure|intn=Exposure|float|Exposure Controls the intensity of Rays during blending pass with main scene. 2.0 is a good start. Good values are 1.0 - 10.0.}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=710px>
File:EXP1.png| thumb |Exposure - 1.00
File:EXP2.png| thumb |Exposure - 10.0
File:EXP3.png| thumb |Exposure - 0.10
</gallery>
}}
{{KV|DistFactor|intn=DistFactor|float|DistFactor Controls the falloff of rays / length. 1.0f is a good starting value increase or decrease in the increments of 0.1. 0.0 will make the rays dissappear only disk will be rendererd.}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=410px>
File:DIST1.gif| thumb |DistFactor - 1.00
File:DIST2.gif| thumb |DistFactor - 10.0
File:DIST3.gif| thumb |DistFactor - 50.0
</gallery>
}}
}}
{{KV|DiskRadius|intn=DiskRadius|float|Radius of Disk/circle of sun in texturespace. 1.0 will be full screen 0.5 is half screen etc.}}
{{KV BmNewLightOldFalloff}}
{{expand|title=Examples|
{{KV BmNewLightBaseMain}}
<br>
{{KV BmNewLightShadowMain}}
<gallery mode=packed heights=710px>
{{KV BmNewLightShadowFace}}
File:DISKR1.png| thumb |DiskRadius - 0.02
{{KV BmNewLightShadowBias}}
File:DISKR2.png| thumb |DiskRadius - 0.10
{{KV BmNewLightCookieMain}}
File:DISKR3.png| thumb |DiskRadius - 1.00
{{KV|LightnGodRayMode|intn=LightnGodRayMode|choices|This determines what effects will be available to use for the light source. Keep in mind that the default choice is Light.
</gallery>
:*0: Light - light only.
:*1: Godrays - godrays only.
:*2: Both Light and GodRays - both light and godrays.
:{{bug|hidetested=1|Even if godrays is turned off, the game will still think that the godrays is used if choice is <code>Godrays</code> or <code>Both Light and GodRays</code>.}}
}}
}}
{{Note|With 0 - will not render.}}
{{KV BmGodraysNormal}}
{{KV|ColorInner|intn=ColorInner|color255| This is the color of the inner circle.}}
{{KV BmGodraysFancy}}
{{expand|title=Examples|
{{KV BmNewLightShadowPasses‎}}
<br>
<gallery mode=packed heights=710px>
File:CRAYS1.png| thumb |255 0 0 255
File:CINN2.png| thumb |0 255 0 255
File:CINN3.png| thumb |0 0 255 255
</gallery>
}}
{{Note|Unlike lighting - brightness of inner depends on fourth number which can be written here.}}
{{KV|ColorRays|intn=ColorRays|color255| This is the color of the rays.}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=710px>
File:CRAYS1.png| thumb |0 0 255 120
File:CRAYS2.png| thumb |0 255 0 120
File:CRAYS3.png| thumb | 255 0 0 120
</gallery>
}}
{{Note|Unlike lighting - brightness of rays depends on fourth number which can be written here.}}
{{KV|GodRaysType|intn=GodRaysType|choices|GodRaysType.
*0: Normal
*1: Fancy}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=710px>
File:GodRaysTypeNormalAlt.png| thumb | Normal
File:GodRaysTypeFancyAlt.png| thumb | Fancy
</gallery>
}}
{{KV|DiskInnerSizePercent|intn=DiskInnerSizePercent|float|Used only in Fancy Gaphics Mode. Disk inner circle radius [[=]] DiskRadius * DiskInnerSizePercent.}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=710px>
File:DISKIR1.png| thumb |DiskInnerSizePercent - 0.75
File:DISKIR2.png| thumb |DiskInnerSizePercent - 0.50
File:DISKIR3.png| thumb |DiskInnerSizePercent - 0.99
</gallery>
}}
{{Note|With 0 - will not render.}}
{{KV|ColorOuter|intn=ColorOuter|color255|Used only in Fancy Mode. This is the color of the outer circle.}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=710px>
File:CRAYS1.png| thumb |0 255 0 255
File:COUT2.png| thumb |255 0 0 255
File:COUT3.png| thumb |0 0 255 255
</gallery>
}}
{{Note|Unlike lighting - brightness of outer depends on fourth number which can be written here.}}
{{KV|Ell_FR_ConstA|intn=Ell_FR_ConstA|float| }}
{{Note|For fancy Godrays only.}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=500px>
File:Ell_FR_ConstA1.png| thumb | left | 510px | 0.9
File:Ell_FR_ConstA2.png| thumb | left | 510px | 5
File:Ell_FR_ConstA3.png| thumb | left | 510px | 10
</gallery>
}}
{{KV|Ell_FR_ConstB|intn=Ell_FR_ConstB|float| }}
{{Note|For fancy Godrays only.}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=500px>
File:Ell_FR_ConstB1.png| thumb | left | 510px | 0.1
File:Ell_FR_ConstB2.png| thumb | left | 510px | 1
File:Ell_FR_ConstB3.png| thumb | left | 510px | 10
</gallery>
}}
{{KV|EEll_SR_ConstA|intn=EEll_SR_ConstA|float| }}
{{KV|EEll_SR_ConstB|intn=EEll_SR_ConstB|float| }}
{{KV|Ell_RRF_ConstA|intn=Ell_RRF_ConstA|float| }}
{{Note|For fancy Godrays only.}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=500px>
File:Ell_RRF_ConstA1.png| thumb | left | 510px | 0.9
File:Ell_RRF_ConstA2.png| thumb | left | 510px | 1.5
File:Ell_RRF_ConstA3.png| thumb | left | 510px | 42
</gallery>
}}
{{KV|Ell_RRF_ConstB|intn=Ell_RRF_ConstB|float| }}
{{Note|For fancy Godrays only.}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=500px>
File:Ell_RRF_ConstB1.png| thumb | left | 510px | 0.1
File:Ell_RRF_ConstB2.png| thumb | left | 510px | 0.7
File:Ell_RRF_ConstB3.png| thumb | left | 510px | 5.0
</gallery>
}}
{{KV|RotSpeed|intn=RotSpeed|float|}}
Determines rotating speed of fancy rays, 0 - don't rotate, negative number - will rotate to left.
{{Note|For fancy Godrays only.}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=500px>
File:RS1.gif| thumb | left | 510px | RotSpeed - 3.14
File:RS2.gif| thumb | left | 510px | RotSpeed - 0
File:RS3.gif| thumb | left | 510px | RotSpeed - 40
</gallery>
}}
{{KV|RotPatternFreq|intn=RotPatternFreq|float|}}
Determines count of fancy rays in frame, with negative number will deny RotSpeed +/- effect.
{{Note|For fancy Godrays only.}}
{{expand|title=Examples|
<br>
<gallery mode=packed heights=500px>
File:RPF1.gif| thumb | left | 510px | RotPatternFreq - -40
File:RPF2.gif| thumb | left | 510px | RotPatternFreq - -40
</gallery>
}}
{{KV|RenderInWorldSpace|intn=m_bEnableWorldSpace|choices|
Disables disks if this enabled.
*0: Disabled
*1: Enabled}}
{{KV|m_fAlphaDiskInner|intn=m_fAlphaDiskInner|float|}}
{{KV|m_fAlphaDiskOuter|intn=m_fAlphaDiskOuter|float| }}
{{KV|UseToneMapRays|intn=m_bUseToneMapRays|choices|
*0: Enabled
*1: Disabled}}
{{KV|UseToneMapDisk|intn=m_bUseToneMapDisk |choices|
*0: Enabled
*1: Disabled}}
{{KV|ShadowPass_Brush|intn=m_bSRO_Brush|choices|Do we want to Render Brushes in shadow passes for this light?
*0: YES
*1: NO}}
{{KV|ShadowPass_StaticProp|intn=m_bSRO_StaticProp|choices|Do we want to Render StaticProps in shadow passes for this light?
*0: YES
*1: NO}}
{{KV|ShadowPass_DynProp|intn=m_bSRO_DynProp|choices|Do we want to Render Dynamic Props in shadow passes for this light?
*0: YES
*1: NO}}
{{KV|ShadowPass_AlphaTest|intn=m_bSRO__Trans|choices|Do we want to Render AlphaTested Objects in shadow passes for this light?
*0: YES
*1: NO}}


==Inputs==
==Inputs==
{{IO|SetColorLight|<color255>. Change Light's Color value. Doesnt effect the godrays}}
{{I|SetColorLight|param=color255|Change light's color value. Doesn't affect the godrays.}}
{{IO|SetIntensityForLight|<float>. Change Light's intensity value. Doesnt effect the godrays}}
{{I|SetIntensityForLight|param=float|Change light's intensity value. Doesn't affect the godrays.}}
{{IO|TurnOnGodRays|Turn the Godrays on.}}
{{I|TurnOnGodRays|param=void|Turn the godrays on.}}
{{IO|TurnOffGodRays|Turn the Godrays off.}}
{{I|TurnOffGodRays|param=void|Turn the godrays off.}}
{{IO|TurnOn|Turn the light on.}}
{{I|TurnOn|param=void|Turn the light on.}}
{{IO|TurnOff|Turn the light off.}}
{{I|TurnOff|param=void|Turn the light off.}}
{{IO|Toggle|Toggle the light's current state.}}
{{I|Toggle|param=void|Toggle the light's current state.}}
{{I BaseEntity}}
 
==Lightcookies==
===What is a lightcookie texture ?===
Lightcookie (a. k. a. "Texture Light") a texture or mask applied to a light source. It is usually used to shape the light's output or fake shadows with specific patterns (which, unlike shadowmaps, can be translucent and look more accurate). It also can be used for stuff like projectors, cautists, disco spheres, etc.
 
In Black Mesa, it can be used via "'''Texture name for TexLight''' ''(texName)''" property (to specify the texture) and "'''Enable Texture Light''' ''(bTexLight)''" (to enable the feature).


==Outputs==
This game used lightcookies mainly for fake shadowmaps and cautists. They are used for some entities by default ([[Item battery (Black Mesa)|batteries]] and grunt pods for example).
{{O BaseEntity|}}


==Issues==
<gallery mode=packed heights=290px>
====Deferred lighting incorrect work with [[$translucent]]====
File:lightcookie0.jpg |Lightcookie is disabled.
Deferred lighting all time rendering through walls with [[material]] [[shader]] parameter [[$translucent]]. This happen because of game can't tell the depth of scene because of the transparency, what you are see in the picture is just the lighting layer applied to the color of transparency texture.
File:lightcookie1.jpg |Lightcookie is enabled.
<br>
<gallery mode=packed heights=410px>
File:BugHah.png| frame | No [[$translucent]]. Behind the wall placed lighting and some models with small room.
File:BugDamn.png| frame | With [[$translucent]]. Now player see everything, but only what lighted.
</gallery>
</gallery>
<br>
 
<gallery mode=packed heights=410px>
Lightcookies are disabled with 2 ('''Low''') value for {{cmd|nr_shadow_quality}} ('''Dynamic Shadow Quality''').
File:GargHah1.png| frame | Scene behide window. Looks like the gargantua has lost its texture and turned white.
===Texture mask===
File:GargDamn1.png| frame | Scene out window. This is what should see player.
The texture mask defines which pixels will display the lighting and also affects their color. Black pixel color will not render the light at all, white will render the light and its color value, other colors (red, blue, yellow, etc.) will be mixed with the light color value, depending on their intensity and how close they are to white. Alpha channel doesn't affect anything, so make sure you don't use it in your texture.
 
Point lights requires "Environment Map" texture to work with lightcookies, because point lights are using 6 separate faces, so each face requires separate texture. Follow [[$envmap#Creating_a_custom_static_cubemap_texture|these steps]] to create "Environment Map" texture.
 
Spot lights can use any texture basically.
 
It is recommended to use '''No Mipmap''' and '''No Level Of Detail''' flags for your [[VTF]] file, so the texture will not cause aliasing issues.
 
<gallery mode=packed heights=290px>
File:lightcookie_aliasing.jpg |Two point lights with two different lightcookie textures. The left don't use the flags, unlike the right texture.
</gallery>
</gallery>
This problem also applies to brushes which not have [[$translucent]], but which parented to brushes that have this parameter. Similar will happen if brush with [[$translucent]] is part of your brush entity.
 
<br>
{{important|Lightcookies are not using [[VMT]] materials, you only need texture.}}
<gallery mode=packed heights=410px>
 
File:BSFL1.png| frame | This sticker is brush parented to the glass. Flashlight off.
===Animation===
File:BSFL2.png| frame | This sticker is brush parented to the glass. Flashlight on.
Spot lights also support 2 different animation types, which allow you to animate a texture in two different ways.
 
====Texture Cookie FPS====
In this mode, a spot light will split image into specified amount of frames (so called atlases) and change frames with specified speed (FPS).
 
The splitting of specified texture into separate parts is done using two-dimensional arrays (in this context, this can also be called a two-dimensional table). The value from '''TexCookieFramesX''' (''TexCookieFramesX'') creates the specified number of rows, the value from '''TexCookieFramesY''' (''TexCookieFramesY'') creates the specified number of columns.
 
The final number of frames is the value from '''TexCookieFramesX''' multiplied by '''TexCookieFramesY'''. For example, value 3 in both '''TexCookieFramesX''' and '''TexCookieFramesY''' will split image into 9 parts.
 
<gallery mode=packed heights=290px>
File:Background01.jpg |''console\background01.vtf'' original image.
File:background01_lightcookie_spit.jpg |''console\background01.vtf'' splitted into 9 parts (3 by 3).
</gallery>
</gallery>
Same will happen if you use [[overlays]]/[[decals]] on brushes with [[$translucent]].
 
<br>
The spot light will change frames from top to bottom and left to right. The frames from the top row are shown first, the spot light passes over them from left to right, then moves down to the next row. If it showed the last frame, it will restart the process. The amount of time it takes to move to the next frame depends on specified value from '''TexCookieFps''' (''TexCookieFps'').
<gallery mode=packed heights=410px>
 
File:MS1.png| frame | Metal speaker is overlay that use [[$alphatest]], but lighting of the health charger visible anyway, because overlay pasted on the transparency window.
====Texture Cookie Scroll Mode====
In this mode, lightcookie texture can scroll in X and Y directions. This feature can be enabled with '''Tex Cookie Scroll Mode''' (''bTexCookieScrollMode'') property.
 
X direction controlled by '''ScrollSpeedU''' (''fScrollSpeedU'') property. Y direction controlled by '''ScrollSpeedV''' (''fScrollSpeedV'') property. Both takes a float value. The default X direction is left, Y is up. Using a value multiplied by -1 will reverse direction, this allows you to use 8 different scroll directions. 0 means don't move in this direction. The size of the value affects the scroll speed.
 
Here is the [https://youtu.be/FkUFF6CLTq8 video] showcase of all 8 directions and how the feature look like.
 
{{note|Combing this mode with previous will result in using first atlas frame for scroll mode.}}
 
==Shadow Mapping==
To cast dynamic shadows, Black Mesa uses {{WP|shadow mapping}} (shadow maps for short) technique for new point and spot light entities when '''HasShadow''' property is enabled. Used local shadowmap camera and [[Depth buffer|depth buffer]].
<gallery mode=packed heights=310px>
File:BmsShadowMapBuffer.jpg| frame |Flashlight's shadowmap camera in depth buffer.
File:BmsShadowMapFinnal.jpg| frame |The final image.
</gallery>
</gallery>
This issues not happen if replace [[LightmappedGeneric]] to [[ShatteredGlass]] shader. [[ShatteredGlass]] give similar to [[LightmappedGeneric]] results, so, you can use it for glass or transparency surfaces when it's needed.
Spot light uses only one camera, while point lights 6 for 6 different directions to make more accurate shadows for omnidirectional light, this is why it takes 6 shadowmap slots ([[NewLight_Point#Shadow_map_slots|see below]]) and 6 times the cost of new spot light. You can disable each shadowmap individually for a new point light entity.
<br>
 
The shadowmaps stored in a large shadowmap atlas, which makes having lots of shadowmap textures a lot cheaper for GPU. There is two of them, one for static shadowmaps ([[NewLight_Point#Static_shadow_maps|see below]]) and one more for dynamic shadowmaps.
<gallery mode=packed heights=410px>
<gallery mode=packed heights=410px>
File:HahF1.png| frame | [[LightmappedGeneric]].
File:BmsShadowMapAtlas.jpg| frame |One of the shadow atlases.
File:HahF2.png| frame | [[ShatteredGlass]].
</gallery>
</gallery>
In some cases use [[$alphatest]] if it'll give similar to [[$translucent]] resualts, with this your surface also will cast dynamic shadows.
 
<br>
Because shadowmap is a texture with limited amount of pixels in it, distance from the light source and objects makes it less accurate a distance.
<gallery mode=packed heights=410px>
<gallery mode=packed heights=410px>
File:AF1.png| frame | [[$translucent]].
File:BmsShadowMapDist1.jpg| frame |Small distance between the light source and [[Npc barney|Barney]]'s model.
File:AF2.png| frame | [[$alphatest]].
File:BmsShadowMapDist2.jpg| frame |Large distance between the light source and [[Npc barney|Barney]]'s model.
</gallery>
</gallery>
====Deferred lighting incorrect work with [[$alphatestreference]] and [[$allowalphatocoverage]]====
 
[[$alphatestreference]] is a [[material]] [[shader]] parameter that specifies the threshold alpha channel value at which the surface should be transparent instead of opaque, default "0.5". [[$allowalphatocoverage]] creates translucent steps based on alpha values. Both have one and same problems with deferred lighting.
Shadow [[Field of View|FOV]], which can be changed with '''OuterAngle''' property or '''ShadowFOV''' property, also affects shadowmap quality. Due to the pixels spread, shadows are less accurate with large FOV values.
For examples used this texture with this alpha channel.
<br>
<gallery mode=packed heights=410px>
<gallery mode=packed heights=410px>
File:ATSC_D.png| frame | Diffuse texture.
File:BmsShadowMapFovQ1.jpg| frame |60 '''OuterAngle''' value.
File:ATSC_A.png| frame | Alpha channel.
File:BmsShadowMapFovQ2.jpg| frame |170 '''OuterAngle''' value.
</gallery>
</gallery>
Here deferred lighting placed behind wall with the texture, lighting is red and shadows is blue. We can see the circle part of that have alpha channel part which is invisible due to $alphatest, with enabled deferred lighting we see that the invisible part doesn't show through itself deferred lighting with shadows.
 
<br>
There is 3 shadowmap resolutions, small (256), medium (512) and big (1024). Higher values create sharper, more accurate shadows, but cost much more to render. Sharp shadows may not be appropriate for all situations either, sometimes soft shadows look more accurate. They are defined by '''ShadowMapLOD''' property, which uses hard coded choice (0, 1, 2), this is why it's not possible to use custom shadowmap resolutions. Each shadowmap resolution takes one shadowmap slot.
<gallery mode=packed heights=410px>
<gallery mode=packed heights=310px>
File:ODSL_1.png| frame | Dynamic light disabled behind wall with the texture, using standart VRAD light.
File:ShadowMapLOD256.jpg| 510px | 256
File:ODSL_2.png| frame | Dynamic light enabled behind wall with the texture, not using standart VRAD light.
File:ShadowMapLOD512.jpg| 510px | 512
File:ShadowMapLOD1024.jpg| 510px | 1024
</gallery>
</gallery>
From the opposite side the invisible part illuminates everything in itself equally, without taking into account decay of light, it's also don't show shadows and other dynamic lights in itself.
The edges of the shadows can be made smoother (or more stepped) with '''ShadowRadius''' property. It determines the radius of shadow edges for soft shadows. If its value is negative, code will auto assign a value depending on ShadowLod. These code based values can be adjusted via convars {{command|nr_shadow_rad_High}}, {{command|nr_shadow_rad_Med}} and {{command|nr_shadow_rad_Low}}.
<br>
<gallery mode=packed heights=290px>
<gallery mode=packed heights=410px>
File:ShadowRaduis1.jpg| 510px | ShadowRadius - 0.0001
File:IIPSEE_.png| frame | Dynamic light disabled, using standart VRAD light.
File:ShadowRaduis2.jpg| 510px | ShadowRadius - 1
File:IIPSEE.png| frame | Dynamic light enabled, not using standart VRAD light.
File:ShadowRaduis3.jpg| 510px | ShadowRadius - 5
</gallery>
</gallery>
If use very low numbers you will see resualts like in the pictures.
 
<br>
The '''NearZ''' distance used by shadowmap camera (distance at which the light source will start cast shadows) can be controlled with '''NearZ''' property. The '''FarZ''' distance uses value from '''Range''' property.
 
Console variable {{cmd|nr_shadow_quality}} sets shadow quality and enable/disable shadows for all or certain objects. Controlled by Dynamic Shadow Quality option. Only 5 values are available for it:
* 0 (Disabled) - Shadows and lightcookies are completely disabled.
* 1 (POTATO) - Shadows are available for world geometry and displacements, only for Static and Stationary light types. The shadows are very pixelated. The player's flashlight also gets very simple shadows with "stairs".
* 2 (Low) - Added brush entities and static props in shadowmaps, only for Static and Stationary light types. Enabled lightcookies.
* 3 (Medium) - All the shadows are also available for Dynamic light type.
* 4 (Hight) - Added dynamic models in shadowmaps for Stationary and Dynamic.
 
Console variable {{cmd|nr_shadow_res}} affects the quality of shadows. Controlled by Dynamic Shadow Memory option. Only 4 values are available for  it:
* 0 (Hight) - Hight quality.
* 1 (Medium) - Medium quality.
* 2 (Low) - Low quality.
* 3 (POTATO) - Very low quality.
 
{{bug|hidetested=1|If there are too many shadowmaps in a frame, this can lead to laggy shadow atlas update.
{{todo|How many ?}}
}}
 
===Shadow filtering===
Versions of the game before Necro Patch uses PСF filter. The shadow edges are sharper and exhibit a more distinct transition. There are visible aliasing artifacts, particularly on the edges. Shadows from small or thin objects were also indistinguishable. However, it was pretty good for shadows with low resolution, because they looked blurry. The shadows are somewhat similar to those that can be seen from the [[projected texture|projected textures]] in {{portal2|4}}.
<gallery mode=packed heights=410px>
<gallery mode=packed heights=410px>
File:CCCC_11.png| frame | Dynamic light disabled, using standart VRAD light.
File:shadowfilter_old.jpg| frame |Barney's hand with old shadow filtering.
File:CCCC_12.png| frame | Dynamic light enabled, not using standart VRAD light.
</gallery>
</gallery>
<br>
The Necro Patch replaced PСF filter with PCSS filter. The shadow edges appear smoother and less jagged. The transition from the shadow to the lit area has more gradient-like softening. Shadows have become more detailed for small objects. Because of this, you have to adjust the shadows more carefully.
<gallery mode=packed heights=410px>
<gallery mode=packed heights=410px>
File:CCCC_21.png| frame | Dynamic light disabled, using standart VRAD light.
File:shadowfilter_new.jpg| frame |Barney's hand with new shadow filtering.
File:CCCC_22.png| frame | Dynamic light enabled, not using standart VRAD light.
</gallery>
</gallery>
You can't escape this problem, only minimize effect with <code>$alphatestreference 0.1</code> or if paint alpha correct channel.
This filter has one significant issue: there is now noticeable noise in the shadows. This is mostly noticeable in low resolution shadows, this spoils them quite a lot (although it makes them more detailed). There is no way to disable this effect. The noise also makes the shadows more similar to shadows from flashlight in {{hl2|4}}. It is worth noting that such thing exists in more modern engines ([https://en.wikipedia.org/wiki/Unreal_Engine Unreal Engine 5] for example, even though they are not easily visible due to [[Anti-aliasing#TAA/TSSAA|temporal anti-aliasing]] smoothing the artifact), so you can ignore the noise if it's not very noticeable, especially on shadows with high quality.
====Godrays incorrect work with [[$alphatestreference]] and [[$allowalphatocoverage]]====
 
Godrays process invisable parts, you can't escape this problem, only minimize effect with <code>$alphatestreference 0.1</code> or if paint alpha correct channel.
The noise is adjusted via ShadowRadius and ShadowMapLOD values, mainly via ShadowRadius; you even can disable the noise with 0 value, but this will make your shadows will look like stairs/pixels.  
<br>
<gallery mode=packed heights=310px>
<gallery mode=packed heights=710px>
File:shadowfilter_new1.jpg| frame |The noise example.
File:GIWTAAA.png| frame | An example.
</gallery>
</gallery>
You can't escape this problem, only minimize effect with <code>$alphatestreference 0.1</code> or if paint alpha correct channel.
{{note|It is not entirely clear which term is correct, '''PCSS''' or '''PCCS''', since it could be orgography, but it is possible (though unlikely) that they created their own filter.}}
====Godrays incorrect work with [[$translucent]]====
 
Godrays (also disk) all time fully rendering through textures with [[material]] [[shader]] parameter [[$translucent]], because of this you will see unexpected results like in the picture. Disable Godrays when you need or use [[$alphatest]] if it'll give resualts similar to [[$translucent]]. You also can try use some other tricks to escape this problem.
===Static shadow maps===
<br>
If our light source remains in the same position and never changes it, we expect that shadows from world geometry, [[displacement]], {{ent|prop_static}} and even [[bmodel|bmodels]] (brush entities) are completely static, this means that we don't need to update shadows for them every frame, so it would be nice to bake shadows for all such objects to save performance. This is why we need static shadow maps.
 
When your light appears, static shadow maps skip all the dynamic models in their pass and take 1-6 pictures of everything mentioned above, then static shadow maps applies to the lighting from the light source and never change again (until save reload).
 
This doesn't happen if your light source is disabled, so you need to keep it enabled on spawn around 1 second. If you need disabled light source - set intensity value to 0 and then after 1 second turn off light source (don't forget to set required intensity value).
 
Static shadow maps are used for Static and Stationary light type. For Stationary type, engine also disable shadows passes in dynamic shadows for everything mentioned above, so that the use of static shadow maps makes sense (this still saves performance quite well). Dynamic light type don't use static shadow maps at all, because it can move, so we need to have dynamic shadows for everything.
 
Important to note that bmodels are also in static shadows maps, including {{ent|func_physbox}}, {{ent|func_door}}, {{ent|func_breakable}}, etc. This is true, despite the fact that such objects can be removed or moved. Most likely this is due to {{ent|func_detail}}, which is very similar in principle to regular world geometry, but cannot be removed or moved, unlike all other brush entities. It gives some problems, because shadows from lab doors or elevators will remain static, while these objects are moving. There are 2 good ways to workaround this issue, "lazy" method and " time-consuming" method. The first is very simple and quick, just use Dynamic light type, this will reduce performance but will completely fix the problem and save your time. The second is using [[Propper]] with converting your brush to model, you'll need spend time on {{ent|propper_model}} setting and brush replacing, but this will also save performance and solve the problem.
 
===Shadow map slots===
Shadow map slots is how many lights with shadows you can have per level. There are 3 separate shadow map slots, <code>High</code> (for lights with <code>1024</code> value for <code>ShadowMap LOD</code> property), <code>Medium</code> (for lights with <code>512</code> value for <code>ShadowMap LOD</code> property) and <code>Low</code> (for lights with <code>256</code> value for <code>ShadowMap LOD</code> property).
 
In <code>High</code> and <code>Medium</code> you can have 48 separate shadow maps, for <code>Low</code> you can have 47 separate shadow maps (143 shadow maps in total).
 
Each spot light with shadows takes 1 shadow map slot, so you can have 48/47 spot lights with shadows, if they are using the same value for <code>ShadowMap LOD</code> property.
 
Each point light with shadows takes 6 shadow map slots, because point light uses 6 separate shadow maps to render shadows. This means that you can have 8 point lights with shadows, if they are using the same value for <code>ShadowMap LOD</code> property. You can increase this value if you need, just disable shadows for one of the shadow face properties.
 
If one of the shadow map slots is full - you will not be able to have shadows for more lights with such shadow quality, you will need to use other value for <code>ShadowMap LOD</code> property.
 
Point lights and spot lights doesn't counts separately. You can't have 48 spot lights with 8 point lights, but you can have 6 spot lights with 7 point lights.
 
You can free up shadow map slots with <code>Kill</code> input. So, you can place triggers which will <code>Kill</code> lights that player can't see and spawn new lights via {{ent|point_template}} (uncheck the second flag for {{ent|point_template}}, this prevents some bugs). This helps a lot when you want to have many dynamic lights in different areas.
 
Important to note that due to some engine bugs you can't use many lights with shadows. Some tests show that 9th point light cause lights with shadows to be very glitchy. This can be done with spot lights as well. So don't be surprised if at some point you find something like this.
<gallery mode=packed heights=410px>
<gallery mode=packed heights=410px>
File:GodraysTransBug.png| frame | Bug example in bm_c1a3c.
File:manyshadowslotsbugg.jpg| frame |The bug example.
File:GodraysTransBugSide.png| frame | Sign from other side.
</gallery>
</gallery>
====Godrays draw through water====
 
Deferred lighting don't fully draw through water, unlike Godrays.
It looks like you can workaround it if you will switch <code>ShadowMap LOD</code> property values from higher to lower.
<br>
 
<gallery mode=packed heights=710px>
{{tip|You can use {{command|nr_debug_print_shadow_slots_info}} to get full info about shadowmap slots.}}
File:c3m0c.png| frame | Black Mesa: Blue Shift - bs_c3m0c.
 
</gallery>
===Shadow map passes per frame===
====Godrays may leak in some cases====
Instead of using the current value from the [[FPS]], shadows use the value from {{cmd|nr_shadow_max_passes_per_frame}} console variable. It stagger the updation of shadow maps, for both static and dynamic, over a few frames. This feature adjustable via '''Dynamic Shadow Memory''' graphics settings. This solution preserves performance, since instead of using 300 from FPS value, the shadow will be updated only 24 times per second, which is enough to display most scenes in dynamic shadows.
Due to way Godrays works, in some cases they can be drawn through walls, appearing where they should not be visible at all. Disable rays with triggers or minimize effect.
{{bug|hidetested=1|'''"End Game"''' chapter crashes at some moment with 29 and higher values.}}
<br>
 
<gallery mode=packed heights=710px>
===Shadows behavior with [[VIS]] and [[areaportals]]===
File:bmsleak(Someone_from_Valve_please_allow_to_BM_devs_to_publish_the_game_code_to_make_possible_for_us_fix_this_bugs_please).gif| frame | An example.
====Static type====
</gallery>
Static type is the most stable, since its shadows are baked in and updates only with save loads or while lighting  turning on. It shows all shadows even with closed [[areaportal]].
====Godrays can't be displayed in monitors and reflections====
Godrays is post process effect that depends on player screen. That means that they can't water reflections or monitors can't show it.
<br>
<gallery mode=packed heights=410px>
<gallery mode=packed heights=410px>
File:GodraysInWater.png| frame | An example.
File:staticlight_0.jpg| frame |Areaportal is open.
File:GodraysInMonitor.png| frame | An example.
File:staticlight_1.jpg| frame |Areaportal is closed.
</gallery>
</gallery>
====Weird clipping====
====Stationary type====
Often meeting strange clipping/flickering, strange phenomenon that also was in early stages of the game, this does not depend on OS or drivers, despite this there are rumors that this occurs most often among users of Linux. There is no known way to deal with this, most often happen with [[NewLight_Spot]].
Shadows for static props and brushes are baked, but not for physics props and other dynamic models. This means that shadows from dynamic models will disappear if they are hidden by a closed areaportal or if [[VIS]] is hiding such objects. Shadows for static props and brushes will not disappear.
<br>
<gallery mode=packed heights=410px>
<gallery mode=packed heights=410px>
File:WC1.gif| frame |One of many examples.
File:stationlight_0.jpg| frame |Areaportal is open.
File:WC2.gif| frame |One of many examples.
File:stationlight_1.jpg| frame |Areaportal is closed.
File:WC3.gif| frame |One of many examples.
</gallery>
</gallery>
====Brush polygons may clip deferred lighting====
 
Rare phenomenon, sometimes brush polygons clip deferred lighting, the reason that cause this is unknown. Can be easy fixed if divide invalid brush into two parts.
In some cases, this can be noticeable if dynamic model creates a large shadow.
<br>
<gallery mode=packed heights=410px>
<gallery mode=packed heights=410px>
File:BPl0.png| frame | One of examples (mat_wireframe 0).
File:Theboxshadow_0.jpg| frame |Areaportal hides the box, note that there is no shadow.
File:BPl1.png| frame | One of examples (mat_wireframe 1).
File:Theboxshadow_1.jpg| frame |Areaportal shows the box, now there is a shadow of the box.
</gallery>
</gallery>
<br>
With {{command|mat_wireframe|1}}.
<gallery mode=packed heights=410px>
<gallery mode=packed heights=410px>
File:BPb0.png| frame | One of examples (mat_wireframe 0).
File:thewireboxshadow_0.jpg| frame |Areaportal hides the box.
File:BPb1.png| frame | One of examples (mat_wireframe 1).
File:thewireboxshadow_1.jpg| frame |Areaportal shows the box.
</gallery>
</gallery>
====Shadows incorrect work with [[newLight_Point]] cube edges====
 
Because [[newLight_Point]] arу cube technically - we get shadows incorrect behavior with edges of this cube, this can sometimes lead to their serious distortion a.k.a. clipping. You only can minimize this if set shadow quality to maximum.
====Dynamic type====
<br>
Shadows for static props and world geometry are baked, but not for dynamic models and brushes. This means that shadows from dynamic models and brushes will disappear if they are hidden by a closed areaportal or if [[VIS]] is hiding such objects. Shadows for static props and world geometry will not disappear. Moving lighting will update shadows for static props and world geometry, even with closed areaportal.
<gallery mode=packed heights=710px>
File:SIWENCE0.png| frame |One of many examples.
File:SIWENCE1.png| frame |One of many examples.
File:SIWENCE_2.png| frame |One of many examples.
</gallery>
====Deferred lighting shine through [[nodraw]] texture====
Not a bug, but a pattern. Unfortunately, this cannot be controlled in any way, you should keep in mind this before paint [[nodraw]] to escape situations like in the gifs. If your dynamic light source illuminates face that player never see - use cheap textures with low resolution and which don't use material shader parameters, a good solution would be dev textures.
<br>
<gallery mode=packed heights=410px>
<gallery mode=packed heights=410px>
File:SLB1.gif| frame | Black Mesa - bm_c2a2a.
File:dynlight_0.jpg| frame |Areaportal is open.
File:SLB2.gif| frame | Black Mesa: Blue Shift - bs_c0m0c.
File:dynlight_1.jpg| frame |Areaportal is closed.
</gallery>
</gallery>
====Shadows don't appear immediately after reload====
 
After game save and load shadows don't appear for short time, maybe it has something to do with caching. This appearance duration may vary depending on power of user PC and how much of lights with enabled shadows are turned on at level, but in any case user will get this issue even with most powerful PC. Enable in [[worldspawn]] settings <code>Level Fade In</code> to hide this problem, this setting also will hide some other problems with loads that avaible in{{bms|4}}.
===Player spawn and areaportals===
<br>
If player spawned in position where areaportal don't hide objects - shadows will be fine. Otherwise, static shadowmap will not see models with [[bmodel|bmodels]] and will bake shadows only for world geometry and displacements. This problem is not relevant only for Dynamic light type. The problem disappears after save reload from proper position.
<gallery mode=packed heights=410px>
<gallery mode=packed heights=410px>
File:SDAIAR1.gif| frame | With no <code>Level Fade In</code>. It seems like the shadows flicker, which makes it unpleasant for eyes.
File:psaa_0.jpg| frame |Player spawned in position where areaportal don't hide objects. The columns are {{ent|func_detail}}, the pipes are {{ent|prop_static}}.
File:SDAIAR2.gif| frame | With <code>Level Fade In</code>. Everything looks fine.
File:psaa_1.jpg| frame |Player spawned in position where areaportal hide objects. Note that the columns and pipes don't have any shadows.
</gallery>
</gallery>
====Shadows don't appear immediately with a lot of lights with shadows====
 
If your level use a lot of lights with shadows - shadows from enabling lights will not appear immediately, this happens if light source was disabled and if player's camera did not see this light source enabled initially. Can be fixed if enable light source at level start and keep it enabled before drawing of level allows player's camera to see this light source, disable this light source and than enable when we need this.
===Shadows behavior with start/end fade dist for prop_static===
<br>
This mechanic has some issues with static shadowmaps. It seems that there are limitations that don't allow to fix these issues, or this issues was not noticed at the development stage.
====Static type====
If player spawns in fade radius - shadows will never disappear (until save reload if out of radius).
<gallery mode=packed heights=410px>
<gallery mode=packed heights=410px>
File:SDAIWALOLWS1.gif| frame | An example.
File:fadepropstaticlight_1.jpg| frame |In radius.
File:SDAIWALOLWS2.gif| frame | bm_c2a1a.
File:fadepropstaticlight_0.jpg| frame |Out of radius.
</gallery>
</gallery>
====Dynamic lights with shadows may buggy====
If player spawns out of radius. - shadows will never appear (until save reload in radius).
In some cases your attached lights may have buggy shadows if parent moving, work smart when use this feature. If your moving light is decoration - highly recommended to leave shadows disabled to save limits and performance.
<br>
<gallery mode=packed heights=410px>
<gallery mode=packed heights=410px>
File:DLWSMB1.gif| frame | An example.
File:fadepropstaticlight_3.jpg| frame |
File:DLWSMB2.gif| frame | bm_c1a1c.
</gallery>
</gallery>
====[[Viewmodel]] illuminated by deferred render draw in [[refract]] shader====
The same for props with both Start and End fade dist.
Refract shader and [[Water_(shader)|Water]] shader take and refract player screen space without taking into account viewmodel. However - viewmodel illuminated by deferred render draw in refract shader because of game can't tell the depth of viewmodel because of the transparency, what you are see in the pictures is just the lighting layer applied to the color of transparency texture.
====Stationary type====
<br>
The above mentioned issues are also available for this type.
<gallery mode=packed heights=710px>
 
File:DFS1Alt.png| frame |Clear example in test map, the hivehand illuminated by deferred render draw in the refract texture, plus it's completely discolored there..
Appears issue for prop_static with both Start and End fade dist.
File:DFS2.png| frame |Black Mesa - bm_c4a1a.
 
File:DFS3.png| frame |Black Mesa: Blue Shift - bs_c2m0a.
If player spawns in Start fade radius - shadows will never disappear (until save reload if out of radius). The same happens if player spawns in End fade radius.
 
If player spawns out of radius - shadows will appear if you are in End fade radius and disappear if you are in Start fade radius (until save reload in radius). This happens because prop_static actually disappears completely, and creates a separate object as a fading model (this is also why decals disappear if player is out of Start fade radius).
 
<gallery mode=packed heights=210px>
File:fadepropstatiorlight_1.jpg| frame |In radius.
File:fadepropstatiorlight_2.jpg| frame |Out of Start fade radius.
File:fadepropstatiorlight_3.jpg| frame |Out of End fade radius.
</gallery>
</gallery>
====Viewmodel doesn't support self-shadowing with deferred ligths====
 
Unlike cascade shadows - viewmodel doesn't support self-shadowing with deferred ligths. Not a bug, but this is not what you expect from real life, it also isn't so with [[env_projectedtexture]].
====Dynamic type====
<br>
Dynamic type don't use static shadowmaps at all. This means that there is no problems with fading prop_static at all.
<gallery mode=packed heights=410px>
{{important|All the issues are also available for {{ent|func_lod}}.}}
File:CSMSF.png| frame | Here you can see how one of gluon gun switches create shadow that fall on other part of gun.
 
File:DFSF.png| frame | Light spot illuminates gluon gun, but lighting just ignore viewmodel and fully shine through, although only the side of the gun should be light.
==Godrays Implementation==
===Implementation===
Godrays in this game are based on [[Sprite|sprite]] entities. They are a post-processed 2D plane that always turns to player's camera. The size of such plane is consistent with the screen size making it appear larger at a distance, in comparison to the world, similar to how '''Glow''' render mode works for {{ent|env_sprite}}, but unlike the render mode, such plane is rendered so that the sprite will cut through any surrounding geometry, similar to how '''Additive''' render mode works for {{ent|env_sprite}}.
<gallery mode=packed heights=210px>
File:grandsprite_0.jpg| frame |Sprite.
File:grandsprite_1.jpg| frame |Godrays.
</gallery>
</gallery>
====Godrays and deferred lighting incorrect work with cloak====
This plane is also not affected by VIS, which means that you will always see it, even if your area in which your light source is located is closed by an areoportal.
Cloak is a material shader parameter for <code>VertexLitGeneric</code> shader, female assassins use it to make them transparent when they need it. Godrays all time fully render through them, same for deferred lighting.
<gallery mode=packed heights=290px>
<br>
File:cRaysDraw.jpg| thumb | left | 510px |
<gallery mode=packed heights=410px>
File:ASSASINRAYS.png| frame | bm_c2a3c, the sun's rays are not cut off despite the fact that she is completely untransparent right now.
File:ASSASINDF.png| frame | bm_c2a3c, she is completely untransparent, but we still can see one of lighting layers.
</gallery>
</gallery>
====Godrays doesn't refract by refract shader and fully draw through====
Such implementation has several  consequences that limits amount of cases when you can use it.
Unlike deferred lighting Godrays doesn't refract by refract shader, also fully draw through.
===Limitations And Use Tips===
<br>
Local point light godrays can "leak" (example on the pictures), since nothing limits the rendering and the size of the plane. The only you can do is place triggers that will turn on/off godrays, but this also basically means  you can't use godrays in multiplayer levels, because multiple players can be located in different places of your map (there is no way to disable godrays for each client separately).
<gallery mode=packed heights=710px>
<gallery mode=packed heights=310px>
File:AnGodexample.gif| frame |An example.
File:godraysleak0.jpg| frame |
File:godraysleak1.jpg| frame |
</gallery>
</gallery>
====Strange "holes" when player's camera is at a great distance====
Because godrays always turns to player's camera, make sure you are using this effect in areas where view angle for player is very limited. The reason is showed in this short video [https://youtu.be/YvhWpE_X4RU clip], note how battery stops processing at some moment.
In some cases may will appear strange "holes" when player's camera is at a great distance. Strange bug that occurs quite rarely, can be fixed if increase <code>NormalBias</code> number.
<gallery mode=packed heights=310px>
{{ModernConfirm|Does it happen with [[newLight_Spot]] ?}}
File:godrayslimiting0.jpg| frame |Bad example, player's view angle is not limited, the player also can walk around in any direction. Both factors are making godrays leaking and bad clipping most of the time.
<br>
File:godrayslimiting1.jpg| frame |Good example, player can look at the godrays forwardly only. The player also can walk only back or forward in this area. Both factors making the godrays nice looking.
<gallery mode=packed heights=710px>
File:AnFuexample.gif| frame | Example in bm_c4a1b1, the green teleporter light source starts to glitch when player move certain distance.
</gallery>
</gallery>
{{note|Everything mentioned here also applies to the disks.}}
==Dedicated [[ConVars]]==
{{varcom|start}}
{{varcom|nr_allow_hammer_nerfs|0|[[Integer]]|Allow new lights nerfs via {{ent|Newlights_gbuffersettings}} entity.
0 - Disabled.
1 - Allowed.
2 - Enabled/Forced.
}}
{{varcom|nr_allow_hammer_nerfs_4ways|0|Integer|Allow {{code|Enable4WaysFastPath}} property from {{ent|Newlights_gbuffersettings}} entity.
0 - Disabled.
1 - Allowed.
2 - Enabled/Forced.
}}
{{varcom|nr_shadow_max_passes_per_frame|16|[[Float]]|Frame per second in shadowmaps. The higher the value, the smoother and faster the shadows from objects can change. The recommended value is 24-28, not higher.}}
{{varcom|nr_shadow_quality|4|Integer|Sets shadow quality and enable/disable shadows for all or certain objects. Controlled by '''Dynamic Shadow Quality''' option. Only 5 values are available here.
0 (Disabled) - Shadows and lightcookies are completely disabled.
1 (POTATO) - Shadows are available for world geometry and displacements, only for '''Static''' and '''Stationary''' light types. The shadows are very pixelated. The player's flashlight also gets very simple shadows with "stairs".
2 (Low) - Added brush entities and static props in shadowmaps, only for '''Static''' and '''Stationary''' light types. Enabled lightcookies.
3 (Medium) - All the shadows are also available for '''Dynamic''' light type.
4 (Hight) - Added dynamic models in shadowmaps for '''Stationary''' and '''Dynamic'''.
}}
{{varcom|mat_unlock_gfx_highend_unsupported|0|[[Bool]]|When enabled this convar will unlock extreme graphics options. There will be a significant FPS drop when running game on ULTRA or INSANE configs. Game will consume upto 3 gigs of VRAM when some of the extreme graphics options have been enabled. These high end graphics config options are not officially supported. Don't enable this unless you have at least 3.5 GHZ quad core CPU with GTX 1080. These options are mainly for debugging and modders.}}
{{varcom|nr_lights_quality|4|Integer|Sets lights quality, state (for specific entities), enable/disable effects. Controlled by '''Dynamic Light Quality''' option. Only 7 values are available here.
0 (POTATO) - Disabled muzzle flash light (regardless of {{command|muzzleflash_light}}), lighting from batteries (regardless of {{command|cl_battery_dlights}}), light sources from [[dynlightscript.txt]], dynamic lights are also disabled for some other entities. Halflambertion is disabled. New specular is disabled. Bumpmaps are disabled. Lights are disabled completely in secondary cameras (monitors, water, etc). Overlaying on viewmodel looks pretty broken. Light is not smoothed out (most noticeable in the least bright areas).
1 (Low) - Allowed muzzle flash light, lighting from batteries, enabled light sources from [[dynlightscript.txt]], other dynamic lights are also enabled for some other entities. Enabled bumpmaps for models.
2 (Medium) - Enabled bumpmaps for brushes. Lights in secondary cameras, but most effects is disabled.
3 (Hight) - Halflambertion with new specular is enabled. Fixed overlaying on viewmodel. Light is smoothed out.
4 (Very Hight) - Bumpmaps are also uncompressed, this makes lighting on surfaces more detailed.
5 (INSANE) - All the effects is enabled in secondary cameras.
6 (DevOnly) - This one for developers only. Includes uncompressed buffers and 32-bit depth. Don't use if you are general player or modder.
}}
{{varcom|nr_shadow_res|0|Integer|Affects the quality of shadows. Controlled by '''Dynamic Shadow Memory''' option. Only 4 values are available here.
0 (Hight) - Hight quality.
1 (Medium) - Medium quality.
2 (Low) - Low quality.
3 (POTATO) - Very low quality.
}}
{{varcom|nr_shadow_res_dkvk|0|Integer|It doesn't seem to work.}}
{{varcom|r_4way_minimal_mode_override|-1|Integer|Enable/disable bumpmaps for {{ent|Lightmapped_4WayBlend}}. Since one material of this shader provides 4 bumpmaps at once, disabling them will significantly affect performance.
-1/0 - Enabled.
1/2 - Disabled.
{{note|This cvar needs {{command|mat_reloadallmaterials}} to see changes.}}}}
{{varcom|np_gr_quality|2|Integer|Enable/disable godrays. Controlled by '''God Rays''' option or '''Enable God Rays''' button (if used [[VGUI]]).
0 - Disabled.
1/2 - Enabled. 1 supposed to enable godrays only for {{ent|newLight_Dir}}, 2 for both point lights and {{ent|newLight_Dir}}, but currently both values enable both types.}}
{{varcom|np_gr_quality_sample_count|3|Integer|Amount of samples for godrays. This affects the quality/detail of the rays. Controlled by '''God Rays''' option, although the original game never changes the value (always 3). Min value is 0, max is 4. The max value is not recommended, it has a huge impact on frame rate, at the same time it does not create a big difference in the game.}}
{{varcom|np_gr_quality_pass_count|1|Integer|Pass count. Not very clear what exactly this affects, but it significantly reduces performance, and Fancy Rays also become pretty buggy. Controlled by '''God Rays''' option, although the original game never changes the value (always 1). Min value is 0, max is 4. Use the default value only.}}
{{varcom|nr_gbuffer_for_reflection_enabled|1|Bool|Enable/disable gbuffer for water reflections.}}
{{varcom|nr_gbuffer_for_refraction_enabled|1|Bool|Enable/disable gbuffer for refractions.}}
{{varcom|nr_gbuffer_for_secondary_cams_enabled|1|Bool|Enable/disable gbuffer for secondary cameras (monitors, etc).}}
{{varcom|nr_gbuffer_for_secondary_cams_quality|-1|Bool|New lights quality in secondary cameras and water reflections. With -1 it will use quality from {{command|nr_lights_quality}} cvar. With 0-5 it will use itown quality settings (in the same way as {{command|nr_lights_quality}}).}}
{{varcom|nr_shadow_filter_quality|2|Integer|Sets shadow filter quality. Min value is 0, max is 3.
0 (POTATO) - Shadow filter disabled.
1 (Medium) - Medium quality.
2 (Hight) - Hight quality.
3 (INSANE) - Best filter quality.
}}
{{varcom|nr_shadow_rad_Low|1.0|Float|Sets shadow filter quality scale for lights with 256 ShadowLOD value.}}
{{varcom|nr_shadow_rad_Med|1.5|Float|Sets shadow filter quality scale for lights with 512 ShadowLOD value.}}
{{varcom|nr_shadow_rad_Hight|1.5|Float|Sets shadow filter quality scale for lights with 1024 ShadowLOD value.}}
{{varcom|nr_shadow_biasoverwrite|0|Bool|Used by [[New Lights Editor]]. Allows/disallows to overwrite bias related values.}}
{{varcom|nr_shadow_nearz_overrite|-1.0|Float|Used by [[New Lights Editor]]. Changes NearZ value for all new lights.}}
{{varcom|nr_shadow_rad_override|0|Bool|Used by [[New Lights Editor]]. Allows/disallows to overwrite shadow radius related values.}}
{{varcom|nr_shadow_fov_overrite|-1|Float|Used by [[New Lights Editor]]. If the value of this convar is higher than -1 it will overrite FOV for shadowed lights.}}
{{varcom|nr_shadow_biasdepth|0.0002|Float|Used by [[New Lights Editor]]. Changes Depth Bias value for all new lights.}}
{{varcom|nr_shadow_biasnormaloffset|1|Float|Used by [[New Lights Editor]]. Changes Normal Bias value for all new lights.}}
{{varcom|nr_shadow_biasslope|0.2|Float|Used by [[New Lights Editor]]. Changes Slope Depth Bias value for all new lights.}}
{{varcom|nr_shadow_active|666|Integer|Sets max active shadowmaps. The value seems hardcoded.}}
{{varcom|nr_debug_print_shadow_slots_info||[[Void]]|Prints text to the console about shadowmap slots and their light sources.
It prints light type (point or spot) with their index, shadowmap enabled state (for each face), shadowmaps number, new light's targetname and position of it.
Below it also prints information about free shadowmap slots for each shadow resolution.
}}
{{varcom|nr_debug_force_shadowmap_res|-1|Bool|Only for debugging. Forces all new lights to use specified shadowmap resolution. -1 means use value from the property.}}
{{varcom|nr_debug_force_dynamic_on_all_stationary_lights|0|Bool|Only for debugging. Forces all stationary new lights to be fully dynamic and update even baked shadows.}}
{{varcom|nr_debug_force_lightstyle|0|Integer|Only for debugging. Forces all new lights to use specified appearance/light style. Possible values are 0-13. 13 for custom style from {{command|nr_debug_force_lightstyle_custom_string}}. 0 means use use value from the property.}}
{{varcom|nr_debug_force_lightstyle_custom_string|1|[[String]]|Only for debugging. Forces all new lights to use custom appearance/light style. Works the same as with lightmapped lights.}}
{{varcom|nr_debug_shadow_render_internal_disable|0|Bool|Only for debugging. Forces all new lights to disable shadowmaps rendering.}}
{{varcom|nr_debug_shadow_print_indices_assignment|0|Bool|Only for debugging. Prints text to the console about all new light sources and shadowmaps after level/save loading.}}
{{varcom|nr_debug_lights_mesh|0|Bool|Only for debugging. Enable/disable new lights mesh.}}
{{varcom|nr_debug_lights_mesh_fullscreen|0|Bool|{{todo|}}}}
{{varcom|nr_debug_light_mesh_volumesize_large|0|Bool|Only for debugging. Enable/disable new lights large mesh volume size mesh.}}
{{varcom|nr_debug_cull_deferred_lights|1|Bool|{{todo|}}}}
{{varcom|nr_debug_cull_deferred_code_lights_via_bsp|1|Bool|{{todo|}}}}
{{varcom|nr_dev_shoot_lights_enabled|0|Bool|Enable/disable point lights on each shoot. Only for player and only for bullet weapons. Shotgun can create several at once. Disappears after save reload.{{warning|Kills performance.}}}}
{{varcom|nr_dev_lights_quality_override|0|Bool|Enable/disable light quality override. Required for some cvars with {{code|nr_dev_}} prefix.}}
{{varcom|nr_dev_gb_debug_type|4|Integer|0 - DepthOnly. 1 - GBuffer_Fast 2 - GBuffer_Fast2. 3 - GBuffer_Fast3. 4 - Gbuffer_Slow.}}
{{varcom|nr_dev_gb_quality|2|Integer|Changes gbuffer quality.}}
{{varcom|nr_dev_lb_quality|1|Integer|0 is broken. 1 - default mode. 2 - debug materials with new specular.}}
{{varcom|nr_disable_setting_auto_reload|0|Bool|{{todo|}}}}
{{varcom|nr_fps_spam|0|Bool|For devolopers only. Spamming in the console performance values. Numbers aren't accurate.}}
{{varcom|nr_light_spot_bbox_optimizie|2|Intenger|Sets BBOX type for spot lights. Min value is 0, max is 3. There are note that 1 is broken. 3 makes BBOX size very small, so spot light sources will disappear even if they are in the player's field of vision.}}
{{varcom|nr_light_spot_mesh_volumesize_large|0|Intenger|This makes BBOX larger than it needs to be.}}
{{varcom|nr_lights_info||Void|Used by the game when you launch it. Prints in the console info about hardware support for texture formats, allocated formats and quality settings.}}
{{varcom|nr_lights_vol_check_threshold|10|Float|{{todo|}}}}
{{varcom|nr_light_settings_transition_exp|2|Integer|Affects the quality of the transition for changes from {{ent|newLights_settings}}. 0 - no transition. 1 - transition. 2 - smooth transition.}}
{{varcom|nr_lights_procedural_disable_all_lights|0|Bool|Disable all proceduraly created new lights ({{ent|npc_zombie_hev}}, {{ent|item_battery}}, weapons, etc).}}
{{varcom|nr_lights_procedural_enable_lights_priority_check|1|Bool|If enabled - all the code based procedural lights will go through priority based check before adding to render queue.}}
{{varcom|r_nr_deffered_debug_normals|0|Bool|Enable/disable normals debug.}}
{{varcom|r_nr_deffered_force_diffuse_only|0|Bool|Forces new lights to use diffuse texture only.}}
{{varcom|r_nr_deffered_lights_hlslclip_range_on|1|Bool|Enable/disable actual new light range in normals debug.}}
{{varcom|r_nr_deffered_lights_hlslclip_dir_on|0|Bool|{{todo|}}}}
{{varcom|r_nr_deferred_AA_fix_multiplier|1|Bool|Fixes anti aliasing issues.
:{{expand|title=Example|
<br>
<br>
<gallery mode=packed heights=410px>
<gallery mode=packed heights=500px>
File:BMSH_1.png| frame | Black Mesa, map bm_c4a1b1. NormalBias - 1.
File:deferred_AA_fix_multiplier0.jpg| thumb | left | 510px | Disabled.
File:BMSH_2.png| frame | Black Mesa, map bm_c4a1b1. NormalBias - 5.
File:deferred_AA_fix_multiplier1.jpg| thumb | left | 510px | Enabled.
</gallery>
<br>
<gallery mode=packed heights=410px>
File:BMOBSH_1.png| frame | Black Mesa: Black Ops - Restored, bmops_map_2. NormalBias - 0.5.
File:BMOBSH_2.png| frame | Black Mesa: Black Ops - Restored, bmops_map_2. NormalBias - 1.5.
</gallery>
====Weapons dynamic light incorrect work with damaged [[func_breakable_surf]]====
For some reason weapons dynamic light can illuminate damaged [[func_breakable_surf]] even if position of it very far from position of damaged [[func_breakable_surf]].
{{ModernConfirm|Is there a way to fix this?}}
<br>
<gallery mode=packed heights=710px>
File:AnSexample.gif| frame |An example.
</gallery>
====New lights don't work with [[3D Skybox]]====
Don't use new lights in your 3D skyboxes, none of them will work at all.
<br>
<gallery mode=packed heights=710px>
File:NLDW3DS.png| frame |An example. We see that deferred lighting and Godrays works fine, but 3D Skybox don't draw both.
</gallery>
====Motion blur blurring viewmodel lighting layer====
For some reason <code>Motion blur</code> blurring viewmodel lighting layer, you can notice this when you just rotate camera.
<br>
<gallery mode=packed heights=510px>
File: VLLBASUalt.gif| frame | An example.
</gallery>
</gallery>
}}
{{varcom|sv_ignite_light_mode|2|Integer|Sets fire light source availability for ignited objects. Min value is 0, max is 3.
0 - Fully disabled.
1 - Available for marines, doesn't work.
2 - Available for all NPCs.
3 - Available for everything, including physics objects and player.
{{bug|Doesn't work with {{ent|env_shooter}}.|hidetested=1}}
}}
}}
{{varcom|end}}
{{note|
* It's not full list.
* Some of these console variables needs save reload for changes.
}}


== See Also ==
==Bugs/Limitations==
See [[/Bugs and limitations]]


* {{ent|light_spot}}
== See also ==
* {{ent|env_lensflare}}
* {{ent|newLight_Dir}} - directional sun light with godrays only.
* {{ent|newLight_Dir}}
* {{ent|NewLights_Spawner}} - spawner of deferred point lights.
* [[Lighting]]
* {{ent|env_lensflare}} - cinematic dynamic lens flare.
* [[Adding Light]]
* {{ent|newLight_Spot}} - spot deferred light entity.
* [[Intermediate Lighting]]
* {{ent|newLights_settings}} - entity that changes deferred light settings.
* [[Advanced Lighting]]
* {{ent|godrays_settings}} - entity that changes godrays settings.
* [[Effect flags]] (dynamic light effects)
* {{ent|env_cascade_light}} - deferred cascade sun light entity.
* [[Tool textures]] (for Block light)
* [[New Lights Editor]] - in game deferred lights editor.
* [https://chetanjags.wordpress.com/2023/07/18/blackmesa-xenengine-part-4-lighting-shadows/ BlackMesa XenEngine: Part 4 – Lighting & Shadows] (page from Black Mesa developer about new lights)
* [[Effect flags]] - effects flags, some of them are dynamic light effects.
{{todo|Investigate and document some keyvalues and functions. Clean up english. Add more issues if you'll find.}}
* [https://chetanjags.wordpress.com/2023/07/18/blackmesa-xenengine-part-4-lighting-shadows/ BlackMesa XenEngine: Part 4 – Lighting & Shadows] - page from Chetan (lead programmer for Black Mesa) about new lights.
* [https://chetanjags.wordpress.com/2023/07/11/blackmesa-xenengine-part2-how-a-frame-is-rendered/ BlackMesa XenEngine: Part2 – How a Frame is Rendered] - page from Chetan (lead programmer for Black Mesa) about how a frame is rendered.
* [https://chetanjags.wordpress.com/2022/06/01/blackmesa-xenengine-part1-a-heavily-modified-source-engine/ BlackMesa XenEngine: Part1 – Heavily Modified Source Engine]  page from Chetan (lead programmer for Black Mesa) about {{xe|4}}.

Latest revision as of 15:36, 10 July 2025

NewLight Point.png

newLight_Point is a point entity available in Black Mesa Black Mesa. It creates an invisible deferred light source that shines in all directions, includes godrays and lightcookies.

C++ Class hierarchy
CNewLightPoint
CBaseEntity
NewLight_Point in End Game chapter (used for the portal).
Note.pngNote:You can have only 512 point light entities placed in the map editor.
Todo: Rework this page.

Keyvalues

Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

Pitch Yaw Roll (Y Z X) (angles) <angle> !FGD
This entity's orientation in the world. Pitch is rotation around the Y axis, yaw is the rotation around the Z axis, roll is the rotation around the X axis.
Note.pngNote:There is almost no differences if you're using point light with no texture. Things changes if you're using textures.


Use old Falloff ? (bUseOldFallOff) <choices> !FGD Obsolete
Deprecated.
Sets old falloff state, disabled or enabled. This feature is disabled in the code, so you can't use old falloff (although it is still used for the flashlight).
  • 0: Disabled
  • 1: Enabled


Light Color (LightColor) <color255>
The RGB color of the light. Colors must be between 0 and 255.
Light Intensity (Intensity) <float>
Intensity/brightness of the light. It's RGB * intensity.
Note.pngNote:With 0 it will make the light disabled, including the effects. Doesn't affect shadows.
Range (Range) <float>
Range of the light, or how far the light source can illuminate. Measured in Hammer Units.
Warning.pngWarning:This is one of the parameters that affects performance in the game. Smaller values ​​allow you to process less geometry and save performance.
Icon-Important.pngImportant:Range is limited, the limit depends on intensity value. Do not use values ​​bigger than the intensity value allows.
Examples
Enabled (Enabled) <choices>
Sets light state on spawn, enabled or disabled.
  • 0: Enabled
  • 1: Disabled
Appearance (style) <integer choices>
Appearance presets.
Lightstyle presets (epilepsy warning)
Literal Value Description Sequence Preview
0 Normal m Lightstyle 0.png
10 Fluorescent flicker mmamammmmammamamaaamammma Lightstyle 10.gif
2 Slow, strong pulse abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba Lightstyle 2.gif
11 Slow pulse, noblack abcdefghijklmnopqrrqponmlkjihgfedcba Lightstyle 11.gif
5 Gentle pulse jklmnopqrstuvwxyzyxwvutsrqponmlkj Lightstyle 5.gif
1 Flicker A mmnmmommommnonmmonqnmmo Lightstyle 1.gif
6 Flicker B nmonqnmomnmomomno Lightstyle 6.gif
3 Candle A mmmmmaaaaammmmmaaaaaabcdefgabcdefg Lightstyle 3.gif
7 Candle B mmmaaaabcdefgmmmmaaaammmaamm Lightstyle 7.gif
8 Candle C mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa Lightstyle 8.gif
4 Fast strobe mamamamamama Lightstyle 4.gif
9 Slow strobe aaaaaaaazzzzzzzz Lightstyle 9.gif
12 Underwater light mutation mmnnmmnnnmmnn Lightstyle 12.gif
Tip.pngTip:Use new lights instead for lights with custom appearance, because static lightmapped lights reduces performance with this feature (especially near displacements).
Note.pngNote:Custom light styles are not possible.
Light Ambient Color (LightColorAmbient) <color255>
The RGB color of the shadows. Colors must be between 0 and 255.
Examples
SpecularMultiplier (SpecMultiplier) <float>
Specular multiplier. Sets intensity of new specular shader from this light source. It's RGB * Intensity * SpecularMultiplier. 0 means disabled.
Examples


falloffConstant (falloffConstant) <integer> !FGD Obsolete
Deprecated.
Constant value (can work only if old falloff is enabled).
falloffLinear (falloffLinear) <integer> !FGD Obsolete
Deprecated.
Linear value (can work only if old falloff is enabled).
falloffQuadratic (falloffQuadratic) <integer> !FGD Obsolete
Deprecated.
Quadratic value (can work only if old falloff is enabled).


Light Type (LightType) <choices>
Type of the light. This affects the behavior of the light source with parent, enable/disable dynamic models in shadowmaps, enable/disable static shadowmaps.
  • 0: Static - used only static shadowmaps, this means that shadows are cast only by static objects (prop_static, geometry, etc). Cannot move with parent.
Icon-Important.pngImportant:Brush entities and bmodels are also included in static shadowmaps and they never update (including func_physbox).
Note.pngNote:Static shadowmaps will update after save reload (only once).
  • 1: Stationary - the same as Static, but with dynamic shadows for dynamic models.
  • 2: Dynamic - lighting don't use static shadowmaps at all. It uses dynamic shadows for static objects and dynamic models. This type also can move with parent. This type is expensive, usually used for moving lights, but also can be used if you're getting issues due to static shadowmaps.
Examples
Note.pngNote:Note that shadow from metal box and grate box are flying on first and second pictures, that's because both was placed in air on map spawn. Doesn't happen on third picture, because the light updated shadow for both.
HasShadow (HasShadow) <choices>
Sets shadows state for the light, enabled or disabled. Remember that the default choices is No.
  • 0: No
  • 1: Yes
Examples
ShadowMapLOD (ShadowLod) <choices>
Resolution of shadowmap used by this light. This affects the quality of the shadows.
  • 0: 256
  • 1: 512
  • 2: 1024
Examples
Icon-Important.pngImportant:You cannot use any value from here an unlimited number of times. More information below.
ShadowRadius (ShadowRadius) <float>
Radius of shadow edges for soft shadows. If its value is negative, code will auto assign a value depending on ShadowLod. These code based values can be adjusted via convars nr_shadow_rad_High, nr_shadow_rad_Med and nr_shadow_rad_Low.
Examples
Tip.pngTip:Don't use very low values, because the shadows will look like stairs. Also don't use very high values, because the noise will spoil them a lot, or you'll see only noise.
NearZ (NearZ) <float>
NearZ used by shadowmap camera for this light. This is the distance at which the light source will start cast shadows.


ShadowFaceX (ShadowFaceX) <choices>
Sets shadow state (enabled or disabled) for X face.
  • 0: Enabled
  • 1: Disabled
ShadowFaceX_Minus (ShadowFaceX_Minus) <choices>
Sets shadow state (enabled or disabled) for -X face.
  • 0: Enabled
  • 1: Disabled
ShadowFaceY (ShadowFaceY) <choices>
Sets shadow state (enabled or disabled) for Y face.
  • 0: Enabled
  • 1: Disabled
ShadowFaceY_Minus (ShadowFaceY_Minus) <choices>
Sets shadow state (enabled or disabled) for -Y face.
  • 0: Enabled
  • 1: Disabled
ShadowFaceZ (ShadowFaceZ) <choices>
Sets shadow state (enabled or disabled) for Z face.
  • 0: Enabled
  • 1: Disabled
ShadowFaceZ_Minus (ShadowFaceZ_Minus) <choices>
Sets shadow state (enabled or disabled) for -Z face.
  • 0: Enabled
  • 1: Disabled


DepthBias (DepthBias) <float>
DepthBias is offset added to depth values in shadowmaps.
Examples


SlopeDepthBias (SlopeDepthBias) <float>
Slope Depth Bias used for surfaces having aliasing due to steep angles with light.
Examples
NormalBias (NormalBias) <float>
While rendering objects into shadowmaps, each vertex will be moved along -ve Normal direction, giving it an appearance of shrinking while rendering to shadowmaps. This property determines the amount of Units to be moved. Helps with shadow aliasing.
Examples
Note.pngNote:You will not see any changes if your material doesn't not provide bumpmap.
Icon-Important.pngImportant:Increasing this value will make shadows between different surfaces less accurate, greate example is third picture in examples, there you can see "two" shadows from railing.
Icon-Bug.pngBug:Numbers lower than 0.8 can cause huge graphics issues. Example.
Tip.pngTip:Increase this value if you are getting aliasing issues like this.


Enable Texture Light (bTexLight) <choices>
Sets lightcookie (texture lights) state, enabled or disabled.
  • 0: Disabled
  • 1: Enabled
Examples
Warning.pngWarning:This is one of the most expensive features, use wisely.
Texture name for TexLight (texName) <string>
Determines which texture will use the light source. Lightcookies are using .vtf (not .vmt) texture from files (just like env_projectedtexture).
.Enable Prop Only Mode (bNegLight) <choices> Obsolete
Deprecated.
Sets prop only mode, which supposed to disable shadows for world geometry. Doesn't work. The same effect can be achieved with shadow pass settings.
  • 0: Disabled
  • 1: Enabled
LightnGodRayMode (LightnGodRayMode) <choices>
This determines what effects will be available to use for the light source. Keep in mind that the default choice is Light.
  • 0: Light - light only.
  • 1: Godrays - godrays only.
  • 2: Both Light and GodRays - both light and godrays.
Icon-Bug.pngBug:Even if godrays is turned off, the game will still think that the godrays is used if choice is Godrays or Both Light and GodRays.


EnableGodRays (EnableGodRays) <choices>
Sets godrays state on spawn, enabled or disabled.
  • 0: Disabled
  • 1: Enabled
Warning.pngWarning:You can have only 40 point lights with godrays enabled simultaneously, otherwise the game will crash with this error message.
The error
Density (Density) <float>
Density controls the length of rays/volumetric shadows. 1.0 should work in 99% cases. Good values are 0.5-1.5.
Examples
Weight (Weight) <float>
Weight controls the intensity of volumetric shadow. Blocking of rays by geometry. Good values are 0.1-10.
Examples
Decay (Decay) <float> Obsolete
Deprecated.
Decay controls luminance fall off per sample. Value here doesn't work.
Exposure (Exposure) <float>
Exposure controls the intensity of rays during blending pass with main scene. 2.0 is a good start. Good values are 1.0-10.0.
Examples


DistFactor (DistFactor) <float>
DistFactor controls the falloff of rays/length. 1.0 is a good starting value increase or decrease in the increments of 0.1. 0.0 will make the rays dissappear only disk will be rendererd.
Examples
Note.pngNote:Godrays doesn't look smooth if used big value here. The same for Exposure.
Example
ColorInner (ColorInner) <color255 + int>
The RGB color and brightness of the inner circle. Colors and brightness must be between 0 and 255.
Icon-Bug.pngBug:This color value doesn't work properly with newLight_Point if you are using Normal godrays type. This entity takes only red value. Works fine with Fancy type.
Examples
Note.pngNote:Rays is disabled on this picture (the colors are partially blending).
ColorRays (ColorRays) <color255 + int>
The RGB color and brightness of the rays. Colors and brightness must be between 0 and 255.
Examples
ColorOuter (ColorOuter) <color255 + int>
The RGB color and brightness of the outer circle. Colors and brightness must be between 0 and 255.
Icon-Bug.pngBug:This color value doesn't work properly with newLight_Point if you are using Normal godrays type. This entity takes only red value. Works fine with Fancy type.
Examples
Note.pngNote:Rays is disabled on this picture (the colors are partially blending).
Note.pngNote:You can't use black colors for ColorOuter, ColorInner and ColorRays.
DiskRadius (DiskRadius) <float>
Radius of disk/circle of sun/point light in texturespace. 1.0 will be full screen, 0.5 is half screen, etc. 0 means don't render.
Examples
DiskInnerSizePercent (DiskInnerSizePercent) <float>
Disk inner circle radius is DiskRadius * DiskInnerSizePercent. 0 means don't render.
Examples
Note.pngNote:Rays is disabled on this picture (for clarity).


GodRaysType (GodRaysType) <choices>
Sets godrays type, normal or fancy.
  • 0: Normal
  • 1: Fancy
Examples
RenderInWorldSpace (m_bEnableWorldSpace) <choices>
Disables disks if this enabled.
  • 0: Disabled
  • 1: Enabled
Confirm:Does it affect anything else ?
Ell_FR_ConstA (Ell_FR_ConstA) <float>
This is fancy godrays disk size.
Examples
Ell_FR_ConstB (Ell_FR_ConstB) <float>
This is fancy godrays disk distortion.
Examples
EEll_SR_ConstA (EEll_SR_ConstA) <float>
This is fancy godrays disk hole size.
Examples
EEll_SR_ConstB (EEll_SR_ConstB) <float>
This is fancy godrays disk hole distortion.
Examples
Ell_RRF_ConstA (Ell_RRF_ConstA) <float>
This is fancy godrays inner size.
Examples


Ell_RRF_ConstB (Ell_RRF_ConstB) <float>
This is fancy godrays inner distortion.
Examples
RotSpeed (RotSpeed) <float>
Rotating speed of fancy godrays, 0 means don't rotate, with negative number it will rotate to left. Examples (link to a video that showcase different values).
RotPatternFreq (RotPatternFreq) <integer>
Count of fancy godrays, with negative number will deny RotSpeed +/- effect. Examples (link to a video that showcase different values).
m_fAlphaDiskInner (m_fAlphaDiskInner) <float> Obsolete
Deprecated.
Alpha inner value for disk. Doesn't work.
m_fAlphaDiskOuter (m_fAlphaDiskOuter) <float> Obsolete
Deprecated.
Alpha outer value for disk. Doesn't work.
UseToneMapRays (m_bUseToneMapRays) <choices> Obsolete
Deprecated.
Sets tonemap state for rays, enabled or disabled. Doesn't work.
  • 0: Enabled
  • 1: Disabled
UseToneMapDisk (m_bUseToneMapDisk) <choices> Obsolete
Deprecated.
Sets tonemap state for disk, enabled or disabled. Doesn't work.
  • 0: Enabled
  • 1: Disabled


ShadowPass_Brush (m_bSRO_Brush) <choices>
Do we want to render world geometry in shadow passes for this light ? Doesn't affect bmodels.
  • 0: YES
  • 1: NO
ShadowPass_StaticProp (m_bSRO_StaticProp) <choices>
Do we want to render prop_static in shadow passes for this light ? This also affect bmodels.
  • 0: YES
  • 1: NO
ShadowPass_DynProp (m_bSRO_DynProp) <choices>
Do we want to render dynamic models in shadow passes for this light ?
  • 0: YES
  • 1: NO
ShadowPass_AlphaTest (m_bSRO__Trans) <choices>
Do we want to render models with transparency materials in shadow passes for this light ? Objects with transparency can cast shadows if your model includes a material without transparency.
  • 0: YES
  • 1: NO

Inputs

SetColorLight <color255RedirectInput/color32>
Change light's color value. Doesn't affect the godrays.
SetIntensityForLight <floatRedirectInput/float>
Change light's intensity value. Doesn't affect the godrays.
TurnOnGodRays <void>
Turn the godrays on.
TurnOffGodRays <void>
Turn the godrays off.
TurnOn <void>
Turn the light on.
TurnOff <void>
Turn the light off.
Toggle <void>
Toggle the light's current state.

Lightcookies

What is a lightcookie texture ?

Lightcookie (a. k. a. "Texture Light") a texture or mask applied to a light source. It is usually used to shape the light's output or fake shadows with specific patterns (which, unlike shadowmaps, can be translucent and look more accurate). It also can be used for stuff like projectors, cautists, disco spheres, etc.

In Black Mesa, it can be used via "Texture name for TexLight (texName)" property (to specify the texture) and "Enable Texture Light (bTexLight)" (to enable the feature).

This game used lightcookies mainly for fake shadowmaps and cautists. They are used for some entities by default (batteries and grunt pods for example).

Lightcookies are disabled with 2 (Low) value for nr_shadow_quality (Dynamic Shadow Quality).

Texture mask

The texture mask defines which pixels will display the lighting and also affects their color. Black pixel color will not render the light at all, white will render the light and its color value, other colors (red, blue, yellow, etc.) will be mixed with the light color value, depending on their intensity and how close they are to white. Alpha channel doesn't affect anything, so make sure you don't use it in your texture.

Point lights requires "Environment Map" texture to work with lightcookies, because point lights are using 6 separate faces, so each face requires separate texture. Follow these steps to create "Environment Map" texture.

Spot lights can use any texture basically.

It is recommended to use No Mipmap and No Level Of Detail flags for your VTF file, so the texture will not cause aliasing issues.

Icon-Important.pngImportant:Lightcookies are not using VMT materials, you only need texture.

Animation

Spot lights also support 2 different animation types, which allow you to animate a texture in two different ways.

Texture Cookie FPS

In this mode, a spot light will split image into specified amount of frames (so called atlases) and change frames with specified speed (FPS).

The splitting of specified texture into separate parts is done using two-dimensional arrays (in this context, this can also be called a two-dimensional table). The value from TexCookieFramesX (TexCookieFramesX) creates the specified number of rows, the value from TexCookieFramesY (TexCookieFramesY) creates the specified number of columns.

The final number of frames is the value from TexCookieFramesX multiplied by TexCookieFramesY. For example, value 3 in both TexCookieFramesX and TexCookieFramesY will split image into 9 parts.

The spot light will change frames from top to bottom and left to right. The frames from the top row are shown first, the spot light passes over them from left to right, then moves down to the next row. If it showed the last frame, it will restart the process. The amount of time it takes to move to the next frame depends on specified value from TexCookieFps (TexCookieFps).

Texture Cookie Scroll Mode

In this mode, lightcookie texture can scroll in X and Y directions. This feature can be enabled with Tex Cookie Scroll Mode (bTexCookieScrollMode) property.

X direction controlled by ScrollSpeedU (fScrollSpeedU) property. Y direction controlled by ScrollSpeedV (fScrollSpeedV) property. Both takes a float value. The default X direction is left, Y is up. Using a value multiplied by -1 will reverse direction, this allows you to use 8 different scroll directions. 0 means don't move in this direction. The size of the value affects the scroll speed.

Here is the video showcase of all 8 directions and how the feature look like.

Note.pngNote:Combing this mode with previous will result in using first atlas frame for scroll mode.

Shadow Mapping

To cast dynamic shadows, Black Mesa uses Wikipedia icon shadow mapping (shadow maps for short) technique for new point and spot light entities when HasShadow property is enabled. Used local shadowmap camera and depth buffer.

Spot light uses only one camera, while point lights 6 for 6 different directions to make more accurate shadows for omnidirectional light, this is why it takes 6 shadowmap slots (see below) and 6 times the cost of new spot light. You can disable each shadowmap individually for a new point light entity.

The shadowmaps stored in a large shadowmap atlas, which makes having lots of shadowmap textures a lot cheaper for GPU. There is two of them, one for static shadowmaps (see below) and one more for dynamic shadowmaps.

Because shadowmap is a texture with limited amount of pixels in it, distance from the light source and objects makes it less accurate a distance.

Shadow FOV, which can be changed with OuterAngle property or ShadowFOV property, also affects shadowmap quality. Due to the pixels spread, shadows are less accurate with large FOV values.

There is 3 shadowmap resolutions, small (256), medium (512) and big (1024). Higher values create sharper, more accurate shadows, but cost much more to render. Sharp shadows may not be appropriate for all situations either, sometimes soft shadows look more accurate. They are defined by ShadowMapLOD property, which uses hard coded choice (0, 1, 2), this is why it's not possible to use custom shadowmap resolutions. Each shadowmap resolution takes one shadowmap slot.

The edges of the shadows can be made smoother (or more stepped) with ShadowRadius property. It determines the radius of shadow edges for soft shadows. If its value is negative, code will auto assign a value depending on ShadowLod. These code based values can be adjusted via convars nr_shadow_rad_High, nr_shadow_rad_Med and nr_shadow_rad_Low.

The NearZ distance used by shadowmap camera (distance at which the light source will start cast shadows) can be controlled with NearZ property. The FarZ distance uses value from Range property.

Console variable nr_shadow_quality sets shadow quality and enable/disable shadows for all or certain objects. Controlled by Dynamic Shadow Quality option. Only 5 values are available for it:

  • 0 (Disabled) - Shadows and lightcookies are completely disabled.
  • 1 (POTATO) - Shadows are available for world geometry and displacements, only for Static and Stationary light types. The shadows are very pixelated. The player's flashlight also gets very simple shadows with "stairs".
  • 2 (Low) - Added brush entities and static props in shadowmaps, only for Static and Stationary light types. Enabled lightcookies.
  • 3 (Medium) - All the shadows are also available for Dynamic light type.
  • 4 (Hight) - Added dynamic models in shadowmaps for Stationary and Dynamic.

Console variable nr_shadow_res affects the quality of shadows. Controlled by Dynamic Shadow Memory option. Only 4 values are available for it:

  • 0 (Hight) - Hight quality.
  • 1 (Medium) - Medium quality.
  • 2 (Low) - Low quality.
  • 3 (POTATO) - Very low quality.
Icon-Bug.pngBug:If there are too many shadowmaps in a frame, this can lead to laggy shadow atlas update.
Todo: How many ?

Shadow filtering

Versions of the game before Necro Patch uses PСF filter. The shadow edges are sharper and exhibit a more distinct transition. There are visible aliasing artifacts, particularly on the edges. Shadows from small or thin objects were also indistinguishable. However, it was pretty good for shadows with low resolution, because they looked blurry. The shadows are somewhat similar to those that can be seen from the projected textures in Portal 2 Portal 2.

The Necro Patch replaced PСF filter with PCSS filter. The shadow edges appear smoother and less jagged. The transition from the shadow to the lit area has more gradient-like softening. Shadows have become more detailed for small objects. Because of this, you have to adjust the shadows more carefully.

This filter has one significant issue: there is now noticeable noise in the shadows. This is mostly noticeable in low resolution shadows, this spoils them quite a lot (although it makes them more detailed). There is no way to disable this effect. The noise also makes the shadows more similar to shadows from flashlight in Half-Life 2 Half-Life 2. It is worth noting that such thing exists in more modern engines (Unreal Engine 5 for example, even though they are not easily visible due to temporal anti-aliasing smoothing the artifact), so you can ignore the noise if it's not very noticeable, especially on shadows with high quality.

The noise is adjusted via ShadowRadius and ShadowMapLOD values, mainly via ShadowRadius; you even can disable the noise with 0 value, but this will make your shadows will look like stairs/pixels.

Note.pngNote:It is not entirely clear which term is correct, PCSS or PCCS, since it could be orgography, but it is possible (though unlikely) that they created their own filter.

Static shadow maps

If our light source remains in the same position and never changes it, we expect that shadows from world geometry, displacement, prop_static and even bmodels (brush entities) are completely static, this means that we don't need to update shadows for them every frame, so it would be nice to bake shadows for all such objects to save performance. This is why we need static shadow maps.

When your light appears, static shadow maps skip all the dynamic models in their pass and take 1-6 pictures of everything mentioned above, then static shadow maps applies to the lighting from the light source and never change again (until save reload).

This doesn't happen if your light source is disabled, so you need to keep it enabled on spawn around 1 second. If you need disabled light source - set intensity value to 0 and then after 1 second turn off light source (don't forget to set required intensity value).

Static shadow maps are used for Static and Stationary light type. For Stationary type, engine also disable shadows passes in dynamic shadows for everything mentioned above, so that the use of static shadow maps makes sense (this still saves performance quite well). Dynamic light type don't use static shadow maps at all, because it can move, so we need to have dynamic shadows for everything.

Important to note that bmodels are also in static shadows maps, including func_physbox, func_door, func_breakable, etc. This is true, despite the fact that such objects can be removed or moved. Most likely this is due to func_detail, which is very similar in principle to regular world geometry, but cannot be removed or moved, unlike all other brush entities. It gives some problems, because shadows from lab doors or elevators will remain static, while these objects are moving. There are 2 good ways to workaround this issue, "lazy" method and " time-consuming" method. The first is very simple and quick, just use Dynamic light type, this will reduce performance but will completely fix the problem and save your time. The second is using Propper with converting your brush to model, you'll need spend time on propper_model setting and brush replacing, but this will also save performance and solve the problem.

Shadow map slots

Shadow map slots is how many lights with shadows you can have per level. There are 3 separate shadow map slots, High (for lights with 1024 value for ShadowMap LOD property), Medium (for lights with 512 value for ShadowMap LOD property) and Low (for lights with 256 value for ShadowMap LOD property).

In High and Medium you can have 48 separate shadow maps, for Low you can have 47 separate shadow maps (143 shadow maps in total).

Each spot light with shadows takes 1 shadow map slot, so you can have 48/47 spot lights with shadows, if they are using the same value for ShadowMap LOD property.

Each point light with shadows takes 6 shadow map slots, because point light uses 6 separate shadow maps to render shadows. This means that you can have 8 point lights with shadows, if they are using the same value for ShadowMap LOD property. You can increase this value if you need, just disable shadows for one of the shadow face properties.

If one of the shadow map slots is full - you will not be able to have shadows for more lights with such shadow quality, you will need to use other value for ShadowMap LOD property.

Point lights and spot lights doesn't counts separately. You can't have 48 spot lights with 8 point lights, but you can have 6 spot lights with 7 point lights.

You can free up shadow map slots with Kill input. So, you can place triggers which will Kill lights that player can't see and spawn new lights via point_template (uncheck the second flag for point_template, this prevents some bugs). This helps a lot when you want to have many dynamic lights in different areas.

Important to note that due to some engine bugs you can't use many lights with shadows. Some tests show that 9th point light cause lights with shadows to be very glitchy. This can be done with spot lights as well. So don't be surprised if at some point you find something like this.

It looks like you can workaround it if you will switch ShadowMap LOD property values from higher to lower.

Tip.pngTip:You can use nr_debug_print_shadow_slots_info to get full info about shadowmap slots.

Shadow map passes per frame

Instead of using the current value from the FPS, shadows use the value from nr_shadow_max_passes_per_frame console variable. It stagger the updation of shadow maps, for both static and dynamic, over a few frames. This feature adjustable via Dynamic Shadow Memory graphics settings. This solution preserves performance, since instead of using 300 from FPS value, the shadow will be updated only 24 times per second, which is enough to display most scenes in dynamic shadows.

Icon-Bug.pngBug:"End Game" chapter crashes at some moment with 29 and higher values.

Shadows behavior with VIS and areaportals

Static type

Static type is the most stable, since its shadows are baked in and updates only with save loads or while lighting turning on. It shows all shadows even with closed areaportal.

Stationary type

Shadows for static props and brushes are baked, but not for physics props and other dynamic models. This means that shadows from dynamic models will disappear if they are hidden by a closed areaportal or if VIS is hiding such objects. Shadows for static props and brushes will not disappear.

In some cases, this can be noticeable if dynamic model creates a large shadow.

With mat_wireframe 1.

Dynamic type

Shadows for static props and world geometry are baked, but not for dynamic models and brushes. This means that shadows from dynamic models and brushes will disappear if they are hidden by a closed areaportal or if VIS is hiding such objects. Shadows for static props and world geometry will not disappear. Moving lighting will update shadows for static props and world geometry, even with closed areaportal.

Player spawn and areaportals

If player spawned in position where areaportal don't hide objects - shadows will be fine. Otherwise, static shadowmap will not see models with bmodels and will bake shadows only for world geometry and displacements. This problem is not relevant only for Dynamic light type. The problem disappears after save reload from proper position.

Shadows behavior with start/end fade dist for prop_static

This mechanic has some issues with static shadowmaps. It seems that there are limitations that don't allow to fix these issues, or this issues was not noticed at the development stage.

Static type

If player spawns in fade radius - shadows will never disappear (until save reload if out of radius).

If player spawns out of radius. - shadows will never appear (until save reload in radius).

The same for props with both Start and End fade dist.

Stationary type

The above mentioned issues are also available for this type.

Appears issue for prop_static with both Start and End fade dist.

If player spawns in Start fade radius - shadows will never disappear (until save reload if out of radius). The same happens if player spawns in End fade radius.

If player spawns out of radius - shadows will appear if you are in End fade radius and disappear if you are in Start fade radius (until save reload in radius). This happens because prop_static actually disappears completely, and creates a separate object as a fading model (this is also why decals disappear if player is out of Start fade radius).

Dynamic type

Dynamic type don't use static shadowmaps at all. This means that there is no problems with fading prop_static at all.

Icon-Important.pngImportant:All the issues are also available for func_lod.

Godrays Implementation

Implementation

Godrays in this game are based on sprite entities. They are a post-processed 2D plane that always turns to player's camera. The size of such plane is consistent with the screen size making it appear larger at a distance, in comparison to the world, similar to how Glow render mode works for env_sprite, but unlike the render mode, such plane is rendered so that the sprite will cut through any surrounding geometry, similar to how Additive render mode works for env_sprite.

This plane is also not affected by VIS, which means that you will always see it, even if your area in which your light source is located is closed by an areoportal.

Such implementation has several consequences that limits amount of cases when you can use it.

Limitations And Use Tips

Local point light godrays can "leak" (example on the pictures), since nothing limits the rendering and the size of the plane. The only you can do is place triggers that will turn on/off godrays, but this also basically means you can't use godrays in multiplayer levels, because multiple players can be located in different places of your map (there is no way to disable godrays for each client separately).

Because godrays always turns to player's camera, make sure you are using this effect in areas where view angle for player is very limited. The reason is showed in this short video clip, note how battery stops processing at some moment.

Note.pngNote:Everything mentioned here also applies to the disks.

Dedicated ConVars

Cvar/Command Parameters or default value Descriptor Effect
nr_allow_hammer_nerfs 0 Integer Allow new lights nerfs via Newlights_gbuffersettings entity.

0 - Disabled.

1 - Allowed.

2 - Enabled/Forced.

nr_allow_hammer_nerfs_4ways 0 Integer Allow Enable4WaysFastPath property from Newlights_gbuffersettings entity.

0 - Disabled.

1 - Allowed.

2 - Enabled/Forced.

nr_shadow_max_passes_per_frame 16 Float Frame per second in shadowmaps. The higher the value, the smoother and faster the shadows from objects can change. The recommended value is 24-28, not higher.
nr_shadow_quality 4 Integer Sets shadow quality and enable/disable shadows for all or certain objects. Controlled by Dynamic Shadow Quality option. Only 5 values are available here.

0 (Disabled) - Shadows and lightcookies are completely disabled.

1 (POTATO) - Shadows are available for world geometry and displacements, only for Static and Stationary light types. The shadows are very pixelated. The player's flashlight also gets very simple shadows with "stairs".

2 (Low) - Added brush entities and static props in shadowmaps, only for Static and Stationary light types. Enabled lightcookies.

3 (Medium) - All the shadows are also available for Dynamic light type.

4 (Hight) - Added dynamic models in shadowmaps for Stationary and Dynamic.

mat_unlock_gfx_highend_unsupported 0 Bool When enabled this convar will unlock extreme graphics options. There will be a significant FPS drop when running game on ULTRA or INSANE configs. Game will consume upto 3 gigs of VRAM when some of the extreme graphics options have been enabled. These high end graphics config options are not officially supported. Don't enable this unless you have at least 3.5 GHZ quad core CPU with GTX 1080. These options are mainly for debugging and modders.
nr_lights_quality 4 Integer Sets lights quality, state (for specific entities), enable/disable effects. Controlled by Dynamic Light Quality option. Only 7 values are available here.

0 (POTATO) - Disabled muzzle flash light (regardless of muzzleflash_light), lighting from batteries (regardless of cl_battery_dlights), light sources from dynlightscript.txt, dynamic lights are also disabled for some other entities. Halflambertion is disabled. New specular is disabled. Bumpmaps are disabled. Lights are disabled completely in secondary cameras (monitors, water, etc). Overlaying on viewmodel looks pretty broken. Light is not smoothed out (most noticeable in the least bright areas).

1 (Low) - Allowed muzzle flash light, lighting from batteries, enabled light sources from dynlightscript.txt, other dynamic lights are also enabled for some other entities. Enabled bumpmaps for models.

2 (Medium) - Enabled bumpmaps for brushes. Lights in secondary cameras, but most effects is disabled.

3 (Hight) - Halflambertion with new specular is enabled. Fixed overlaying on viewmodel. Light is smoothed out.

4 (Very Hight) - Bumpmaps are also uncompressed, this makes lighting on surfaces more detailed.

5 (INSANE) - All the effects is enabled in secondary cameras.

6 (DevOnly) - This one for developers only. Includes uncompressed buffers and 32-bit depth. Don't use if you are general player or modder.

nr_shadow_res 0 Integer Affects the quality of shadows. Controlled by Dynamic Shadow Memory option. Only 4 values are available here.

0 (Hight) - Hight quality.

1 (Medium) - Medium quality.

2 (Low) - Low quality.

3 (POTATO) - Very low quality.

nr_shadow_res_dkvk 0 Integer It doesn't seem to work.
r_4way_minimal_mode_override -1 Integer Enable/disable bumpmaps for Lightmapped_4WayBlend. Since one material of this shader provides 4 bumpmaps at once, disabling them will significantly affect performance.

-1/0 - Enabled. 1/2 - Disabled.

Note.pngNote:This cvar needs mat_reloadallmaterials to see changes.
np_gr_quality 2 Integer Enable/disable godrays. Controlled by God Rays option or Enable God Rays button (if used VGUI).

0 - Disabled.

1/2 - Enabled. 1 supposed to enable godrays only for newLight_Dir, 2 for both point lights and newLight_Dir, but currently both values enable both types.
np_gr_quality_sample_count 3 Integer Amount of samples for godrays. This affects the quality/detail of the rays. Controlled by God Rays option, although the original game never changes the value (always 3). Min value is 0, max is 4. The max value is not recommended, it has a huge impact on frame rate, at the same time it does not create a big difference in the game.
np_gr_quality_pass_count 1 Integer Pass count. Not very clear what exactly this affects, but it significantly reduces performance, and Fancy Rays also become pretty buggy. Controlled by God Rays option, although the original game never changes the value (always 1). Min value is 0, max is 4. Use the default value only.
nr_gbuffer_for_reflection_enabled 1 Bool Enable/disable gbuffer for water reflections.
nr_gbuffer_for_refraction_enabled 1 Bool Enable/disable gbuffer for refractions.
nr_gbuffer_for_secondary_cams_enabled 1 Bool Enable/disable gbuffer for secondary cameras (monitors, etc).
nr_gbuffer_for_secondary_cams_quality -1 Bool New lights quality in secondary cameras and water reflections. With -1 it will use quality from nr_lights_quality cvar. With 0-5 it will use itown quality settings (in the same way as nr_lights_quality).
nr_shadow_filter_quality 2 Integer Sets shadow filter quality. Min value is 0, max is 3.

0 (POTATO) - Shadow filter disabled.

1 (Medium) - Medium quality.

2 (Hight) - Hight quality.

3 (INSANE) - Best filter quality.

nr_shadow_rad_Low 1.0 Float Sets shadow filter quality scale for lights with 256 ShadowLOD value.
nr_shadow_rad_Med 1.5 Float Sets shadow filter quality scale for lights with 512 ShadowLOD value.
nr_shadow_rad_Hight 1.5 Float Sets shadow filter quality scale for lights with 1024 ShadowLOD value.
nr_shadow_biasoverwrite 0 Bool Used by New Lights Editor. Allows/disallows to overwrite bias related values.
nr_shadow_nearz_overrite -1.0 Float Used by New Lights Editor. Changes NearZ value for all new lights.
nr_shadow_rad_override 0 Bool Used by New Lights Editor. Allows/disallows to overwrite shadow radius related values.
nr_shadow_fov_overrite -1 Float Used by New Lights Editor. If the value of this convar is higher than -1 it will overrite FOV for shadowed lights.
nr_shadow_biasdepth 0.0002 Float Used by New Lights Editor. Changes Depth Bias value for all new lights.
nr_shadow_biasnormaloffset 1 Float Used by New Lights Editor. Changes Normal Bias value for all new lights.
nr_shadow_biasslope 0.2 Float Used by New Lights Editor. Changes Slope Depth Bias value for all new lights.
nr_shadow_active 666 Integer Sets max active shadowmaps. The value seems hardcoded.
nr_debug_print_shadow_slots_info Void Prints text to the console about shadowmap slots and their light sources.

It prints light type (point or spot) with their index, shadowmap enabled state (for each face), shadowmaps number, new light's targetname and position of it.

Below it also prints information about free shadowmap slots for each shadow resolution.

nr_debug_force_shadowmap_res -1 Bool Only for debugging. Forces all new lights to use specified shadowmap resolution. -1 means use value from the property.
nr_debug_force_dynamic_on_all_stationary_lights 0 Bool Only for debugging. Forces all stationary new lights to be fully dynamic and update even baked shadows.
nr_debug_force_lightstyle 0 Integer Only for debugging. Forces all new lights to use specified appearance/light style. Possible values are 0-13. 13 for custom style from nr_debug_force_lightstyle_custom_string. 0 means use use value from the property.
nr_debug_force_lightstyle_custom_string 1 String Only for debugging. Forces all new lights to use custom appearance/light style. Works the same as with lightmapped lights.
nr_debug_shadow_render_internal_disable 0 Bool Only for debugging. Forces all new lights to disable shadowmaps rendering.
nr_debug_shadow_print_indices_assignment 0 Bool Only for debugging. Prints text to the console about all new light sources and shadowmaps after level/save loading.
nr_debug_lights_mesh 0 Bool Only for debugging. Enable/disable new lights mesh.
nr_debug_lights_mesh_fullscreen 0 Bool [Todo]
nr_debug_light_mesh_volumesize_large 0 Bool Only for debugging. Enable/disable new lights large mesh volume size mesh.
nr_debug_cull_deferred_lights 1 Bool [Todo]
nr_debug_cull_deferred_code_lights_via_bsp 1 Bool [Todo]
nr_dev_shoot_lights_enabled 0 Bool Enable/disable point lights on each shoot. Only for player and only for bullet weapons. Shotgun can create several at once. Disappears after save reload.
Warning.pngWarning:Kills performance.
nr_dev_lights_quality_override 0 Bool Enable/disable light quality override. Required for some cvars with nr_dev_ prefix.
nr_dev_gb_debug_type 4 Integer 0 - DepthOnly. 1 - GBuffer_Fast 2 - GBuffer_Fast2. 3 - GBuffer_Fast3. 4 - Gbuffer_Slow.
nr_dev_gb_quality 2 Integer Changes gbuffer quality.
nr_dev_lb_quality 1 Integer 0 is broken. 1 - default mode. 2 - debug materials with new specular.
nr_disable_setting_auto_reload 0 Bool [Todo]
nr_fps_spam 0 Bool For devolopers only. Spamming in the console performance values. Numbers aren't accurate.
nr_light_spot_bbox_optimizie 2 Intenger Sets BBOX type for spot lights. Min value is 0, max is 3. There are note that 1 is broken. 3 makes BBOX size very small, so spot light sources will disappear even if they are in the player's field of vision.
nr_light_spot_mesh_volumesize_large 0 Intenger This makes BBOX larger than it needs to be.
nr_lights_info Void Used by the game when you launch it. Prints in the console info about hardware support for texture formats, allocated formats and quality settings.
nr_lights_vol_check_threshold 10 Float [Todo]
nr_light_settings_transition_exp 2 Integer Affects the quality of the transition for changes from newLights_settings. 0 - no transition. 1 - transition. 2 - smooth transition.
nr_lights_procedural_disable_all_lights 0 Bool Disable all proceduraly created new lights (npc_zombie_hev, item_battery, weapons, etc).
nr_lights_procedural_enable_lights_priority_check 1 Bool If enabled - all the code based procedural lights will go through priority based check before adding to render queue.
r_nr_deffered_debug_normals 0 Bool Enable/disable normals debug.
r_nr_deffered_force_diffuse_only 0 Bool Forces new lights to use diffuse texture only.
r_nr_deffered_lights_hlslclip_range_on 1 Bool Enable/disable actual new light range in normals debug.
r_nr_deffered_lights_hlslclip_dir_on 0 Bool [Todo]
r_nr_deferred_AA_fix_multiplier 1 Bool Fixes anti aliasing issues.
Example


sv_ignite_light_mode 2 Integer Sets fire light source availability for ignited objects. Min value is 0, max is 3.

0 - Fully disabled.

1 - Available for marines, doesn't work.

2 - Available for all NPCs.

3 - Available for everything, including physics objects and player.

Icon-Bug.pngBug:Doesn't work with env_shooter.
Note.pngNote:
  • It's not full list.
  • Some of these console variables needs save reload for changes.

Bugs/Limitations

See /Bugs and limitations

See also