Screenspace General: Difference between revisions
SirYodaJedi (talk | contribs) m (SirYodaJedi moved page Screenspace general to Screenspace General)  | 
				m (Added $BASETEXTURE)  | 
				||
| (13 intermediate revisions by 4 users not shown) | |||
| 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.  | ||
{{todo|Document available constants and inputs}}  | |||
{{note|{{gmod|2}} has the {{csgo|2}} version of this shader.}}  | |||
== Notable usage ==  | == Notable usage ==  | ||
| Line 15: | Line 18: | ||
== Parameters ==  | == Parameters ==  | ||
{{  | {{MatParamDef|$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 only be loaded from the mod directory, packed [[BSP]], or a workshop addon.}}  | ||
{{  | |||
{{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"  | ||
	{  | 	{  | ||
		"$PIXSHADER" "YOUR_DX8_PIXSHADER_HERE"  | 		"$PIXSHADER" "YOUR_DX8_PIXSHADER_HERE"  | ||
	}</nowiki>  | 	}</nowiki>}}  | ||
}}  | }}  | ||
{{MatParamDef|$VERTEXSHADER|string|Name of the vertex shader to use. {{asw|since}}}}  | |||
=== Custom shader inputs ===  | |||
{{MatParamDef|$c0_x|float|}}  | |||
{{MatParamDef|$c0_y|float|}}  | |||
{{MatParamDef|$c0_z|float|}}  | |||
{{MatParamDef|$c0_w|float|}}  | |||
{{MatParamDef|$c1_x|float|}}  | |||
{{MatParamDef|$c1_y|float|}}  | |||
{{MatParamDef|$c1_z|float|}}  | |||
{{MatParamDef|$c1_w|float|}}  | |||
{{MatParamDef|$c2_x|float|}}  | |||
{{MatParamDef|$c2_y|float|}}  | |||
{{MatParamDef|$c2_z|float|}}  | |||
{{MatParamDef|$c2_w|float|}}  | |||
{{MatParamDef|$c3_x|float|}}  | |||
{{MatParamDef|$c3_y|float|}}  | |||
{{MatParamDef|$c3_z|float|}}  | |||
{{MatParamDef|$c3_w|float|}}  | |||
{{MatParamDef|$c4_x|float|{{asw|since}}{{gmod|not}}}}  | |||
{{MatParamDef|$c4_y|float|{{asw|since}}{{gmod|not}}}}  | |||
{{MatParamDef|$c4_z|float|{{asw|since}}{{gmod|not}}}}  | |||
{{MatParamDef|$c4_w|float|{{asw|since}}{{gmod|not}}}}  | |||
{{MatParamDef|$c5_x|float|{{csgo|since}}{{gmod|not}}}}  | |||
{{MatParamDef|$c5_y|float|{{csgo|since}}{{gmod|not}}}}  | |||
{{MatParamDef|$c5_z|float|{{csgo|since}}{{gmod|not}}}}  | |||
{{MatParamDef|$c5_w|float|{{csgo|since}}{{gmod|not}}}}  | |||
{{MatParamDef|$BASETEXTURE|texture|}}  | |||
{{MatParamDef|$TEXTURE1|texture|}}  | |||
{{MatParamDef|$TEXTURE2|texture|}}  | |||
{{MatParamDef|$TEXTURE3|texture|}}  | |||
=== Other parameters ===  | |||
{{MatParamDef|$DISABLE_COLOR_WRITES|integer|}}  | |||
{{MatParamDef|$ALPHATESTED|float|}}  | |||
{{MatParamDef|$ALPHA_BLEND|integer|}}  | |||
{{MatParamDef|$ALPHA_BLEND_COLOR_OVERLAY|integer|}}  | |||
{{MatParamDef|$LINEARREAD_BASETEXTURE|integer|}}  | |||
{{MatParamDef|$LINEARREAD_TEXTURE1|integer|}}  | |||
{{MatParamDef|$LINEARREAD_TEXTURE2|integer|}}  | |||
{{MatParamDef|$LINEARREAD_TEXTURE3|integer|}}  | |||
{{MatParamDef|$LINEARWRITE|integer|}}  | |||
{{MatParamDef|$COPYALPHA|integer|}}  | |||
{{MatParamDef|$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 <code>$vertextransform</code>. {{asw|removed}}}}  | |||
{{MatParamDef|$VERTEXTRANSFORM|integer|verts are in world space {{asw|since}}}}  | |||
{{MatParamDef|$VERTEXNORMAL|integer|specify vertex normal (compressed) in material format {{csgo|since}}}}  | |||
{{MatParamDef|$ALPHABLEND|integer|whether or not to enable alpha blend {{asw|since}}}}  | |||
{{MatParamDef|$MULTIPLYCOLOR|integer|whether or not to multiply src and dest color {{asw|since}}}}  | |||
{{MatParamDef|$WRITEALPHA|integer|whether or not to enable alpha write {{asw|since}}}}  | |||
{{MatParamDef|$WRITEDEPTH|integer|whether or not to enable depth write {{asw|since}}}}  | |||
{{MatParamDef|$TCSIZE0|integer|Number of components in texture coord0 (default is 2) {{asw|since}}}}  | |||
{{MatParamDef|$TCSIZE1|integer|Number of components in texture coord1 {{asw|since}}}}  | |||
{{MatParamDef|$TCSIZE2|integer|Number of components in texture coord2 {{asw|since}}}}  | |||
{{MatParamDef|$TCSIZE3|integer|Number of components in texture coord3 {{asw|since}}}}  | |||
{{MatParamDef|$TCSIZE4|integer|Number of components in texture coord4 {{asw|since}}}}  | |||
{{MatParamDef|$TCSIZE5|integer|Number of components in texture coord5 {{asw|since}}}}  | |||
{{MatParamDef|$TCSIZE6|integer|Number of components in texture coord6 {{asw|since}}}}  | |||
{{MatParamDef|$TCSIZE7|integer|Number of components in texture coord7 {{asw|since}}}}  | |||
{{MatParamDef|$POINTSAMPLE_BASETEXTURE|integer|{{asw|since}}}}  | |||
{{MatParamDef|$POINTSAMPLE_TEXTURE1|integer|{{asw|since}}}}  | |||
{{MatParamDef|$POINTSAMPLE_TEXTURE2|integer|{{asw|since}}}}  | |||
{{MatParamDef|$POINTSAMPLE_TEXTURE3|integer|{{asw|since}}}}  | |||
{{MatParamDef|$CULL|integer|Culling control where 0 is nocull, 1 is do cull {{asw|since}}}}  | |||
{{MatParamDef|$DEPTHTEST|integer|Enable Depthtest {{asw|since}}}}  | |||
{{MatParamDef|$VIEWPROJMAT|matrix|{{csgo|since}}}}  | |||
{{MatParamDef|$INVVIEWPROJMAT|matrix|{{csgo|since}}}}  | |||
{{MatParamDef|$BlendOpMin|integer|{{csgo|since}}}}  | |||
== Tools ==  | == Tools ==  | ||
An SDK to easily create custom pixel shaders for any Source game is available here: [https://github.com/ficool2/sdk_screenspace_shaders ficool2/sdk_screenspace_shaders].  | An SDK to easily create custom pixel shaders for any Source game is available here: [https://github.com/ficool2/sdk_screenspace_shaders ficool2/sdk_screenspace_shaders].  | ||
{{note|Although not intended. This shader also correctly displays on brushes, [[  | {{note|Although not intended. This shader also correctly displays on brushes, [[overlay]]s, [[decal]]s, and models (requires [[$softwareskin]] 1 and [[$translucent]] 1)}}  | ||
{{todo|Is this sdk_screenspace_shaders exclusive?}}  | {{todo|Is this sdk_screenspace_shaders exclusive?}}  | ||
[[Category:Shaders]]  | [[Category:Shaders]]  | ||
Latest revision as of 11:53, 29 August 2025
Screenspace_General  is a   Vertex shader  available in all 
 Source games since 
 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.
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.)
$C0_X actually does what it says it is supposed to do.Parameters
platform directory. In Custom shader inputs
Other parameters
$vertextransform. (removed since Tools
An SDK to easily create custom pixel shaders for any Source game is available here: ficool2/sdk_screenspace_shaders.