Garry's Mod Wiki

DepthWrite

Description

This is a shader for depth write. It can either write all the depth from the scene at once or render models one by one, but with alpha support. It also has treesway support.

This shader outputs Depth based on ProjPos.W, so it's only suitable for Perspective cameras. It won't work with Orthographic projection (shadow maps), since ProjPos.W for Orthographic is always equal to 1. In this case, you'll need to create your own shader analogous to DepthWrite that outputs ProjPos.Z using Shaders/screenspace_general.

Parameters

ITexture BASETEXTURE
Basetexture allows the shader to work with the .a channel to create alpha support for depth.
boolean COLOR_DEPTH
Write depth as color. Allows output of COLOR0 as ProjPosW / 4000. This is what render.GetResolvedFullFrameDepth does.
To normalize the depth buffer, use this formula: 1 / depth / 4000.

Default: false

boolean ALPHATEST
Allows you to clip in the shader using the .a channel of basetexture, adding alpha support.

Default: false

float ALPHATESTREFERENCE
Sets the alpha threshold: clip( color.a - g_AlphaThreshold );.
boolean NOCULL
Culling control - 1 = nocull, 0 = do cull.

Default: 0

integer TREESWAY
What option to use for the tree swaying effect. Treesway parameters can be found here: treesway.

Default: 0