Lighting

From Valve Developer Community
Jump to: navigation, search
简体中文

Lighting in Dota 2 is handled via a deferred lighting model and is dynamic. Lighting does not need to be compiled.

env_global_light

Controls overall global light settings in a custom map. Some settings here are global while others can be overridden by the ent_dota_lightinfo entity.

Specular Angle (Y Z X) Controls specular angle (default: 64 283 0)
Specular Power 0 = infinite width falloff, higher values = sharper falloff (default: 14)
FOV This is the field of view that the sunlight casts in. Use lower values for more distant sun and sharper shadows (default: 5)
NearZ Distance This controls the near clipping plane's distance from the player (default: 4)
Texture Name Cloud shadows material (default: ...effects/light_clouds_00)
Enable Shadows Enable/disable shadows
Cloud Scale This is the projected scale size of the clouds (default: 6500)
Cloud 1 Speed Cloud 1 material movement speed (default: 120)
Cloud 1 Direction Cloud 1 material movement direction (default: 0 165 0)
Cloud 2 Speed Cloud 2 material movement speed (default: 80)
Cloud 2 Direction Cloud 2 material movement direction (default: 0 145 0)

ent_dota_lightinfo

Control and blend lighting settings from one localized space to another. Maps contain an env_global_light and env_fog_controller entity and most of their values can be controlled by parallel values in ent_dota_lightinfo entities. This is useful for the light differences when passing between the Radiant and Dire sides of the Dota map and a different lighting look is desired. More than one of these entities can exist in a map and any overlap between the outer radii of two or more will cause an averaged transition to occur between the multiple settings. Inner radii cannot overlap each other.

Color Directional light color
Ambient Rim lighting on objects
Shadow Scale Shadow opacity for any elements using the 'Hero Shader' (Example: heroes, npcs, creeps, etc.)
Shadow Ground Scale Shadow opacity for multiblend and global_lit_simple shaders (Example: Props, terrain, etc.)
Height Fog Not supported in custom maps yet - Misty ground effect opacity (0 is fully transparent, .09 default in dota map)
FoW Darkness Fog of war additive opacity
FoW Color RGB Fog of war color is defined by the weighted average of these separate RGB values (Example: R0 G2 B2)
Skybox Name Not supported yet - Add a localized skybox image
Skybox Tint Not supported yet - Tint the localized skybox image
Inner Radius Inner core radius of the ent_dota_lightinfo (Important! These cannot overlap between any ent_dota_lightinfo entities)
Outer Radius Outer radius of the ent_dota_lightinfo. Once the camera has passed beyond this radius, the lighting will be controlled by neighboring ent_dota_lightinfo entities or by the env_global_light if none are intersecting the current camera position
Tip:If the fog of war in a custom map goes entirely black the camera has exceeded the defined outer radius of the nearby ent_dota_lightinfo" entity. Either make the radius bigger or add a second controller.

env_deferred_light

Creates a small, shadowless light, similar to a point light, that can cast light from its origin. Often used for torches, fires, etc.

Performance Considerations

When adding deferred point lights to custom maps be aware of overlapping a number of them will cause a hit to performance. A good tool to use when evaluating performance is "r_deferred_simple_light 2" which will display a point light's radius in game with some color information. If the color shifts to green as more and more lights overlap then there is a significant amount of overdraw caused by having a number of lights in the same space. Reduce the number of overlapping light radii to reduce overdraw.