Revision Difference
Shaders/screenspace_general#563772
<cat>shader</cat>
<title>screenspace_general</title>
<shader>
<description>
This shader is a wrapper for providing custom pixel and vertex shaders, while it is named `screenspace_general` there is nothing inherently `screenspace` only about this shader, it is merely the name that was chosen before it received extra functionality that allowed it to do more than just screenspace work, as such this is a general shader that can be used on brushes, decals, info_overlays, models, and more.
The following content paths are supported: <page text="MOD">File_Search_Paths</page>, <page text="BSP">File_Search_Paths</page>, <page text="THIRDPARTY">File_Search_Paths</page>
Source Engine games use the ``game/shaders/fxc`` (GMod uses the ``garrysmod/shaders/fxc``) folder to load `.vcs` shaders.
<note>
For Linux/Mac users who rely on the ToGL translation layer for their graphics they might run into issues because of lacking SM3.0 support. Running the game through compatibility tools like Proton which make use of DXVK will bypass this issue.
</note>
<note>
If you are trying to make UI shaders, use constant colors, or use textures in UI, and do not want them to be gamma-corrected (see [issue 2807](https://github.com/Facepunch/garrysmod-issues/issues/2807), [issue 2241](https://github.com/Facepunch/garrysmod-requests/issues/2241)), then set `$linearwrite` to 1 (and `linearread_basetexture`/etc in case if you are using textures in your shader).
</note>
## Example of custom pixel shader
<upload src="b5bf8/8dd619600409ef9.png" size="497935" name="pix_shader_example.png" />
## See Also
- [Shader Authoring - Valve Developer Community](https://developer.valvesoftware.com/wiki/Shader_Authoring) for the shader authoring process.
- [SDK Screenspace Shaders - ficool2 GitHub](https://github.com/ficool2/sdk_screenspace_shaders) for more information on screenspace_general.
- [SCell555's Shader Compiler](https://github.com/SCell555/ShaderCompile) for standalone shader compilation which is useful for Linux/Mac users through Wine/Crossover, or for CI/CD processes. If you encounter `SM1 non-float expression`, it means you have to download the original d3dcompiler for Wine via winetricks.
- [Srlions's RDNX library](https://github.com/Srlion/RNDX) a shader example which draws rounded shapes.
- [EthanTheGreat's gm_universe shaders](https://github.com/EthanTheGreat/gm_universe) a shader example which draws planets.
- [EthanTheGreat's gm_shaderbuild utility](https://github.com/EthanTheGreat/gm_shaderbuild) a utility that allows you to hotload shaders for easy development.
</description>
<parameters>
<item name="PIXSHADER" type="string" default="">Your supplied custom pixel shader. Must have `_ps20` postfix at the end. If you want to use SM3.0 pixel shaders you must also pass a SM3.0 vertex shader, otherwise you are limited to SM2.0b.</item>
<item name="VERTEXSHADER" type="string" default="">Your supplied custom vertex shader. Must have `_vs20` or `_vs30` postfix at the end.</item>
<item name="DISABLE_COLOR_WRITES" type="boolean" default="false"></item>
<item name="ALPHATESTED" type="float" default="0"></item>
<item name="ALPHA_BLEND" type="boolean" default="false"></item>
<item name="ALPHA_BLEND_COLOR_OVERLAY" type="boolean" default="false"></item>
<item name="BASETEXTURE" type="ITexture" default="">Texture that will be supplied to your shader.</item>
<item name="TEXTURE1" type="ITexture" default="">Texture that will be available in slot 1 to your shader.</item>
<item name="TEXTURE2" type="ITexture" default="">Texture that will be available in slot 2 to your shader.</item>
<item name="TEXTURE3" type="ITexture" default="">Texture that will be available in slot 3 to your shader.</item>
<item name="LINEARREAD_BASETEXTURE" type="boolean" default="false">Whether to linearly read the textures color or to apply gamma correction.</item>
<item name="LINEARREAD_TEXTURE1" type="boolean" default="false">Whether to linearly read the textures color or to apply gamma correction.</item>
<item name="LINEARREAD_TEXTURE2" type="boolean" default="false">Whether to linearly read the textures color or to apply gamma correction.</item>
<item name="LINEARREAD_TEXTURE3" type="boolean" default="false">Whether to linearly read the textures color or to apply gamma correction.</item>
<item name="LINEARWRITE" type="boolean" default="false">Whether to linearly write the textures color or to apply gamma correction.</item>
<item name="VERTEXTRANSFORM" type="boolean" default="false">Verts are in world space.</item>
<item name="VERTEXNORMAL" type="boolean" default="false">Specify vertex normal (compressed) in material format.</item>
<item name="ALPHABLEND" type="boolean" default="false">Whether or not to enable alpha blend.</item>
<item name="MULTIPLYCOLOR" type="boolean" default="false">Whether or not to multiply src and dest color.</item>
<item name="WRITEALPHA" type="boolean" default="false">Whether or not to enable alpha write.</item>
<item name="WRITEDEPTH" type="boolean" default="false">Whether or not to enable depth write.</item>
<item name="TCSIZE0" type="integer" default="2">Number of components in texture coord0.</item>
<item name="TCSIZE1" type="integer" default="0">Number of components in texture coord1.</item>
<item name="TCSIZE2" type="integer" default="0">Number of components in texture coord2.</item>
<item name="TCSIZE3" type="integer" default="0">Number of components in texture coord3.</item>
<item name="TCSIZE4" type="integer" default="0">Number of components in texture coord4.</item>
<item name="TCSIZE5" type="integer" default="0">Number of components in texture coord5.</item>
<item name="TCSIZE6" type="integer" default="0">Number of components in texture coord6.</item>
<item name="TCSIZE7" type="integer" default="0">Number of components in texture coord7.</item>
<item name="POINTSAMPLE_BASETEXTURE" type="boolean" default="false"></item>
<item name="POINTSAMPLE_TEXTURE1" type="boolean" default="false"></item>
<item name="POINTSAMPLE_TEXTURE2" type="boolean" default="false"></item>
<item name="POINTSAMPLE_TEXTURE3" type="boolean" default="false"></item>
<item name="CULL" type="boolean" default="0">Culling control - `0` = nocull, `1` = do cull.</item>
<item name="DEPTHTEST" type="boolean" default="0">Enable depth test.</item>
<item name="COPYALPHA" type="boolean" default="0"></item>
<item name="VIEWPROJMAT" type="matrix" default="0"></item>
<item name="INVVIEWPROJMAT" type="matrix" default="0"></item>
<item name="BLENDOPMIN" type="integer" default="0"></item>
<item name="X360APPCHOOSER" type="boolean">Setting this to 1 allows to supply mesh colors, and to multiply meshes to view projection. It's recommended to be set to 1.
<removed notag="true">This was a workaround added by Valve for the x360, you should now use $VERTEXCOLOR instead.</removed>
</item>
<item name="VERTEXCOLOR" type="number"></item>
<item name="IGNOREZ" type="boolean" default="false">Whether or not to ignore the ZBuffer.</item>
<item name="fix_fb" type="number" default="32768">⤶
Used to transfer it's value to $flags2. It allows FB texture to show up.⤶
⤶
<note>This is a third party parameter by ficool2's SDK.</note>⤶
</item>⤶
<item name="C0_X" type="float" default="0">Dummy parameter you can utilise for your custom shader.</item>
<item name="C0_Y" type="float" default="0">Dummy parameter you can utilise for your custom shader.</item>
<item name="C0_Z" type="float" default="0">Dummy parameter you can utilise for your custom shader.</item>
<item name="C0_W" type="float" default="0">Dummy parameter you can utilise for your custom shader.</item>
<item name="C1_X" type="float" default="0">Dummy parameter you can utilise for your custom shader.</item>
<item name="C1_Y" type="float" default="0">Dummy parameter you can utilise for your custom shader.</item>
<item name="C1_Z" type="float" default="0">Dummy parameter you can utilise for your custom shader.</item>
<item name="C1_W" type="float" default="0">Dummy parameter you can utilise for your custom shader.</item>
<item name="C2_X" type="float" default="0">Dummy parameter you can utilise for your custom shader.</item>
<item name="C2_Y" type="float" default="0">Dummy parameter you can utilise for your custom shader.</item>
<item name="C2_Z" type="float" default="0">Dummy parameter you can utilise for your custom shader.</item>
<item name="C2_W" type="float" default="0">Dummy parameter you can utilise for your custom shader.</item>
<item name="C3_X" type="float" default="0">Dummy parameter you can utilise for your custom shader.</item>
<item name="C3_Y" type="float" default="0">Dummy parameter you can utilise for your custom shader.</item>
<item name="C3_Z" type="float" default="0">Dummy parameter you can utilise for your custom shader.</item>
<item name="C3_W" type="float" default="0">Dummy parameter you can utilise for your custom shader.</item>
</parameters>
</shader>