This article's documentation is for anything that uses the Source engine. Click here for more information.

Screenspace_General

From Valve Developer Community
Jump to navigation Jump to search
English (en)Translate (Translate)
This article or section is a stub. You can help by expanding it.

Screenspace_General is a Vertex shader available in all Source Source games since Source 2007 Source 2007.[confirm] It is most commonly used to draw generic screenspace effects.

Unlike other shaders using screenspaceeffect as its vertex shader, screenspace_general allows developers to easily access and modify its pixel shader, 4 texture samplers and 4 shader register constants.[Clarify]

This can be useful for quickly iterating and testing screen effects, without having to reload all shaders, or recompile stdshaders to define/modify parameters.

Todo: Document available constants and inputs
Note.pngNote: Garry's Mod Garry's Mod has the Counter-Strike: Global Offensive Counter-Strike: Global Offensive version of this shader.

Notable usage

dev/halo_add_to_screen

Used by the TF2 Glow Effect (2013 SDK) to help create an outline around models using stencils. It uses the haloaddoutline_ps20 pixel shader to apply cheap blur. $C0_X controls the glow fade value (restricted to 1.0f in code.)

Todo: Test if changing $C0_X actually does what it says it is supposed to do.

Parameters

$PIXSHADER <string>
Name of the pixel shader to use. Can be loaded from any directory. In Portal 2 Portal 2 and Counter-Strike: Global Offensive Counter-Strike: Global Offensive, shaders can only be loaded from the platform directory. In Garry's Mod Garry's Mod, they can only be loaded from the mod directory, packed BSP, or a workshop addon.
Note.pngNote: If you intent to draw your shader on DX8, you'll have to add the following code your material file (inside the "screenspace_general" keyvalue.)
"screenspace_general_dx8" { "$PIXSHADER" "YOUR_DX8_PIXSHADER_HERE" }
$VERTEXSHADER <string>
Name of the vertex shader to use. (in all games since Alien Swarm)

Custom shader inputs

$c0_x <float>
$c0_y <float>
$c0_z <float>
$c0_w <float>
$c1_x <float>
$c1_y <float>
$c1_z <float>
$c1_w <float>
$c2_x <float>
$c2_y <float>
$c2_z <float>
$c2_w <float>
$c3_x <float>
$c3_y <float>
$c3_z <float>
$c3_w <float>
$c4_x <float>
(in all games since Alien Swarm)(not in Garry's Mod)
$c4_y <float>
(in all games since Alien Swarm)(not in Garry's Mod)
$c4_z <float>
(in all games since Alien Swarm)(not in Garry's Mod)
$c4_w <float>
(in all games since Alien Swarm)(not in Garry's Mod)
$c5_x <float>
(in all games since Counter-Strike: Global Offensive)(not in Garry's Mod)
$c5_y <float>
(in all games since Counter-Strike: Global Offensive)(not in Garry's Mod)
$c5_z <float>
(in all games since Counter-Strike: Global Offensive)(not in Garry's Mod)
$c5_w <float>
(in all games since Counter-Strike: Global Offensive)(not in Garry's Mod)
$BASETEXTURE <texture>
$TEXTURE1 <texture>
$TEXTURE2 <texture>
$TEXTURE3 <texture>

Other parameters

$DISABLE_COLOR_WRITES <integer>
$ALPHATESTED <float>
$ALPHA_BLEND <integer>
$ALPHA_BLEND_COLOR_OVERLAY <integer>
$LINEARREAD_BASETEXTURE <integer>
$LINEARREAD_TEXTURE1 <integer>
$LINEARREAD_TEXTURE2 <integer>
$LINEARREAD_TEXTURE3 <integer>
$LINEARWRITE <integer>
$COPYALPHA <integer>
$X360APPCHOOSER <integer>
Dictates if vertex color should be used and if they should be transformed from world space. In later games, this is replaced by the usage of $vertexcolor material flag and $vertextransform. (removed since Alien Swarm)
$VERTEXTRANSFORM <integer>
verts are in world space (in all games since Alien Swarm)
$VERTEXNORMAL <integer>
specify vertex normal (compressed) in material format (in all games since Counter-Strike: Global Offensive)
$ALPHABLEND <integer>
whether or not to enable alpha blend (in all games since Alien Swarm)
$MULTIPLYCOLOR <integer>
whether or not to multiply src and dest color (in all games since Alien Swarm)
$WRITEALPHA <integer>
whether or not to enable alpha write (in all games since Alien Swarm)
$WRITEDEPTH <integer>
whether or not to enable depth write (in all games since Alien Swarm)
$TCSIZE0 <integer>
Number of components in texture coord0 (default is 2) (in all games since Alien Swarm)
$TCSIZE1 <integer>
Number of components in texture coord1 (in all games since Alien Swarm)
$TCSIZE2 <integer>
Number of components in texture coord2 (in all games since Alien Swarm)
$TCSIZE3 <integer>
Number of components in texture coord3 (in all games since Alien Swarm)
$TCSIZE4 <integer>
Number of components in texture coord4 (in all games since Alien Swarm)
$TCSIZE5 <integer>
Number of components in texture coord5 (in all games since Alien Swarm)
$TCSIZE6 <integer>
Number of components in texture coord6 (in all games since Alien Swarm)
$TCSIZE7 <integer>
Number of components in texture coord7 (in all games since Alien Swarm)
$POINTSAMPLE_BASETEXTURE <integer>
(in all games since Alien Swarm)(not in Garry's Mod)
$POINTSAMPLE_TEXTURE1 <integer>
(in all games since Alien Swarm)(not in Garry's Mod)
$POINTSAMPLE_TEXTURE2 <integer>
(in all games since Alien Swarm)(not in Garry's Mod)
$POINTSAMPLE_TEXTURE3 <integer>
(in all games since Alien Swarm)(not in Garry's Mod)
$CULL <integer>
Culling control where 0 is nocull, 1 is do cull (in all games since Alien Swarm)
$DEPTHTEST <integer>
Enable Depthtest (in all games since Alien Swarm)
$VIEWPROJMAT <matrix>
(in all games since Counter-Strike: Global Offensive)
$INVVIEWPROJMAT <matrix>
(in all games since Counter-Strike: Global Offensive)
$BlendOpMin <integer>
(in all games since Counter-Strike: Global Offensive)

Tools

An SDK to easily create custom pixel shaders for any Source game is available here: ficool2/sdk_screenspace_shaders.

Note.pngNote: Although not intended. This shader also correctly displays on brushes, overlays, decals, and models (requires $softwareskin 1 and $translucent 1)
Todo: Is this sdk_screenspace_shaders exclusive?