Loading...
Loading...
Helps write SDSL shaders for Stride and vvvv gamma — TextureFX, shader mixins, compute shaders, and ShaderFX composition. Use when writing or debugging .sdsl shader files, creating visual effects, working with the Stride rendering pipeline, or composing shader mixins.
npx skill4agent add tebjan/vvvv-skills vvvv-shadersshaderstreamsoverride.sdslstream float4 MyData : TEXCOORD5; // Declare a custom stream variable
// In vertex shader:
streams.MyData = float4(1, 0, 0, 1); // Write
// In pixel shader:
float4 d = streams.MyData; // Read (auto-interpolated)streams.ShadingPositionstreams.ColorTargetstreams.Positionstreams.TexCoordstreams.normalWS| Shader | Provides |
|---|---|
| VSMain/PSMain entry points |
| Texture0-9, Sampler, PointSampler, LinearSampler, TexCoord |
| World, View, Projection, WorldViewProjection matrices |
| Position, PositionWS, DepthVS |
| meshNormal, normalWS, tangentToWorld |
| CSMain entry, Compute() hook, thread groups |
| Interface returning float4 via Compute() |
| Interface returning void via Compute() |
| Time, TimeStep (cbuffer PerFrame) |
| Shader | Inherits | Use For |
|---|---|---|
| ShaderBase, PositionStream4, NormalStream, Transformation | DrawFX base |
| TextureFX | Pixel-processing texture effects |
| TextureFX | Blending textures |
| ImageEffectShader, Camera, ShaderUtils | Texture effect base |
VS_PS_Base| Suffix | Node Type | Description |
|---|---|---|
| TextureFX | Image processing effects |
| DrawFX | Drawing/rendering shaders |
| ComputeFX | Compute shaders |
| ShaderFX | General shader effects |
MyBlur_TextureFX.sdslshader MyEffect_TextureFX : FilterBase
{
float Intensity = 1.0;
float4 Filter(float4 tex0col)
{
return tex0col * Intensity;
}
};static constoverride| Keyword | Purpose |
|---|---|
| Defines a shader class |
| Required when overriding parent methods |
| Access parent implementation |
| Ensures member defined once across compositions |
| Member accessible at every shader stage |
| Static methods callable without inheritance |
| Declare a composition slot for shader mixins |
| Force separate instance of a composed shader |
| Method without body (child must implement) |
// Single inheritance
shader Child : Parent
{
override float4 Filter(float4 tex0col)
{
return base.Filter(tex0col) * 0.5;
}
};
// Multiple inheritance (mixins)
shader MyShader : FilterBase, ColorUtils, MathUtils
{
float4 Filter(float4 tex0col)
{
float3 linear = ColorUtils.GammaToLinear(tex0col.rgb);
return float4(linear, tex0col.a);
}
};
// Static function calls (no inheritance needed)
float3 result = ColorUtils.LinearToGamma(col.rgb);.sdsl[EnumType("MyNamespace.BlendMode, MyAssembly")]
int Mode = 0;.csnamespace MyNamespace;
public enum BlendMode
{
Normal = 0,
Add = 1,
Multiply = 2,
Screen = 3
}float3 safeLog = log2(max(x, 1e-10)); // Avoid log2(0)
float3 safe = x / max(y, 0.0001); // Avoid div by zero
float3 safePow = pow(max(x, 0.0), gamma); // Avoid pow(negative)// In TextureFX, tex0col is already sampled from Texture0
float4 Filter(float4 tex0col)
{
// Sample additional textures:
float4 tex1 = Texture1.Sample(Texturex1Sampler, streams.TexCoord);
return lerp(tex0col, tex1, 0.5);
}composeshader MyTonemap_ShaderFX : ComputeColor, TonemapOperators
{
compose ComputeColor ColorIn;
[EnumType("MyNamespace.TonemapOp, MyAssembly")]
int Operator = 1;
float Exposure = 0.0;
override float4 Compute()
{
float4 color = ColorIn.Compute();
color.rgb *= exp2(Exposure);
color.rgb = ApplyTonemap(color.rgb, Operator);
return color;
}
};compose// Base shader declares the virtual method
shader ColorProcessorBase
{
float4 ProcessColor(float4 inPixel) { return inPixel; }
};
// Host shader uses composition
shader ColorTransform_TextureFX : TextureFX
{
stage compose ColorProcessorBase Processor;
stage override float4 Shading()
{
float4 col = Texture0.SampleLevel(PointSampler, streams.TexCoord, 0);
return Processor.ProcessColor(col);
}
};// Declaration with type parameter
shader ComputeColorWave<float Frequency> : ComputeColor, Texturing
{
override float4 Compute()
{
return float4(sin(streams.TexCoord.x * Frequency), 0, 0, 1);
}
};
// Instantiation via inheritance
shader MyEffect : ComputeColorWave<2.0f> { };floatintfloat2float3float4Texture2DSamplerStatecompose ComputeColor lights[];
override float4 Compute()
{
float4 total = 0;
foreach (var light in lights)
total += light.Compute();
return total;
}shader ParticleTypes
{
struct Particle { float3 Position; float3 Velocity; float Life; };
};
shader Emit_ComputeFX : ComputeShaderBase, ParticleTypes { /* fills buffer */ };
shader Simulate_ComputeFX : ComputeShaderBase, ParticleTypes { /* physics */ };
shader Draw_DrawFX : VS_PS_Base, ParticleTypes { /* renders */ };