newLight_Spot

From Valve Developer Community
Jump to navigation Jump to search
NewLight_Spot in bm_c4a1b (used for the floodlight).
NewLight Dir-Icon-Small.png

newLight_Spot is a point entity available in Black Mesa Black Mesa. It is a cone-shaped, invisible deferred light source, includes lightcookies with animations for them. The animations is based on row and column atlases or scroll mode.

Warning.pngWarning:New lights use expensive gbuffer, that means that with this entity your scene rendering at least 5 times, which makes your level very expensive, considering that XenEngine uses 32-bit architecture and DirectX 9.5 rendering. In large quantities, new lights can greatly heat up your computer and also cause large FPS drops (depending on difficulty of your map and how your area open). Use wisely.
Note.pngNote:You can have only 256 spot light entities placed in the map editor.
Black Mesa Level Creation

Represented by class CNewLightSpot.

Todo: Update issues, rework page.

Keyvalues

Name (targetname) <string>
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

ReverseDir (ReverseDir) <choices>
By default, the Y angle for a spot light is inverted, which causes the light to point upward when pointed downwards. This option allows you to fix this problem.
  • 0: No
  • 1: Yes
Icon-Important.pngImportant:This additionally impacts performance, use it in rare cases (for moving with NPC flashlight, etc), It is much better to invert required Y angle value (make it from 90 to -90 for example).
Examples
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.
Note.pngNote:Shadows from objects that are at a great distance look noticeably worse than shadows from objects that are near to the light source.
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 (FlareStyle) <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).
Confirm:Is it possible to have your own light styles (the property are using integer values) ?
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).
OuterAngle (phi) <float>
Outer angle for spot light.
Warning.pngWarning:This affect shadow quality, less is better.
Icon-Important.pngImportant:Don't use values 180 and higher, this will make shadows and lighting broken.
InnerAngle (theta) <float>
Inner angle value for spot light.
Warning.pngWarning:Using values higher than in OuterAngle will not make ShadowFOV value higher. This will result in broken shadows.
AngularFallOff (angularFallOff) <float>
Angular falloff value.
Examples
Note.pngNote:Results depend on values of OuterAngle and InnerAngle.
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.
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.
ShadowFOV (ShadowFOV) <float>
Fov used by shadowmap camera for this light. Keep it 0 to use Outer angle as the fov.
Icon-Bug.pngBug:If value lower than OuterAngle value, the lights will have visual issues.
Example
Enable Texture Light (bTexLight) <choices>
Sets lightcookie (texture lights) state, enabled or disabled. For NewLight_Point, you need static cubemap texture. For NewLight_Spot, you can use any texture with No Mipmap and No Level Of Detail flags.
  • 0: Disabled
  • 1: Enabled
Examples
Tip.pngTip:Follow these steps to create your own lightcookie texture for point light.
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>
Enable Prop Only Mode.
  • 0: Disabled
  • 1: Enabled
Confirm:Deprecated.
TexCookieFramesX (TexCookieFramesX) <integer>
Number of frames in 1 row of atlas.
Note.pngNote:If value lower than 1 - you'll get message in the developer console:

TexCookieFramesX for LightSpot - class C_NewLightSpot CookieName - TEXTURENAME.vtf is 0. Are you sure this light is using texcookie? If yes then set this property to at least 1.

TexCookieFramesY (TexCookieFramesY) <integer>
Number of frames in 1 column of atlas. Also sets scale for texture, with 2 and higher it allows TexCookieFps to animate texture.
Note.pngNote:If value lower than 1 - you'll get message in the developer console:

TexCookieFramesY for LightSpot - class C_NewLightSpot CookieName - TEXTURENAME.vtf is 0. Are you sure this light is using texcookie? If yes then set this property to at least 1.

Examples
TexCookieFps (TexCookieFps) <float>
Frame rate for animation. This entity divides texture into several parts (their count is indicated in TexCookieFramesY) and changes them in a specific sequence.
Tex Cookie Scroll Mode (bTexCookieScrollMode) <choices>
Sets texture scrolling function state, enabled or disabled. ScrollSpeedU and ScrollSpeedV sets scrolling speed and direction.
  • 0: Disabled
  • 1: Enabled
