Class VolumetricFog
Namespace: ValveResourceFormat.Renderer.SceneEnvironment
Assembly: Renderer.dll
The volumetric fog of a scene, from env_volumetric_fog_controller and its env_volumetric_fog_volumes. Each frame it lights the fog in a grid of the screen and accumulates the light along each ray, for the shaders to read as scatter + color * transmittance.
public sealed class VolumetricFog : IDisposableInheritance
object ← VolumetricFog
Implements
Constructors
VolumetricFog(RendererContext)
Initializes the fog of a scene.
public VolumetricFog(RendererContext rendererContext)Parameters
rendererContext RendererContext
The context to load the fog shader from.
Fields
DefaultGridDepth
Number of slices of the grid, from the camera outwards, of a controller that does not set it.
public const int DefaultGridDepth = 64Field Value
int
GridHeight
Height of the grid in cells.
public const int GridHeight = 160Field Value
int
GridWidth
Width of the grid in cells.
public const int GridWidth = 240Field Value
int
ShadowAtlasSize
Size in texels of the square fog shadow atlas.
public const int ShadowAtlasSize = 2048Field Value
int
ShadowAtlasTiles
Number of tiles along a side of the fog shadow atlas.
public const int ShadowAtlasTiles = 16Field Value
int
ShadowTileSize
Size in texels of the tile a fog light shadow map is rendered into.
public const int ShadowTileSize = 128Field Value
int
ShapeHeight
The falloff shape of a volume that fades from its top and sides.
public const int ShapeHeight = 2Field Value
int
Properties
DepthWarp
Gets the warp of the slice distribution and one over its log2, or zero for slices that grow with the square of their index. With a warp, a slice at s of the grid lies at (warp + 1)^s - 1 over the warp of the way from the first slice to the last.
public Vector2 DepthWarp { get; }Property Value
GridDepth
Gets the number of slices of the grid.
public int GridDepth { get; }Property Value
int
HasController
Gets a value indicating whether the scene has a fog controller.
public bool HasController { get; }Property Value
bool
NearRange
Gets the distance of the first slice from the camera, and the distance from it to the last slice.
public Vector2 NearRange { get; }Property Value
ShadowFaces
Gets the shadow maps picked by the last VolumetricFog.PrepareShadows(Scene, Camera) that are not in the fog shadow atlas yet, to render into it.
public ReadOnlySpan<VolumetricFog.ShadowFace> ShadowFaces { get; }Property Value
ReadOnlySpan<VolumetricFog.ShadowFace>
UsesShadowAtlas
Gets whether the fog has lights with shadow maps of their own, which need the fog shadow atlas.
public bool UsesShadowAtlas { get; }Property Value
bool
Volume
Gets the texture the fog is accumulated into, or null before the first frame.
public RenderTexture? Volume { get; }Property Value
VolumeEntityCount
Gets or sets how many env_volumetric_fog_volume entities the scene has, including disabled ones. A scene with none gets a default volume.
public int VolumeEntityCount { get; set; }Property Value
int
Volumes
Gets the fog volumes of the scene.
public List<VolumetricFog.FogVolume> Volumes { get; }Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()InvalidateShadows()
Makes every shadow map render again. Call it when the atlas the maps were rendered into is created anew.
public void InvalidateShadows()PrepareShadows(Scene, Camera)
Picks the lights of the view and places the shadow maps of the ones the fog shadows, for the next VolumetricFog.Render(Scene, Camera, RenderTexture, RenderTexture?) to use.
public void PrepareShadows(Scene scene, Camera camera)Parameters
scene Scene
The scene whose lights light the fog.
camera Camera
The view the fog is built for.
Render(Scene, Camera, RenderTexture, RenderTexture?)
Lights and accumulates the fog for the view that is bound.
public void Render(Scene scene, Camera camera, RenderTexture shadowDepth, RenderTexture? fogShadowDepth)Parameters
scene Scene
The scene whose lights light the fog.
camera Camera
The view the fog is built for.
shadowDepth RenderTexture
The shadow atlas of the scene's spot lights.
fogShadowDepth RenderTexture?
The atlas the VolumetricFog.ShadowFaces were rendered into, or null if there are none.
SetController(Entity, Vector3)
Takes the fog settings of an env_volumetric_fog_controller.
public void SetController(EntityLump.Entity entity, Vector3 origin)Parameters
entity EntityLump.Entity
The controller's keyvalues.
origin Vector3
The position of the controller, which its box is relative to.

