diff --git a/packages/VL.Stride.Runtime/src/Effects/Common/ShaderUtils.sdsl b/packages/VL.Stride.Runtime/src/Effects/Common/ShaderUtils.sdsl index 9d140a3da..278086e8b 100644 --- a/packages/VL.Stride.Runtime/src/Effects/Common/ShaderUtils.sdsl +++ b/packages/VL.Stride.Runtime/src/Effects/Common/ShaderUtils.sdsl @@ -253,4 +253,11 @@ shader ShaderUtils float y = cos(a) * pt.y - sin(a) * pt.x; return float2(x,y); } + + // TRANSFORM 2D ============================================================== + + float2 TransformUV(float2 uv, float4x4 transform) + { + return mul(float4((uv.xy * 2 - 1) * float2(1, -1) * 0.5, 0, 1), transform).xy * float2(1, -1) + 0.5; + } }; \ No newline at end of file diff --git a/packages/VL.Stride.Runtime/src/Effects/TextureFX/Sources/Checkerboard_TextureFX.sdsl b/packages/VL.Stride.Runtime/src/Effects/TextureFX/Sources/Checkerboard_TextureFX.sdsl index 535ece5f1..8a1e27581 100644 --- a/packages/VL.Stride.Runtime/src/Effects/TextureFX/Sources/Checkerboard_TextureFX.sdsl +++ b/packages/VL.Stride.Runtime/src/Effects/TextureFX/Sources/Checkerboard_TextureFX.sdsl @@ -4,18 +4,22 @@ [Tags("chessboard")] shader Checkerboard_TextureFX : TextureFX { - int2 CellCount = int2(8, 8); + [Default(8.0f, 8.0f)] + compose ComputeFloat2 CellCount; [Color] float4 Black = float4(0, 0, 0, 1); [Color] float4 White = float4(1, 1, 1, 1); + float4x4 Transform; + stage override float4 Shading() { //compute size - float2 stepHV = 1 / float2(CellCount.x, CellCount.y); - float2 uv = streams.TexCoord; + float2 cellCount = CellCount.Compute(); + float2 stepHV = 1 / float2(cellCount.x, cellCount.y); + float2 uv = TransformUV(streams.TexCoord, Transform); //compute black|white float2 cHV = abs(uv) / stepHV; diff --git a/packages/VL.Stride.Runtime/src/Effects/TextureFX/Sources/Checkerboard_TextureFX.sdsl.cs b/packages/VL.Stride.Runtime/src/Effects/TextureFX/Sources/Checkerboard_TextureFX.sdsl.cs new file mode 100644 index 000000000..f24d6720c --- /dev/null +++ b/packages/VL.Stride.Runtime/src/Effects/TextureFX/Sources/Checkerboard_TextureFX.sdsl.cs @@ -0,0 +1,25 @@ +// +// Do not edit this file yourself! +// +// This code was generated by Stride Shader Mixin Code Generator. +// To generate it yourself, please install Stride.VisualStudio.Package .vsix +// and re-save the associated .sdfx. +// + +using System; +using Stride.Core; +using Stride.Rendering; +using Stride.Graphics; +using Stride.Shaders; +using Stride.Core.Mathematics; +using Buffer = Stride.Graphics.Buffer; + +namespace Stride.Rendering +{ + public static partial class Checkerboard_TextureFXKeys + { + public static readonly ValueParameterKey Black = ParameterKeys.NewValue(new Color4(0,0,0,1)); + public static readonly ValueParameterKey White = ParameterKeys.NewValue(new Color4(1,1,1,1)); + public static readonly ValueParameterKey Transform = ParameterKeys.NewValue(); + } +}