diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ColorfulInfinity.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ColorfulInfinity.cs
index 6ab6b07a..803d44fc 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ColorfulInfinity.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ColorfulInfinity.cs
@@ -6,16 +6,11 @@ namespace ComputeSharp.SwapChain.Shaders;
/// Created by Benoit Marini.
/// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
///
-[AutoConstructor]
+/// The current time since the start of the application.
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
[GeneratedComputeShaderDescriptor]
-internal readonly partial struct ColorfulInfinity : IComputeShader
+internal readonly partial struct ColorfulInfinity(float time) : IComputeShader
{
- ///
- /// The current time since the start of the application.
- ///
- private readonly float time;
-
///
/// The total number of layers for the final animation.
///
@@ -31,7 +26,7 @@ internal readonly partial struct ColorfulInfinity : IComputeShader
///
private float4 Tex(float3 p)
{
- float t = this.time + 78.0f;
+ float t = time + 78.0f;
float4 o = new(p.X, p.Y, p.Z, 3.0f * Hlsl.Sin(t * 0.1f));
float4 dec =
new float4(1.0f, 0.9f, 0.1f, 0.15f) +
@@ -50,7 +45,7 @@ internal readonly partial struct ColorfulInfinity : IComputeShader
{
float2 uv = (ThreadIds.XY - ((float2)DispatchSize.XY * 0.5f)) / DispatchSize.Y;
float3 col = 0;
- float t = this.time * 0.3f;
+ float t = time * 0.3f;
for (float i = 0.0f; i <= 1.0f; i += 1.0f / NumberOfLayers)
{
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs
index 9f795bc1..5a632cc3 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs
@@ -5,21 +5,14 @@ namespace ComputeSharp.SwapChain.Shaders;
/// Ported from .
/// Created by Shane.
///
-[AutoConstructor]
+/// The current time Hlsl.Since the start of the application.
+/// The background texture to sample.
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
[GeneratedComputeShaderDescriptor]
-internal readonly partial struct ContouredLayers : IComputeShader
+internal readonly partial struct ContouredLayers(
+ float time,
+ IReadOnlyNormalizedTexture2D texture) : IComputeShader
{
- ///
- /// The current time Hlsl.Since the start of the application.
- ///
- private readonly float time;
-
- ///
- /// The background texture to sample.
- ///
- private readonly IReadOnlyNormalizedTexture2D texture;
-
// float3 to float hash.
private static float Hash21(float2 p)
{
@@ -33,7 +26,7 @@ internal readonly partial struct ContouredLayers : IComputeShader
p = Hlsl.Frac(new float2(262144, 32768) * n);
- return Hlsl.Sin((p * 6.2831853f) + this.time);
+ return Hlsl.Sin((p * 6.2831853f) + time);
}
// float2 to float2 hash.
@@ -110,7 +103,7 @@ internal readonly partial struct ContouredLayers : IComputeShader
// Layer color. Based on the shade, layer number and smoothing factor.
private float3 GetColor(float2 p, float sh, float fi)
{
- float3 tx = this.texture.Sample(p + Hash21(new float2(sh, fi))).XYZ;
+ float3 tx = texture.Sample(p + Hash21(new float2(sh, fi))).XYZ;
tx *= tx;
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs
index ec060b65..c3659c6c 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs
@@ -5,16 +5,11 @@ namespace ComputeSharp.SwapChain.Shaders;
/// Ported from .
/// Created by Shane.
///
-[AutoConstructor]
+/// The current time since the start of the application.
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
[GeneratedComputeShaderDescriptor]
-internal readonly partial struct ExtrudedTruchetPattern : IComputeShader
+internal readonly partial struct ExtrudedTruchetPattern(float time) : IComputeShader
{
- ///
- /// The current time since the start of the application.
- ///
- private readonly float time;
-
///
/// Curve shape - Round: 0, Semi-round: 1, Octagonal: 2, Superellipse: 3, Straight: 4.
///
@@ -169,7 +164,7 @@ internal readonly partial struct ExtrudedTruchetPattern : IComputeShader
float sca = 2.0f;
float occ = 0.0f;
- for (int i = (int)Hlsl.Min(this.time, 0f); i < 5; i++)
+ for (int i = (int)Hlsl.Min(time, 0f); i < 5; i++)
{
float hr = (i + 1f) * 0.15f / 5.0f;
float d = M(p + (n * hr));
@@ -203,15 +198,15 @@ internal readonly partial struct ExtrudedTruchetPattern : IComputeShader
int2 coords = new(ThreadIds.X, DispatchSize.Y - ThreadIds.Y);
float2 u = (coords - ((float2)DispatchSize.XY * 0.5f)) / DispatchSize.Y;
float3 r = Hlsl.Normalize(new float3(u, 1));
- float3 o = new(0, this.time / 2.0f, -3);
+ float3 o = new(0, time / 2.0f, -3);
float3 l = o + new float3(0.25f, 0.25f, 2.0f);
r.YZ = Hlsl.Mul(Rotate2x2(0.15f), r.YZ);
- r.XZ = Hlsl.Mul(Rotate2x2(-Hlsl.Cos(this.time * 3.14159f / 32.0f) / 8.0f), r.XZ);
- r.XY = Hlsl.Mul(Rotate2x2(Hlsl.Sin(this.time * 3.14159f / 32.0f) / 8.0f), r.XY);
+ r.XZ = Hlsl.Mul(Rotate2x2(-Hlsl.Cos(time * 3.14159f / 32.0f) / 8.0f), r.XZ);
+ r.XY = Hlsl.Mul(Rotate2x2(Hlsl.Sin(time * 3.14159f / 32.0f) / 8.0f), r.XY);
float d;
- float t = Hash21((r.XY * 57.0f) + Hlsl.Frac(this.time)) * 0.5f;
+ float t = Hash21((r.XY * 57.0f) + Hlsl.Frac(time)) * 0.5f;
float glow = 0;
for (int i = 0; i < 96; i++)
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs
index a94a8283..37e800b5 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs
@@ -6,16 +6,11 @@ namespace ComputeSharp.SwapChain.Shaders;
/// Created by Inigo Quilez.
/// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
///
-[AutoConstructor]
+/// The current time since the start of the application.
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
[GeneratedComputeShaderDescriptor]
-internal readonly partial struct FourColorGradient : IComputeShader
+internal readonly partial struct FourColorGradient(float time) : IComputeShader
{
- ///
- /// The current time since the start of the application.
- ///
- private readonly float time;
-
// Colors to blend together
private static readonly float3 ColorOne = new(0.999f, 0.999f, 0.999f);
private static readonly float3 ColorTwo = new(0.999f, 0f, 0f);
@@ -82,7 +77,7 @@ internal readonly partial struct FourColorGradient : IComputeShader
tuv -= 0.5f;
// Rotate with noise
- float degree = Noise(new float2(this.time * 0.1f, tuv.X * tuv.Y));
+ float degree = Noise(new float2(time * 0.1f, tuv.X * tuv.Y));
tuv.Y *= 1.0f / ratio;
tuv.XY = Hlsl.Mul(tuv.XY, Rotate(Hlsl.Radians(((degree - 0.5f) * 720.0f) + 180.0f)));
@@ -91,7 +86,7 @@ internal readonly partial struct FourColorGradient : IComputeShader
// Wave warp with sin
float frequency = 5.0f;
float amplitude = 30.0f;
- float speed = this.time * 2.0f;
+ float speed = time * 2.0f;
tuv.X += Hlsl.Sin((tuv.Y * frequency) + speed) / amplitude;
tuv.Y += Hlsl.Sin((tuv.X * frequency * 1.5f) + speed) / (amplitude * 0.5f);
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/FractalTiling.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/FractalTiling.cs
index 145c2a91..50a1dc25 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/FractalTiling.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/FractalTiling.cs
@@ -6,20 +6,15 @@ namespace ComputeSharp.SwapChain.Shaders;
/// Created by Inigo Quilez.
/// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
///
-[AutoConstructor]
+/// The current time since the start of the application.
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
[GeneratedComputeShaderDescriptor]
-internal readonly partial struct FractalTiling : IComputeShader
+internal readonly partial struct FractalTiling(float time) : IComputeShader
{
- ///
- /// The current time since the start of the application.
- ///
- private readonly float time;
-
///
public float4 Execute()
{
- float2 position = (((float2)(256 * ThreadIds.XY)) / DispatchSize.X) + this.time;
+ float2 position = (((float2)(256 * ThreadIds.XY)) / DispatchSize.X) + time;
float4 color = 0;
for (int i = 0; i < 6; i++)
@@ -27,7 +22,7 @@ internal readonly partial struct FractalTiling : IComputeShader
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 * this.time)) +
+ (Hlsl.Sin((a.X * 7) + (31.0f * a.Y) + (0.01f * time)) +
new float4(0.035f, 0.01f, 0, 0.7f))
* 13.545317f);
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/HelloWorld.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/HelloWorld.cs
index 43ee5e87..54c77971 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/HelloWorld.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/HelloWorld.cs
@@ -4,16 +4,11 @@ namespace ComputeSharp.SwapChain.Shaders;
/// A simple shader to get started with based on shadertoy new shader template.
/// Ported from .
///
-[AutoConstructor]
+/// The current time since the start of the application.
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
[GeneratedComputeShaderDescriptor]
-internal readonly partial struct HelloWorld : IComputeShader
+internal readonly partial struct HelloWorld(float time) : IComputeShader
{
- ///
- /// The current time since the start of the application.
- ///
- private readonly float time;
-
///
public float4 Execute()
{
@@ -21,7 +16,7 @@ internal readonly partial struct HelloWorld : IComputeShader
float2 uv = ThreadIds.Normalized.XY;
// Time varying pixel color
- float3 col = 0.5f + (0.5f * Hlsl.Cos(this.time + new float3(uv, uv.X) + new float3(0, 2, 4)));
+ 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);
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs
index 022237aa..78fbeec4 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs
@@ -5,16 +5,11 @@ namespace ComputeSharp.SwapChain.Shaders;
/// Ported from .
/// Created by Syntopia.
///
-[AutoConstructor]
+/// The current time since the start of the application.
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
[GeneratedComputeShaderDescriptor]
-internal readonly partial struct MengerJourney : IComputeShader
+internal readonly partial struct MengerJourney(float time) : IComputeShader
{
- ///
- /// The current time since the start of the application.
- ///
- private readonly float time;
-
private const int MaxSteps = 30;
private const float MinimumDistance = 0.0009f;
private const float NormalDistance = 0.0002f;
@@ -76,7 +71,7 @@ internal readonly partial struct MengerJourney : IComputeShader
for (int n = 0; n < Iterations; n++)
{
- z.XY = Rotate(z.XY, 4.0f + (2.0f * Hlsl.Cos(this.time / 8.0f)));
+ z.XY = Rotate(z.XY, 4.0f + (2.0f * Hlsl.Cos(time / 8.0f)));
z = Hlsl.Abs(z);
if (z.X < z.Y) { z.XY = z.YX; }
@@ -122,7 +117,7 @@ internal readonly partial struct MengerJourney : IComputeShader
return Hlsl.Frac(Hlsl.Cos(Hlsl.Dot(co, new float2(4.898f, 7.23f))) * 23421.631f);
}
- float totalDistance = Jitter * Rand(fragCoord.XY + this.time);
+ float totalDistance = Jitter * Rand(fragCoord.XY + time);
float3 dir2 = dir;
float distance = 0;
int steps = 0;
@@ -130,7 +125,7 @@ internal readonly partial struct MengerJourney : IComputeShader
for (int i = 0; i < MaxSteps; i++)
{
- dir.ZY = Rotate(dir2.ZY, totalDistance * Hlsl.Cos(this.time / 4.0f) * NonLinearPerspective);
+ dir.ZY = Rotate(dir2.ZY, totalDistance * Hlsl.Cos(time / 4.0f) * NonLinearPerspective);
pos = from + (totalDistance * dir);
distance = DE(pos) * FudgeFactor;
totalDistance += distance;
@@ -157,8 +152,8 @@ internal readonly partial struct MengerJourney : IComputeShader
///
public float4 Execute()
{
- float3 camPos = 0.5f * this.time * new float3(1.0f, 0.0f, 0.0f);
- float3 target = camPos + new float3(1.0f, 0.0f * Hlsl.Cos(this.time), 0.0f * Hlsl.Sin(0.4f * this.time));
+ float3 camPos = 0.5f * time * new float3(1.0f, 0.0f, 0.0f);
+ float3 target = camPos + new float3(1.0f, 0.0f * Hlsl.Cos(time), 0.0f * Hlsl.Sin(0.4f * time));
float3 camDir = Hlsl.Normalize(target - camPos);
float3 camUp = new(0.0f, 1.0f, 0.0f);
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/Octagrams.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/Octagrams.cs
index b43b0191..8ff3bab4 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/Octagrams.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/Octagrams.cs
@@ -5,16 +5,11 @@ namespace ComputeSharp.SwapChain.Shaders;
/// Ported from .
/// Created by whisky_shusuky.
///
-[AutoConstructor]
+/// The current time since the start of the application.
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
[GeneratedComputeShaderDescriptor]
-internal readonly partial struct Octagrams : IComputeShader
+internal readonly partial struct Octagrams(float time) : IComputeShader
{
- ///
- /// The current time since the start of the application.
- ///
- private readonly float time;
-
private static float2x2 Rotate(float a)
{
float c = Hlsl.Cos(a);
@@ -89,11 +84,11 @@ internal readonly partial struct Octagrams : IComputeShader
public float4 Execute()
{
float2 p = (((float2)ThreadIds.XY * 2.0f) - DispatchSize.XY) / Hlsl.Min(DispatchSize.X, DispatchSize.Y);
- float3 ro = new(0.0f, -0.2f, this.time * 4.0f);
+ float3 ro = new(0.0f, -0.2f, time * 4.0f);
float3 ray = Hlsl.Normalize(new float3(p, 1.5f));
- ray.XY = Hlsl.Mul(ray.XY, Rotate(Hlsl.Sin(this.time * 0.03f) * 5.0f));
- ray.YZ = Hlsl.Mul(ray.YZ, Rotate(Hlsl.Sin(this.time * 0.05f) * 0.2f));
+ ray.XY = Hlsl.Mul(ray.XY, Rotate(Hlsl.Sin(time * 0.03f) * 5.0f));
+ ray.YZ = Hlsl.Mul(ray.YZ, Rotate(Hlsl.Sin(time * 0.05f) * 0.2f));
float t = 0.1f;
float ac = 0.0f;
@@ -109,7 +104,7 @@ internal readonly partial struct Octagrams : IComputeShader
pos = Mod(pos - 2.0f, 4.0f) - 2.0f;
- float gTime = this.time - (i * 0.01f);
+ float gTime = time - (i * 0.01f);
float d = BoxSet(pos, gTime);
d = Hlsl.Max(Hlsl.Abs(d), 0.01f);
@@ -117,7 +112,7 @@ internal readonly partial struct Octagrams : IComputeShader
t += d * 0.55f;
}
- float3 col = (ac * 0.02f) + new float3(0.0f, 0.2f * Hlsl.Abs(Hlsl.Sin(this.time)), 0.5f + (Hlsl.Sin(this.time) * 0.2f));
+ float3 col = (ac * 0.02f) + new float3(0.0f, 0.2f * Hlsl.Abs(Hlsl.Sin(time)), 0.5f + (Hlsl.Sin(time) * 0.2f));
float4 color = new(col, 1);
return color;
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs
index b928d66d..2c56510d 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs
@@ -6,16 +6,11 @@ namespace ComputeSharp.SwapChain.Shaders;
/// Created by nimitz (twitter: @stormoid).
/// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
///
-[AutoConstructor]
+/// The current time Hlsl.Since the start of the application.
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
[GeneratedComputeShaderDescriptor]
-internal readonly partial struct ProteanClouds : IComputeShader
+internal readonly partial struct ProteanClouds(float time) : IComputeShader
{
- ///
- /// The current time Hlsl.Since the start of the application.
- ///
- private readonly float time;
-
private static readonly float3x3 M3 = new float3x3(0.33338f, 0.56034f, -0.71817f, -0.87887f, 0.32651f, -0.15323f, 0.15162f, 0.69596f, 0.61339f) * 1.93f;
private static float2x2 Rotate(in float a)
@@ -41,7 +36,7 @@ internal readonly partial struct ProteanClouds : IComputeShader
float3 p2 = p;
p2.XY -= Disp(p.Z).XY;
- p.XY = Hlsl.Mul(p.XY, Rotate((Hlsl.Sin(p.Z + this.time) * (0.1f + (prm1 * 0.05f))) + (this.time * 0.09f)));
+ p.XY = Hlsl.Mul(p.XY, Rotate((Hlsl.Sin(p.Z + time) * (0.1f + (prm1 * 0.05f))) + (time * 0.09f)));
float cl = Hlsl.Dot(p2.XY, p2.XY);
float d = 0.0f;
@@ -54,7 +49,7 @@ internal readonly partial struct ProteanClouds : IComputeShader
for (int i = 0; i < 5; i++)
{
- p += Hlsl.Sin((p.ZXY * 0.75f * trk) + (this.time * trk * 0.8f)) * dspAmp;
+ p += Hlsl.Sin((p.ZXY * 0.75f * trk) + (time * trk * 0.8f)) * dspAmp;
d -= Hlsl.Abs(Hlsl.Dot(Hlsl.Cos(p), Hlsl.Sin(p.YZX)) * z);
z *= 0.57f;
trk *= 1.4f;
@@ -137,10 +132,10 @@ internal readonly partial struct ProteanClouds : IComputeShader
float2 q = (float2)ThreadIds.XY / DispatchSize.XY;
float2 p = (ThreadIds.XY - (0.5f * (float2)DispatchSize.XY)) / DispatchSize.Y;
float2 bsMo = -0.5f * (float2)DispatchSize.XY / DispatchSize.Y;
- float scaledTime = this.time * 3.0f;
+ float scaledTime = time * 3.0f;
float3 ro = new(0, 0, scaledTime);
- ro += new float3(Hlsl.Sin(this.time) * 0.5f, Hlsl.Sin(this.time * 1.0f) * 0.0f, 0);
+ ro += new float3(Hlsl.Sin(time) * 0.5f, Hlsl.Sin(time * 1.0f) * 0.0f, 0);
float dspAmp = 0.85f;
@@ -160,7 +155,7 @@ internal readonly partial struct ProteanClouds : IComputeShader
rd.XY = Hlsl.Mul(rd.XY, Rotate((-Disp(scaledTime + 3.5f).X * 0.2f) + bsMo.X));
- float prm1 = Hlsl.SmoothStep(-0.4f, 0.4f, Hlsl.Sin(this.time * 0.3f));
+ float prm1 = Hlsl.SmoothStep(-0.4f, 0.4f, Hlsl.Sin(time * 0.3f));
float4 scn = Render(ro, rd, scaledTime, prm1, bsMo);
float3 col = scn.RGB;
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs
index 8c5d0956..c4e23655 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs
@@ -6,16 +6,11 @@ namespace ComputeSharp.SwapChain.Shaders;
/// Ported from .
/// Created by Shane.
///
-[AutoConstructor]
+/// The current time Hlsl.Since the start of the application.
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
[GeneratedComputeShaderDescriptor]
-internal readonly partial struct PyramidPattern : IComputeShader
+internal readonly partial struct PyramidPattern(float time) : IComputeShader
{
- ///
- /// The current time Hlsl.Since the start of the application.
- ///
- private readonly float time;
-
// Standard 2D rotation formula.
private static float2x2 Rotate2x2(in float a)
{
@@ -83,7 +78,7 @@ internal readonly partial struct PyramidPattern : IComputeShader
p -= ip + 0.5f;
- float ang = (-3.14159f * 3.0f / 5.0f) + (FBM((ip / 8.0f) + (this.time / 3.0f)) * 6.2831f * 2.0f);
+ float ang = (-3.14159f * 3.0f / 5.0f) + (FBM((ip / 8.0f) + (time / 3.0f)) * 6.2831f * 2.0f);
float2 offs = new float2(Hlsl.Cos(ang), Hlsl.Sin(ang)) * 0.35f;
@@ -153,7 +148,7 @@ internal readonly partial struct PyramidPattern : IComputeShader
float2 uv = (coordinate - ((float2)DispatchSize.XY * 0.5f)) / iRes;
float3 rd = Hlsl.Normalize(new float3(uv, 0.5f));
const float gSc = 10.0f;
- float2 p = (uv * gSc) + new float2(0, this.time / 2.0f);
+ float2 p = (uv * gSc) + new float2(0, time / 2.0f);
float2 oP = p;
float m = BMap(p);
float3 n = new(0, 0, -1);
@@ -162,7 +157,7 @@ internal readonly partial struct PyramidPattern : IComputeShader
n = DoBumpMap(p, n, bumpFactor, ref edge);
- float3 lp = new float3(-0.0f + (Hlsl.Sin(this.time) * 0.3f), 0.0f + (Hlsl.Cos(this.time * 1.3f) * 0.3f), -1) - new float3(uv, 0);
+ float3 lp = new float3(-0.0f + (Hlsl.Sin(time) * 0.3f), 0.0f + (Hlsl.Cos(time * 1.3f) * 0.3f), -1) - new float3(uv, 0);
float lDist = Hlsl.Max(Hlsl.Length(lp), 0.001f);
float3 ld = lp / lDist;
float diff = Hlsl.Max(Hlsl.Dot(n, ld), 0.0f);
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/TerracedHills.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/TerracedHills.cs
index d84390a7..7431beb9 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/TerracedHills.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/TerracedHills.cs
@@ -5,16 +5,11 @@ namespace ComputeSharp.SwapChain.Shaders;
/// Ported from .
/// Created by Shane.
///
-[AutoConstructor]
+/// The current time since the start of the application.
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
[GeneratedComputeShaderDescriptor]
-internal readonly partial struct TerracedHills : IComputeShader
+internal readonly partial struct TerracedHills(float time) : IComputeShader
{
- ///
- /// The current time since the start of the application.
- ///
- private readonly float time;
-
// 2x2 matrix rotation. Angle vector, courtesy of Fabrice
private static float2x2 Rot2(float th)
{
@@ -91,7 +86,7 @@ internal readonly partial struct TerracedHills : IComputeShader
rd.YZ = Rot2(0.35f) * rd.YZ;
- float3 ro = new(this.time * 0.4f, 0.5f, this.time * 0.2f);
+ float3 ro = new(time * 0.4f, 0.5f, time * 0.2f);
float t = 0, d;
for (int i = 0; i < 96; i++)
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs
index 4aeee763..12ea48be 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs
@@ -5,16 +5,11 @@ namespace ComputeSharp.SwapChain.Shaders;
/// Ported from .
/// Created by Shane.
///
-[AutoConstructor]
+/// The current time Hlsl.Since the start of the application.
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
[GeneratedComputeShaderDescriptor]
-internal readonly partial struct TriangleGridContouring : IComputeShader
+internal readonly partial struct TriangleGridContouring(float time) : IComputeShader
{
- ///
- /// The current time Hlsl.Since the start of the application.
- ///
- private readonly float time;
-
// Standard 2D rotation formula.
private static float2x2 Rotate2x2(in float a)
{
@@ -31,7 +26,7 @@ internal readonly partial struct TriangleGridContouring : IComputeShader
p = Hlsl.Frac(new float2(262144, 32768) * n);
- return Hlsl.Sin((p * 6.2831853f) + this.time);
+ return Hlsl.Sin((p * 6.2831853f) + time);
}
// Based on IQ's gradient noise formula.
@@ -290,7 +285,7 @@ internal readonly partial struct TriangleGridContouring : IComputeShader
{
int2 coordinate = new(ThreadIds.X, DispatchSize.Y - ThreadIds.Y);
float2 uv = (coordinate - ((float2)DispatchSize.XY * 0.5f)) / Hlsl.Min(650.0f, DispatchSize.Y);
- float2 p = Hlsl.Mul(Rotate2x2(3.14159f / 12.0f), uv) + (new float2(0.8660254f, 0.5f) * this.time / 16.0f);
+ float2 p = Hlsl.Mul(Rotate2x2(3.14159f / 12.0f), uv) + (new float2(0.8660254f, 0.5f) * time / 16.0f);
float3 col = SimplexContour(p);
uv = coordinate / (float2)DispatchSize.XY;
diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/TwoTiledTruchet.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/TwoTiledTruchet.cs
index 7106bd51..c674a2e3 100644
--- a/samples/ComputeSharp.SwapChain.Shaders.Shared/TwoTiledTruchet.cs
+++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/TwoTiledTruchet.cs
@@ -5,16 +5,11 @@ namespace ComputeSharp.SwapChain.Shaders;
/// Ported from .
/// Created by Shane.
///
-[AutoConstructor]
+/// The current time since the start of the application.
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
[GeneratedComputeShaderDescriptor]
-internal readonly partial struct TwoTiledTruchet : IComputeShader
+internal readonly partial struct TwoTiledTruchet(float time) : IComputeShader
{
- ///
- /// The current time since the start of the application.
- ///
- private readonly float time;
-
///
/// Calculates the Truchet distance field.
///
@@ -105,7 +100,7 @@ internal readonly partial struct TwoTiledTruchet : IComputeShader
ang *= 2.0f;
}
- ang = Hlsl.Frac(ang + (this.time / 4.0f));
+ ang = Hlsl.Frac(ang + (time / 4.0f));
return d;
}
@@ -115,7 +110,7 @@ internal readonly partial struct TwoTiledTruchet : IComputeShader
{
float2 uv = (ThreadIds.XY - ((float2)DispatchSize.XY * 0.5f)) / DispatchSize.Y;
float gSc = 7.0f;
- float2 p = (uv * gSc) - (new float2(-1, -0.5f) * this.time / 2.0f);
+ float2 p = (uv * gSc) - (new float2(-1, -0.5f) * time / 2.0f);
float sf = 2.0f / DispatchSize.Y * gSc;
float lSc = 6.0f;
float lw = 1.0f / lSc / gSc;
@@ -125,7 +120,7 @@ internal readonly partial struct TwoTiledTruchet : IComputeShader
for (int i = 0; i < 2; i++)
{
float di = d[i] - (lw / 4.0f);
- float tracks = Hlsl.Clamp(Hlsl.Sin((ang[i] * 6.2831f) + (this.time * 6.0f)) * 4.0f, 0.0f, 1.0f);
+ float tracks = Hlsl.Clamp(Hlsl.Sin((ang[i] * 6.2831f) + (time * 6.0f)) * 4.0f, 0.0f, 1.0f);
float gap = 1.0f + lw;
col = Hlsl.Lerp(col, 0, (1.0f - Hlsl.SmoothStep(0.0f, sf * 6.0f, di)) * 0.35f);