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

Screenspace General: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Added X360APPCHOOSER)
(Most of these are ASW)
Line 7: Line 7:


This can be useful for quickly iterating and testing screen effects, without having to reload all shaders, or recompile stdshaders to define/modify parameters.
This can be useful for quickly iterating and testing screen effects, without having to reload all shaders, or recompile stdshaders to define/modify parameters.
{{note|{{gmod|2}} has the {{csgo|2}} version of this shader.}}


== Notable usage ==
== Notable usage ==
Line 15: Line 17:


== Parameters ==
== Parameters ==
{{MatParam|$PIXSHADER|string|Name of the pixel shader to use.
{{MatParam|$PIXSHADER|string|Name of the pixel shader to use. Can be loaded from any directory. In {{portal2|2}} and {{csgo|2}}, shaders can only be loaded from the <code>platform</code> directory. In {{gmod|2}}, they can currently only be loaded from the mod directory or packed [[BSP]].}}
{{note|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.){{CodeBlock|<nowiki> "screenspace_general_dx8"
{{note|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.){{CodeBlock|<nowiki> "screenspace_general_dx8"
{
{
Line 22: Line 24:
}}
}}


{{MatParam|$VERTEXSHADER|string|Name of the vertex shader to use. {{csgo|since}}{{confirm}} }}
{{MatParam|$VERTEXSHADER|string|Name of the vertex shader to use. {{asw|since}}}}


=== Custom shader inputs ===
=== Custom shader inputs ===
Line 41: Line 43:
{{MatParam|$c3_z|float|}}
{{MatParam|$c3_z|float|}}
{{MatParam|$c3_w|float|}}
{{MatParam|$c3_w|float|}}
{{MatParam|$c4_x|float|{{csgo|since}}{{confirm}}}}
{{MatParam|$c4_x|float|{{asw|since}}}}
{{MatParam|$c4_y|float|{{csgo|since}}{{confirm}}}}
{{MatParam|$c4_y|float|{{asw|since}}}}
{{MatParam|$c4_z|float|{{csgo|since}}{{confirm}}}}
{{MatParam|$c4_z|float|{{asw|since}}}}
{{MatParam|$c4_w|float|{{csgo|since}}{{confirm}}}}
{{MatParam|$c4_w|float|{{asw|since}}}}
{{MatParam|$c5_x|float|{{csgo|since}}{{confirm}}}}
{{MatParam|$c5_x|float|{{csgo|since}}}}
{{MatParam|$c5_y|float|{{csgo|since}}{{confirm}}}}
{{MatParam|$c5_y|float|{{csgo|since}}}}
{{MatParam|$c5_z|float|{{csgo|since}}{{confirm}}}}
{{MatParam|$c5_z|float|{{csgo|since}}}}
{{MatParam|$c5_w|float|{{csgo|since}}{{confirm}}}}
{{MatParam|$c5_w|float|{{csgo|since}}}}


{{MatParam|$TEXTURE1|texture|}}
{{MatParam|$TEXTURE1|texture|}}
Line 71: Line 73:
{{MatParam|$X360APPCHOOSER|integer|Dictates if vertex colors should be used. {{confirm}} In later games, this is replaced by the usage of [[$vertexcolor]] material flag. {{csgo|removed}}{{confirm}}}}
{{MatParam|$X360APPCHOOSER|integer|Dictates if vertex colors should be used. {{confirm}} In later games, this is replaced by the usage of [[$vertexcolor]] material flag. {{csgo|removed}}{{confirm}}}}


{{MatParam|$VERTEXTRANSFORM|integer|verts are in world space {{csgo|since}}{{confirm}}}}
{{MatParam|$VERTEXTRANSFORM|integer|verts are in world space {{asw|since}}}}
{{MatParam|$VERTEXNORMAL|integer|specify vertex normal (compressed) in material format {{csgo|since}}{{confirm}}}}
{{MatParam|$VERTEXNORMAL|integer|specify vertex normal (compressed) in material format {{csgo|since}}}}
{{MatParam|$ALPHABLEND|integer|whether or not to enable alpha blend {{csgo|since}}{{confirm}}}}
{{MatParam|$ALPHABLEND|integer|whether or not to enable alpha blend {{asw|since}}}}
{{MatParam|$MULTIPLYCOLOR|integer|whether or not to multiply src and dest color {{csgo|since}}{{confirm}}}}
{{MatParam|$MULTIPLYCOLOR|integer|whether or not to multiply src and dest color {{asw|since}}}}
{{MatParam|$WRITEALPHA|integer|whether or not to enable alpha write {{csgo|since}}{{confirm}}}}
{{MatParam|$WRITEALPHA|integer|whether or not to enable alpha write {{asw|since}}}}
{{MatParam|$WRITEDEPTH|integer|whether or not to enable depth write {{csgo|since}}{{confirm}}}}
{{MatParam|$WRITEDEPTH|integer|whether or not to enable depth write {{asw|since}}}}


{{MatParam|$TCSIZE0|integer|Number of components in texture coord0 (default is 2) {{csgo|since}}{{confirm}}}}
{{MatParam|$TCSIZE0|integer|Number of components in texture coord0 (default is 2) {{asw|since}}}}
{{MatParam|$TCSIZE1|integer|Number of components in texture coord1 {{csgo|since}}{{confirm}}}}
{{MatParam|$TCSIZE1|integer|Number of components in texture coord1 {{asw|since}}}}
{{MatParam|$TCSIZE2|integer|Number of components in texture coord2 {{csgo|since}}{{confirm}}}}
{{MatParam|$TCSIZE2|integer|Number of components in texture coord2 {{asw|since}}}}
{{MatParam|$TCSIZE3|integer|Number of components in texture coord3 {{csgo|since}}{{confirm}}}}
{{MatParam|$TCSIZE3|integer|Number of components in texture coord3 {{asw|since}}}}
{{MatParam|$TCSIZE4|integer|Number of components in texture coord4 {{csgo|since}}{{confirm}}}}
{{MatParam|$TCSIZE4|integer|Number of components in texture coord4 {{asw|since}}}}
{{MatParam|$TCSIZE5|integer|Number of components in texture coord5 {{csgo|since}}{{confirm}}}}
{{MatParam|$TCSIZE5|integer|Number of components in texture coord5 {{asw|since}}}}
{{MatParam|$TCSIZE6|integer|Number of components in texture coord6 {{csgo|since}}{{confirm}}}}
{{MatParam|$TCSIZE6|integer|Number of components in texture coord6 {{asw|since}}}}
{{MatParam|$TCSIZE7|integer|Number of components in texture coord7 {{csgo|since}}{{confirm}}}}
{{MatParam|$TCSIZE7|integer|Number of components in texture coord7 {{asw|since}}}}


{{MatParam|$POINTSAMPLE_BASETEXTURE|integer|{{csgo|since}}{{confirm}}}}
{{MatParam|$POINTSAMPLE_BASETEXTURE|integer|{{asw|since}}}}
{{MatParam|$POINTSAMPLE_TEXTURE1|integer|{{csgo|since}}{{confirm}}}}
{{MatParam|$POINTSAMPLE_TEXTURE1|integer|{{asw|since}}}}
{{MatParam|$POINTSAMPLE_TEXTURE2|integer|{{csgo|since}}{{confirm}}}}
{{MatParam|$POINTSAMPLE_TEXTURE2|integer|{{asw|since}}}}
{{MatParam|$POINTSAMPLE_TEXTURE3|integer|{{csgo|since}}{{confirm}}}}
{{MatParam|$POINTSAMPLE_TEXTURE3|integer|{{asw|since}}}}


{{MatParam|$CULL|integer|Culling control where 0 is nocull, 1 is do cull {{csgo|since}}{{confirm}}}}
{{MatParam|$CULL|integer|Culling control where 0 is nocull, 1 is do cull {{asw|since}}}}
{{MatParam|$DEPTHTEST|integer|Enable Depthtest {{csgo|since}}{{confirm}}}}
{{MatParam|$DEPTHTEST|integer|Enable Depthtest {{asw|since}}}}


{{MatParam|$VIEWPROJMAT|matrix|{{csgo|since}}{{confirm}}}}
{{MatParam|$VIEWPROJMAT|matrix|{{csgo|since}}}}
{{MatParam|$INVVIEWPROJMAT|matrix|{{csgo|since}}{{confirm}}}}
{{MatParam|$INVVIEWPROJMAT|matrix|{{csgo|since}}}}
{{MatParam|$BlendOpMin|integer|{{csgo|since}}{{confirm}}}}
{{MatParam|$BlendOpMin|integer|{{csgo|since}}}}


== Tools ==
== Tools ==

Revision as of 19:56, 9 January 2025

English (en)Translate (Translate)

Stub

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.

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

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

Custom shader inputs

$c0_x $c0_y $c0_z $c0_w $c1_x $c1_y $c1_z $c1_w $c2_x $c2_y $c2_z $c2_w $c3_x $c3_y $c3_z $c3_w $c4_x $c4_y $c4_z $c4_w $c5_x $c5_y $c5_z $c5_w

$TEXTURE1 $TEXTURE2 $TEXTURE3

Other parameters

$DISABLE_COLOR_WRITES

$ALPHATESTED $ALPHA_BLEND $ALPHA_BLEND_COLOR_OVERLAY

$LINEARREAD_BASETEXTURE $LINEARREAD_TEXTURE1 $LINEARREAD_TEXTURE2 $LINEARREAD_TEXTURE3 $LINEARWRITE

$COPYALPHA

$X360APPCHOOSER

$VERTEXTRANSFORM $VERTEXNORMAL $ALPHABLEND $MULTIPLYCOLOR $WRITEALPHA $WRITEDEPTH

$TCSIZE0 $TCSIZE1 $TCSIZE2 $TCSIZE3 $TCSIZE4 $TCSIZE5 $TCSIZE6 $TCSIZE7

$POINTSAMPLE_BASETEXTURE $POINTSAMPLE_TEXTURE1 $POINTSAMPLE_TEXTURE2 $POINTSAMPLE_TEXTURE3

$CULL $DEPTHTEST

$VIEWPROJMAT $INVVIEWPROJMAT $BlendOpMin

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, info_overlays, decals, and models (requires $softwareskin 1 and $translucent 1)
Todo: Is this sdk_screenspace_shaders exclusive?