$color_depth
Jump to navigation
Jump to search

Note: Since the
Team Fortress 2 branch outputs
$color_depth is a material shader parameter for the DepthWrite shader available in all
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 uses a magic number 4000 as a divisor. This must be taken into account when creating shaders.
| Engine branch | Formula |
|---|---|
ProjPosZ / ProjPosW
| |
ProjPosW / 4000
|
ProjPosW, it does not work with orthographic projections, as orthographic projections lack perspective distortion.VMT Syntax
DepthWrite { $color_depth 1 }