diff --git a/samples/ComputeSharp.SwapChain/Program.cs b/samples/ComputeSharp.SwapChain/Program.cs index 7e7332f2..c44c7992 100644 --- a/samples/ComputeSharp.SwapChain/Program.cs +++ b/samples/ComputeSharp.SwapChain/Program.cs @@ -20,6 +20,7 @@ namespace ComputeSharp.SwapChain /// private static readonly Win32Application[] Samples = new Win32Application[] { + new SwapChainApplication(static time => new((float)time.TotalSeconds)), new SwapChainApplication(static time => new((float)time.TotalSeconds)), new SwapChainApplication(static time => new((float)time.TotalSeconds)), new SwapChainApplication(static time => new((float)time.TotalSeconds)), diff --git a/samples/ComputeSharp.SwapChain/Shaders/HelloWorld.cs b/samples/ComputeSharp.SwapChain/Shaders/HelloWorld.cs new file mode 100644 index 00000000..cf6c9a34 --- /dev/null +++ b/samples/ComputeSharp.SwapChain/Shaders/HelloWorld.cs @@ -0,0 +1,29 @@ +namespace ComputeSharp.SwapChain.Shaders +{ + /// + /// A simple shader to get started with based on shadertoy new shader template. + /// Ported from . + /// + /// + [AutoConstructor] + internal readonly partial struct HelloWorld : IPixelShader + { + /// + /// The current time since the start of the application. + /// + public readonly float time; + + /// + public Float4 Execute() + { + // Normalized ScreenSpace UV coordinates from 0.0f to 1.0f + Float2 uv = new Float2(ThreadIds.Normalized.X, ThreadIds.Normalized.Y); + + // Time varying pixel color + Float3 col = 0.5f + 0.5f * Hlsl.Cos(time + new Float3(uv, uv.X) + new Float3(0, 2, 4)); + + // Output to screen + return new(col, 1f); + } + } +}