ScrollSpeedU (fScrollSpeedU) <float>
Scrolling speed along Y axis.
Examples
ScrollSpeedV (fScrollSpeedV) <float>
Scrolling speed along X axis.
Examples
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 <color255>
Change Light's Color value. Doesnt effect the godrays
SetIntensityForLight <float>
Change Light's intensity value. Doesnt effect the godrays
TurnOn <void>
Turn the light on.
TurnOff <void>
Turn the light off.
Toggle <void>
Toggle the light's current state.
InputFixRotBugDueToTram <void>
InputFixRotBugDueToTram

Lighting 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.

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.

Bugs/Limitations

Deferred lighting incorrect work with $translucent

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.


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.

Same will happen if you use overlays/decals on brushes with $translucent.

This issues does not happen if replace LightmappedGeneric to ShatteredGlass or UnlitGeneric, so, you can use one of them for glass or transparency surfaces when it's needed.

In some cases use $alphatest if it'll give similar to $translucent resualts, with this your surface also will cast dynamic shadows.


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. For examples used this texture with this alpha channel.

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.

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.

If use very low numbers you will see resualts like in the pictures.


You can't escape this problem, only minimize effect with $alphatestreference 0.1 or if paint alpha correct channel.


Weird clipping

Often meeting strange clipping/flickering, strange bug that was in early stages of the game (this can be seen even in videos before new lights release in public), this does not depend on OS or drivers. Somehow related to Range value, since changing its value halfway fixes this bug, because it move away the bugged area.


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.



Spot lights have sharpness bug if shadows enabled

It is most noticeable if spot light is at not a right angle. It greatly degrades quality of shadows. Issue can be partially fixed if make NormalBias value bigger. Also can be minimized with shadow quality, range, outer and inner angles.


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 tools/toolsblack or any Shader-ball.png UnlitGeneric texture.


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 Level Fade In to hide this problem, this setting also will hide some other problems with loads that avaible inBlack Mesa Black Mesa.


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.This happen because shadows use passes per frame for memory, if level use a lot of new lights - game change integer value of cvar nr_shadow_max_passes_per_frame to lower numbers. Can be fixed if change cvar value with point_servercommand to 25 or 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.


Dynamic lights with shadows may buggy

In some cases your attached lights may have buggy shadows if parent is moving, work smart when use this feature. If your moving light is decoration - highly recommended to leave shadows disabled to save limits and performance.


Moving newLight_Spot clipping if shadows enabled

Even with low speed, newLight_Spot clipping when rotating, but only if shadows enabled. With pause this bug get fix.


Viewmodel illuminated by deferred render draw in refract shader

Refract shader and 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.


Objects with refract shader self refract if illuminated by deferred render

Objects with refract shader in their own refraction disable self, to escape some problems. However - objects with refract shader illuminated by deferred render refract self because of game can't tell the depth of objects because of the transparency, what you are see in the pictures is just the lighting layer applied to the color of transparency texture.

Similar issue happen if model with refraction behind wall with refraction.


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.


Godrays and deferred lighting incorrect work with cloak

Cloak is a material shader parameter for VertexLitGeneric shader, female assassins use it to make them transparent when they need it. Godrays all time fully render through them, same for deferred lighting.


Strange "holes" when player's camera is at a great distance

In some cases may will appear strange "holes" when player's camera is at a great distance. Strange bug that occurs quite rarely. It is affected by game resolution, for example in bm_c4a1b1 this bug shows up well with a resolution wtih 1920x1080, but with 3840x2160 the light source from the teleporter flickers, but does not form a hole. Can be fixed if increase NormalBias number.

Confirm:Does it happen with newLight_Spot ?





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.

Confirm:Is there a way to fix this?



New lights don't work with 3D Skybox

Don't use new lights in your 3D skyboxes, none of them will work at all.


Motion blur blurring viewmodel lighting layer

For some reason Motion blur blurring viewmodel lighting layer, you can notice this when you just rotate camera.


Deferred lighting incorrect work with Customize Character window

For some reason Customize Character take player's screen, inserts it into character preview window and show one of deferred lighting layers.


Deferred lighting does not draw with -tools

If you don't use Full Screen - deferred lighting will not draw.



Deferred lighting that use shadows disappear after materials reload

This issue happen when you open Hammer while game is opened, when you disable speculars with mat_specular 0, when you reload all matelias with mat_reloadallmaterials, e. t. c. Can be fixed with save reload.


See also