namespace ComputeSharp.SwapChain.Shaders; /// /// A shader creating a fractal tiling animation. /// Ported from . /// Created by Inigo Quilez. /// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. /// /// The current time since the start of the application. [ThreadGroupSize(DefaultThreadGroupSizes.XY)] [GeneratedComputeShaderDescriptor] internal readonly partial struct FractalTiling(float time) : IComputeShader { /// public float4 Execute() { float2 position = (((float2)(256 * ThreadIds.XY)) / DispatchSize.X) + time; float4 color = 0; for (int i = 0; i < 6; i++) { float2 a = Hlsl.Floor(position); float2 b = Hlsl.Frac(position); float4 w = Hlsl.Frac( (Hlsl.Sin((a.X * 7) + (31.0f * a.Y) + (0.01f * time)) + new float4(0.035f, 0.01f, 0, 0.7f)) * 13.545317f); color.XYZ += w.XYZ * 2.0f * Hlsl.SmoothStep(0.45f, 0.55f, w.W) * Hlsl.Sqrt(16.0f * b.X * b.Y * (1.0f - b.X) * (1.0f - b.Y)); position /= 2.0f; color /= 2.0f; } color.XYZ = Hlsl.Pow(color.XYZ, new float3(0.7f, 0.8f, 0.5f)); color.W = 1.0f; return color; } }