Revision Difference
Shaders/screenspace_general#563666
<cat>shader</cat>
<title>screenspace_general</title>⤶
<shader>
<description>The shader is a wrapper for providing custom pixel (and in some games vector) shaders.⤶
<bug> Unfortunately (at the moment of 2024-12-22), the only way for Garry's Mod to find and mount custom .VCS shaders, is to provide them in root garrysmod folder, or zip into BSP file. Issue describing this is located [here](https://github.com/Facepunch/garrysmod-requests/issues/2564)</bug>⤶
⤶
This shader can be used on brushes, decals, info_overlays, models, etc.⤶
More detail information about this is listed on [ficool2's screenspace shader sdk](https://github.com/ficool2/sdk_screenspace_shaders)
⤶
Source engine games use ``game/shaders/fxc`` (in gmod case it is ``garrysmod/shaders/fxc``) folder to load .vcs shaders. They can be compiled either via this guide on [valve wiki](https://developer.valvesoftware.com/wiki/Shader_Authoring)
<note>If you are a Linux/Mac user, you can use Wine/Crossover and [SCell555's Shader Compiler](https://github.com/SCell555/ShaderCompile) in order to build your shaders. Keep in mind, that only 2.0b shaders are properly being translated into OpenGL's shaders via ToGL. Some 3.0 shader specifics are available from 2.0b shaders (like screenspace positions) in some specific vendor drivers.⤶
If you encounter ``SM1 non-float expression``, then it means you have to download original d3dcompiler for Wine via winetricks.</note>⤶
⤶
<note>⤶
If you are trying to make UI shaders, or using constant colors, or if you are using 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.⤶
⤶
</description>⤶
<parameters>⤶
<item name="pixshader" type="string">Your supplied custom shader. Must have _ps20 postfix at the end.</item>⤶
⤶
<item name="basetexture" type="ITexture">Texture that will can be supplied to your shader.</item>⤶
<item name="texture1" type="ITexture">Same as ``basetexture``.</item>⤶
<item name="texture2" type="ITexture">Same as ``basetexture``.</item>⤶
<item name="texture3" type="ITexture">Same as ``basetexture``.</item>⤶
⤶
<item name="x360appchoser" 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</item>⤶
<item name="ignorez" type="boolean">Ignores Z buffer if set to 1</item>⤶
<item name="fix_fb" type="number">A custom parameter provided by ficool2's sdk, which is set to 32768. Used to transfer it's value to $flags2. It allows FB texture to show up.</item>⤶
<item name="copyalpha" type="boolean">Overrides pixel shader's alpha to, probably, vertex's alpha.</item>
<item name="alpha_blend_color_overlay" type="boolean"></item>⤶
<item name="alpha_blend" type="boolean"></item>⤶
<item name="linearwrite" type="boolean">Disables gamma-correction on shader's output. If disabled, then gamma-corected output color will be powered to ``1/2.2``.</item>
<item name="linearread_basetexture" type="boolean">If disabled, tries to restore ``gamma-corection`` on texture, by powering it's color to 2.2. If enabled, it reads raw texture's color.</item>
<item name="linearread_texture1" type="boolean">Same as ``linearread_basetexture``</item>⤶
<item name="linearread_texture2" type="boolean">Same as ``linearread_basetexture``</item>⤶
<item name="linearread_texture3" type="boolean">Same as ``linearread_basetexture``</item>⤶
⤶
<item name="c0_x" type="number">This is a dummy parameter which (alongside with ``basetexture``/``texture1``/``2``/``3``) used for supplying custom values to your shader.</item>
<item name="c0_y" type="number">Same as ``c0_x``.</item>⤶
<item name="c0_z" type="number">Same as ``c0_x``.</item>⤶
<item name="c0_w" type="number">Same as ``c0_x``.</item>
⤶
<item name="c1_x" type="number">Same as ``c0_x``.</item>
<item name="c1_y" type="number">Same as ``c0_x``.</item>⤶
<item name="c1_z" type="number">Same as ``c0_x``.</item>⤶
<item name="c1_w" type="number">Same as ``c0_x``.</item>
⤶
<item name="c2_x" type="number">Same as ``c0_x``.</item>
<item name="c2_y" type="number">Same as ``c0_x``.</item>⤶
<item name="c2_z" type="number">Same as ``c0_x``.</item>⤶
<item name="c2_w" type="number">Same as ``c0_x``.</item>⤶
⤶
<item name="c3_x" type="number">Same as ``c0_x``.</item>
<item name="c3_y" type="number">Same as ``c0_x``.</item>
<item name="c3_z" type="number">Same as ``c0_x``.</item>
<item name="c3_w" type="number">Same as ``c0_x``.</item>
</parameters>⤶
⤶
</shader>⤶
⤶
<description>⤶
This shader is a wrapper for providing custom pixel and vertex shaders.⤶
⤶
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>⤶
⤶
This shader can be used on brushes, decals, info_overlays, models, etc.
⤶
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.⤶
</description>⤶
⤶
<parameters>⤶
<item name="pixshader" type="string">Your supplied custom pixel shader. Must have _ps20 postfix at the end.</item>
<item name="vertexshader" type="string">Your supplied custom vertex shader. Must have _vs20 postfix at the end.</item>⤶
⤶
<item name="basetexture" type="ITexture">Texture that will can be supplied to your shader.</item>⤶
<item name="texture1" type="ITexture">Texture that will be available in slot 1 to your shader.</item>
<item name="texture2" type="ITexture">Texture that will be available in slot 2 to your shader.</item>
<item name="texture3" type="ITexture">Texture that will be available in slot 3 to your shader</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>This was a workaround added by valve for the x360, you should now use $VertexColor instead</removed>⤶
⤶
</item>
<item name="VertexColor" type="number">Stub</item>⤶
<item name="ignorez" type="boolean">Ignores Z buffer if set to 1</item>⤶
<item name="fix_fb" type="number">A custom parameter provided by ficool2's SDK, which is set to 32768. Used to transfer it's value to $flags2. It allows FB texture to show up.</item>
<item name="copyalpha" type="boolean">Overrides pixel shader's alpha to, probably, vertex's alpha.</item>
<item name="alpha_blend_color_overlay" type="boolean"></item>⤶
<item name="alpha_blend" type="boolean"></item>⤶
<item name="linearwrite" type="boolean">Disables gamma-correction on shader's output. If disabled, then gamma-corected output color will be powered to ``1/2.2``.</item>
<item name="linearread_basetexture" type="boolean">If disabled, tries to restore ``gamma-corection`` on texture, by powering it's color to 2.2. If enabled, it reads raw texture's color.</item>
<item name="linearread_texture1" type="boolean">Same as ``linearread_basetexture``</item>⤶
<item name="linearread_texture2" type="boolean">Same as ``linearread_basetexture``</item>⤶
<item name="linearread_texture3" type="boolean">Same as ``linearread_basetexture``</item>⤶
⤶
<item name="c0_x" type="number">This is a dummy parameter which (alongside with ``basetexture``/``texture1``/``2``/``3``) used for supplying custom values to your shader.</item>
<item name="c0_y" type="number">Same as ``c0_x``.</item>
<item name="c0_z" type="number">Same as ``c0_x``.</item>
<item name="c0_w" type="number">Same as ``c0_x``.</item>
<item name="c1_x" type="number">Same as ``c0_x``.</item>⤶
<item name="c1_y" type="number">Same as ``c0_x``.</item>⤶
<item name="c1_z" type="number">Same as ``c0_x``.</item>⤶
<item name="c1_w" type="number">Same as ``c0_x``.</item>⤶
⤶
<item name="c2_x" type="number">Same as ``c0_x``.</item>⤶
<item name="c2_y" type="number">Same as ``c0_x``.</item>⤶
<item name="c2_z" type="number">Same as ``c0_x``.</item>⤶
<item name="c2_w" type="number">Same as ``c0_x``.</item>⤶
⤶
<item name="c3_x" type="number">Same as ``c0_x``.</item>⤶
<item name="c3_y" type="number">Same as ``c0_x``.</item>⤶
<item name="c3_z" type="number">Same as ``c0_x``.</item>⤶
<item name="c3_w" type="number">Same as ``c0_x``.</item>⤶
</parameters>⤶
</shader>