Revision Difference
Shaders/DepthWrite#565450
<cat>shader</cat>
<title>DepthWrite</title>
<shader>
<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](https://developer.valvesoftware.com/wiki/$treesway) support.
<note>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 <page>Shaders/screenspace_general</page>.</note>
<warning>The shader does not support `$basetexturetranform`, so the depth buffer-based shaders may not match the actual image.</warning>⤶
</description>
<parameters>
<item name="BASETEXTURE" type="ITexture">
Basetexture allows the shader to work with the `.a` channel to create alpha support for depth.
</item>
<item name="COLOR_DEPTH" type="boolean" default="false">
Write depth as color. Allows output of `COLOR0` as `ProjPosW / 4000`. This is what <page>render.GetResolvedFullFrameDepth</page> does.
<note>
To normalize the depth buffer, use this formula: `1 / depth / 4000`.
</note>
</item>
<item name="ALPHATEST" type="boolean" default="false">
Allows you to `clip` in the shader using the `.a` channel of `basetexture`, adding alpha support.
</item>
<item name="ALPHATESTREFERENCE" type="float">
Sets the alpha threshold: `clip( color.a - g_AlphaThreshold );`.
</item>
<item name="NOCULL" type="boolean" default="0">
Culling control - `1` = nocull, `0` = do cull.
</item>
<item name="TREESWAY" type="integer" default="0">
What option to use for the tree swaying effect. Treesway parameters can be found here: [treesway](https://developer.valvesoftware.com/wiki/$treesway).
</item>
</parameters>
</shader>