$color_depth

From Valve Developer Community
Jump to navigation Jump to search
English (en)Translate (Translate)

$color_depth is a material shader parameter for the DepthWrite shader available in all Source Source games. It outputs a color value as depth in the shader. Used in _rt_ResolvedFullFrameDepth as a Depth buffer. It can be useful for Screen Space Ambient Occlusion (SSAO).

Formula

The colored depth output differs between branches. For example Source SDK Base 2013 Source SDK Base 2013 uses a magic number 4000 as a divisor. This must be taken into account when creating shaders.

Engine branch Formula
CS:GO engine branch CS:GO engine branch ProjPosZ / ProjPosW
Team Fortress 2 branch Team Fortress 2 branch ProjPosW / 4000
Note.pngNote: Since the Team Fortress 2 branch Team Fortress 2 branch outputs ProjPosW, it does not work with orthographic projections, as orthographic projections lack perspective distortion.

VMT Syntax

$color_depth <bool>
DepthWrite
{
	$color_depth 1
}