Env fog controller: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (update & clean up)
Line 10: Line 10:
Note that [[3D Skybox]] fog levels set by the [[sky_camera]] parameters should correspond to your [[env_fog_controller]] settings.
Note that [[3D Skybox]] fog levels set by the [[sky_camera]] parameters should correspond to your [[env_fog_controller]] settings.
{{clr}}
{{clr}}
{{tip|By adding fog to a level, you can hide a far clip plane, and reduce the amount of rendered geometry, improving game performance.}}
{{tip|By adding fog to a level, you can hide a '''FarZ''' Clip Plane, and reduce the amount of rendered geometry, improving game performance.}}


Adding fog (to represent haze, mist, diffuse smoke or dust) to the atmosphere has important implications for 'realistic' [[Lighting]]. Light is scattered and absorbed as it passes through fog. The denser the fog, the greater the effect.  
Adding fog (to represent haze, mist, diffuse smoke or dust) to the atmosphere has important implications for 'realistic' [[Lighting]]. Light is scattered and absorbed as it passes through fog. The denser the fog, the greater the effect.  
Line 20: Line 20:


* [[Fog tutorial]]
* [[Fog tutorial]]
* [[Fog Basics]]
* [[Dust, Fog, & Smoke]]
* [[Dust, Fog, & Smoke]]


==Keyvalues==
==Keyvalues==


* {{kv targetname}}
;* fogenable {{boolean}}
: Enable fog on map load.
 
;* fogstart <float>
: How far from the viewer the fog should start.
 
;* fogend <float>
: How far from the viewer the scene should be completely fogged.
 
;* fogmaxdensity <float>
: Fog Max Density [0..1]
 
;* farz <integer>
: This setting is used for optimizing your map. Anything beyond this distance (in world units) will not be rendered. It is recommended to keep this number higher then your ''fogend'' value and ensure fogmaxdensity is set to 1.
 
;* fogcolor {{color}}
: Primary Fog Color.
 
;* fogblend {{boolean}}
: This will enable blending between two fogcolor and fogcolor2, based on the direction the player is looking. If the player's viewpoint is equal to the ''fogdir'' vector, the fog will be drawn with the fogcolor2 (eg red); if facing in the complete opposite direction, the fog will be drawn with the fogcolor (eg blue). If facing perpendicular to the fogblend axis, the fog will be a 50/50 blend of fogcolor and fogcolor2 (eg purple).
: This can be used to approximate the effect of light diffusing through the fog, but since the fogblend effect is applied for the entire rendered scene, it is best to keep the two colors relatively close to make the blending less obvious.
: For example, sunlight with a Yaw of 45 degrees and a Pitch of -45 degrees could be enhanced using a '''fogdir''' of '-1 -1 1', a '''fogcolor''' of '120 110 100' and a '''fogcolor2''' of '80 70 60'.
 
;* fogcolor2 {{color}}
: Secondary Fog Color.
 
;* fogdir
: <vector> A vector (given by three space-separated numbers X Y Z) which points from the secondary fog color '''fogcolor2''' towards the primary fog color '''fogcolor'''.
 
;* use_angles {{boolean}}
: Use ''angles'' instead of ''fogdir'' for the fogblend-axis.
 
* {{kv angles}}
* {{kv angles}}
;* {{ep1 add|foglerptime}} <float>
: Interpolate time
* {{kv dxlevelchoice}}
* {{kv dxlevelchoice}}
* '''fogcolor'''
* {{kv targetname}}
: {{color}}
 
* '''fogcolor2'''
==Flags==
: {{color}}
 
* '''fogdir'''
* 1 : Master (Has priority if multiple env_fog_controllers exist)
: <vector> A vector (given by three space-separated numbers X Y Z) which points from the secondary fog color '''fogcolor2''' towards the primary fog color '''fogcolor'''.
* '''fogstart'''
: <float> How far from the point-of-view the fog should start.
* '''fogend'''
: <float> How far from the point-of-view the view should be completely fogged.
* '''farz'''
: <integer> This is the distance from the point-of-view that the level geometry should stop being drawn at. This can be used to control engine performance.
* '''fogenable'''
: {{boolean}}
* '''fogblend'''
: {{boolean}} This will enable blending between two fog colors, based on the direction the player is looking. If the player's viewpoint is equal to the ''fogdir'' vector, the fog will be drawn with the secondary color; if facing in the complete opposite direction, the fog will be drawn with the primary color.
: This can be used to approximate the aesthetic effect of diffuse light filtering through the fog, but since the fog effect color is changed for the entire rendered scene, it is best to keep the two colors relatively close to make the blending less obvious.
: For example, sunlight with a yaw of 45 degrees and a pitch of -45 degrees could be enhanced using a '''fogdir''' of '-1 -1 1', a '''fogcolor''' of '120 110 100' and a '''fogcolor2''' of '80 70 60'.
* '''use_angles'''
: {{boolean}}
* '''{{ep1 add|foglerptime}}
: <float> Interpolate time


==Inputs==
==Inputs==
* {{i targetname}}
 
* '''SetStartDist <float>'''
;* SetStartDist <float>
: Set the fog start distance.
: Set the fog start distance.
* '''SetEndDist <float>'''
 
;* SetEndDist <float>
: Set the fog end distance.
: Set the fog end distance.
* '''TurnOn'''
 
;* TurnOn
: Turn the fog on.
: Turn the fog on.
* '''TurnOff'''
 
;* TurnOff
: Turn the fog off.
: Turn the fog off.
* '''SetColor {{color}}
 
