$npx -y skills add tebjan/vvvv-skills --skill vvvv-shadersHelps write SDSL shaders for Stride and vvvv gamma — TextureFX, shader mixins, compute shaders, and ShaderFX composition. SDSL is a superset of HLSL, so use this skill when writing or debugging .sdsl shader files, GPU shaders, visual effects, HLSL code for vvvv, working with the
| 1 | # SDSL Shaders for vvvv gamma / Stride |
| 2 | |
| 3 | ## What Is SDSL |
| 4 | |
| 5 | SDSL (Stride Shading Language) is Stride's shader language — a superset of HLSL with four key additions: `shader` classes with inheritance, multiple inheritance (mixins), the `streams` system for automatic inter-stage data flow, and `override` for clean method replacement. Shaders are defined in `.sdsl` files. |
| 6 | |
| 7 | ## Streams System |
| 8 | |
| 9 | Streams replace manual VS_INPUT/VS_OUTPUT structs. Declare once, access everywhere: |
| 10 | |
| 11 | ```hlsl |
| 12 | stream float4 MyData : TEXCOORD5; // Declare a custom stream variable |
| 13 | |
| 14 | // In vertex shader: |
| 15 | streams.MyData = float4(1, 0, 0, 1); // Write |
| 16 | |
| 17 | // In pixel shader: |
| 18 | float4 d = streams.MyData; // Read (auto-interpolated) |
| 19 | ``` |
| 20 | |
| 21 | Key built-in streams: |
| 22 | - `streams.ShadingPosition` (SV_Position) — clip-space position |
| 23 | - `streams.ColorTarget` (SV_Target0) — pixel shader output |
| 24 | - `streams.Position` (float4) — object-space position |
| 25 | - `streams.TexCoord` (TEXCOORD0) — texture coordinates |
| 26 | - `streams.normalWS` — world-space normal |
| 27 | |
| 28 | ## Base Shader Hierarchy |
| 29 | |
| 30 | ### Stride Core (available in both Stride and vvvv) |
| 31 | |
| 32 | | Shader | Provides | |
| 33 | |---|---| |
| 34 | | `ShaderBase` | VSMain/PSMain entry points | |
| 35 | | `Texturing` | Texture0-9, Sampler, PointSampler, LinearSampler, TexCoord | |
| 36 | | `Transformation` | World, View, Projection, WorldViewProjection matrices | |
| 37 | | `PositionStream4` | Position, PositionWS, DepthVS | |
| 38 | | `NormalStream` | meshNormal, normalWS, tangentToWorld | |
| 39 | | `ComputeShaderBase` | CSMain entry, Compute() hook, thread groups | |
| 40 | | `ComputeColor` | Interface returning float4 via Compute() | |
| 41 | | `ComputeVoid` | Interface returning void via Compute() | |
| 42 | | `Global` | Time, TimeStep (cbuffer PerFrame) | |
| 43 | |
| 44 | ### vvvv-Only (NOT available in plain Stride) |
| 45 | |
| 46 | | Shader | Inherits | Use For | |
| 47 | |---|---|---| |
| 48 | | `VS_PS_Base` | ShaderBase, PositionStream4, NormalStream, Transformation | DrawFX base | |
| 49 | | `FilterBase` | TextureFX | Pixel-processing texture effects | |
| 50 | | `MixerBase` | TextureFX | Blending textures | |
| 51 | | `TextureFX` | ImageEffectShader, Camera, ShaderUtils | Texture effect base | |
| 52 | |
| 53 | **Important**: `VS_PS_Base` already includes Transformation, NormalStream, and PositionStream4. Do NOT re-inherit them. |
| 54 | |
| 55 | ## File Naming → Auto Node Generation |
| 56 | |
| 57 | vvvv automatically creates nodes from shaders based on filename suffix: |
| 58 | |
| 59 | | Suffix | Node Type | Description | |
| 60 | |---|---|---| |
| 61 | | `_TextureFX.sdsl` | TextureFX | Image processing effects | |
| 62 | | `_DrawFX.sdsl` | DrawFX | Drawing/rendering shaders | |
| 63 | | `_ComputeFX.sdsl` | ComputeFX | Compute shaders | |
| 64 | | `_ShaderFX.sdsl` | ShaderFX | General shader effects | |
| 65 | |
| 66 | Example: `MyBlur_TextureFX.sdsl` automatically creates a "MyBlur" TextureFX node. |
| 67 | |
| 68 | ## Basic TextureFX Structure |
| 69 | |
| 70 | ```hlsl |
| 71 | shader MyEffect_TextureFX : FilterBase |
| 72 | { |
| 73 | float Intensity = 1.0; |
| 74 | |
| 75 | float4 Filter(float4 tex0col) |
| 76 | { |
| 77 | return tex0col * Intensity; |
| 78 | } |
| 79 | }; |
| 80 | ``` |
| 81 | |
| 82 | Note the **semicolon after the closing brace** — this is required. |
| 83 | |
| 84 | ## Syntax Rules |
| 85 | |
| 86 | For critical SDSL syntax rules (`static const` scope, semicolons, `override`, variable initialization, common mistakes, branch divergence), see [syntax-rules.md](syntax-rules.md). |
| 87 | |
| 88 | ## Keywords |
| 89 | |
| 90 | | Keyword | Purpose | |
| 91 | |---|---| |
| 92 | | `shader` | Defines a shader class | |
| 93 | | `override` | Required when overriding parent methods | |
| 94 | | `base` | Access parent implementation | |
| 95 | | `stage` | Ensures member defined once across compositions | |
| 96 | | `stream` | Member accessible at every shader stage | |
| 97 | | `static` | Static methods callable without inheritance | |
| 98 | | `compose` | Declare a composition slot for shader mixins | |
| 99 | | `clone` | Force separate instance of a composed shader | |
| 100 | | `abstract` | Method without body (child must implement) | |
| 101 | |
| 102 | ## Inheritance & Mixins |
| 103 | |
| 104 | ```hlsl |
| 105 | // Single inheritance |
| 106 | shader Child : Parent |
| 107 | { |
| 108 | override float4 Filter(float4 tex0col) |
| 109 | { |
| 110 | return base.Filter(tex0col) * 0.5; |
| 111 | } |
| 112 | }; |
| 113 | |
| 114 | // Multiple inheritance (mixins) |
| 115 | shader MyShader : FilterBase, ColorUtils, MathUtils |
| 116 | { |
| 117 | float4 Filter(float4 tex0col) |
| 118 | { |
| 119 | float3 linear = ColorUtils.GammaToLinear(tex0col.rgb); |
| 120 | return float4(linear, tex0col.a); |
| 121 | } |
| 122 | }; |
| 123 | |
| 124 | // Static function calls (no inheritance needed) |
| 125 | float3 result = ColorUtils.LinearToGamma(col.rgb); |
| 126 | ``` |
| 127 | |
| 128 | ## Enum Binding — C# Enum in Shaders |
| 129 | |
| 130 | In the shader (`.sdsl`): |
| 131 | ```hlsl |
| 132 | [EnumType("MyNamespace.BlendMode, MyAssembly")] |
| 133 | int Mode = 0; |
| 134 | ``` |
| 135 | |
| 136 | In C# (`.cs`): |
| 137 | ``` |