;* SetColor {{color}}
: Set the primary fog color.
: Set the primary fog color.
* '''SetColorSecondary {{color}}
 
;* SetColorSecondary {{color}}
: Set the secondary fog color.
: Set the secondary fog color.
* '''SetFarZ <integer>'''
 
;* SetFarZ <integer>
: Set the far clip plane distance.
: Set the far clip plane distance.
* '''SetAngles <[[QAngle|angles]]>'''
 
;* SetAngles <[[QAngle|angles]]>
: Set the angles to use for the secondary fog direction.
: Set the angles to use for the secondary fog direction.
* '''{{ep1 add|SetColorLerpTo <color255>}}'''
 
;* {{ep1 add|SetColorLerpTo <color255>}}
: Set the primary fog color.
: Set the primary fog color.
* '''{{ep1 add|SetColorSecondaryLerpTo <color255>}}'''
 
;* {{ep1 add|SetColorSecondaryLerpTo <color255>}}
: Set the secondary fog color.
: Set the secondary fog color.
* '''{{ep1 add|SetStartDistLerpTo <float>}}'''
 
;* {{ep1 add|SetStartDistLerpTo <float>}}
: Set the fog start distance.
: Set the fog start distance.
* '''{{ep1 add|SetEndDistLerpTo <float>}}'''
 
;* {{ep1 add|SetEndDistLerpTo <float>}}
: Set the fog end distance.
: Set the fog end distance.
* '''{{ep1 add|StartFogTransition}}'''
 
;* {{ep1 add|StartFogTransition}}
: Start fog transition.
: Start fog transition.
* {{i targetname}}


==Outputs==
==Outputs==
* {{o targetname}}
* {{o targetname}}

Revision as of 16:29, 15 April 2008

Template:Wrongtitle Template:Base point

Entity Description

Fog controller.png

The env_fog_controller entity determines the density of aerial fog for the whole map.

Template:Map properties Only the first instance of the env_fog_controller entity in a level will be used. It is pointless to place multiple env_fog_controller entities in a map!.

Note that 3D Skybox fog levels set by the sky_camera parameters should correspond to your env_fog_controller settings.

Tip.pngTip:By adding fog to a level, you can hide a FarZ Clip Plane, and reduce the amount of rendered geometry, improving game performance.

Adding fog (to represent haze, mist, diffuse smoke or dust) to the atmosphere has important implications for 'realistic' Lighting. Light is scattered and absorbed as it passes through fog. The denser the fog, the greater the effect.

  • Falloff - (or attenuation) is the rate at which light intensity decreases over distance. Falloff distance decreases as fog gets thicker.
  • Tyndall Effects - can be seen when the fog particles reflect light toward the viewer. Halos and Lightbeams become more visible as fog gets thicker.
  • Diffused Lighting - the boundary-line between light and shadow becomes more blurred (diffuse) as fog gets thicker. See Lightmap Scale and shadow_control's "distance" parameter.

See Also

Keyvalues

Enable fog on map load.
  • fogstart <float>
How far from the viewer the fog should start.
  • fogend <float>
How far from the viewer the scene should be completely fogged.
  • fogmaxdensity <float>
Fog Max Density [0..1]
  • farz <integer>
This setting is used for optimizing your map. Anything beyond this distance (in world units) will not be rendered. It is recommended to keep this number higher then your fogend value and ensure fogmaxdensity is set to 1.
  • fogcolor #000000
Primary Fog Color.
This will enable blending between two fogcolor and fogcolor2, based on the direction the player is looking. If the player's viewpoint is equal to the fogdir vector, the fog will be drawn with the fogcolor2 (eg red); if facing in the complete opposite direction, the fog will be drawn with the fogcolor (eg blue). If facing perpendicular to the fogblend axis, the fog will be a 50/50 blend of fogcolor and fogcolor2 (eg purple).
This can be used to approximate the effect of light diffusing through the fog, but since the fogblend effect is applied for the entire rendered scene, it is best to keep the two colors relatively close to make the blending less obvious.
For example, sunlight with a Yaw of 45 degrees and a Pitch of -45 degrees could be enhanced using a fogdir of '-1 -1 1', a fogcolor of '120 110 100' and a fogcolor2 of '80 70 60'.
  • fogcolor2 #000000
Secondary Fog Color.
  • fogdir
<vector> A vector (given by three space-separated numbers X Y Z) which points from the secondary fog color fogcolor2 towards the primary fog color fogcolor.
Use angles instead of fogdir for the fogblend-axis.
Interpolate time

Flags

  • 1 : Master (Has priority if multiple env_fog_controllers exist)

Inputs

  • SetStartDist <float>
Set the fog start distance.
  • SetEndDist <float>
Set the fog end distance.
  • TurnOn
Turn the fog on.
  • TurnOff
Turn the fog off.
  • SetColor #000000
Set the primary fog color.
  • SetColorSecondary #000000
Set the secondary fog color.
  • SetFarZ <integer>
Set the far clip plane distance.
Set the angles to use for the secondary fog direction.
Set the primary fog color.
Set the secondary fog color.
Set the fog start distance.
Set the fog end distance.
Start fog transition.

Outputs