Add D2D1 FractalTiling test
このコミットが含まれているのは:
1 親
03279bf426
コミット
feab84cafc
3ファイル変更
+64
-4
検索条件に一致するファイルはありません
@@ -0,0 +1,54 @@
|
||||
namespace ComputeSharp.D2D1.Tests.Shaders;
|
||||
|
||||
/// <summary>
|
||||
/// A shader creating a fractal tiling animation.
|
||||
/// Ported from <see href="https://www.shadertoy.com/view/Ml2GWy"/>.
|
||||
/// <para>Created by Inigo Quilez.</para>
|
||||
/// <para>License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.</para>
|
||||
/// </summary>
|
||||
[D2DInputCount(0)]
|
||||
[D2DRequiresScenePosition]
|
||||
[D2DShaderProfile(D2D1ShaderProfile.PixelShader50)]
|
||||
[AutoConstructor]
|
||||
internal readonly partial struct FractalTiling : ID2D1PixelShader
|
||||
{
|
||||
/// <summary>
|
||||
/// The current time since the start of the application.
|
||||
/// </summary>
|
||||
public readonly float time;
|
||||
|
||||
/// <summary>
|
||||
/// The dispatch size for the current output.
|
||||
/// </summary>
|
||||
public readonly int2 dispatchSize;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public float4 Execute()
|
||||
{
|
||||
int2 xy = (int2)D2D.GetScenePosition().XY;
|
||||
float2 position = (((float2)(256 * xy)) / this.dispatchSize.X) + this.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 * this.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;
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ internal readonly partial struct HelloWorld : ID2D1PixelShader
|
||||
/// <inheritdoc/>
|
||||
public float4 Execute()
|
||||
{
|
||||
Int2 xy = (int2)D2D.GetScenePosition().XY;
|
||||
int2 xy = (int2)D2D.GetScenePosition().XY;
|
||||
|
||||
// Normalized screen space UV coordinates from 0.0 to 1.0
|
||||
float2 uv = xy / (float2)this.dispatchSize;
|
||||
|
||||
@@ -8,6 +8,12 @@ namespace ComputeSharp.D2D1.Tests;
|
||||
[TestCategory("Shaders")]
|
||||
public class ShadersTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void HelloWorld()
|
||||
{
|
||||
RunTest<Shaders.HelloWorld>();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ColorfulInfinity()
|
||||
{
|
||||
@@ -15,9 +21,9 @@ public class ShadersTests
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void HelloWorld()
|
||||
public void FractalTiling()
|
||||
{
|
||||
RunTest<Shaders.HelloWorld>();
|
||||
RunTest<Shaders.FractalTiling>();
|
||||
}
|
||||
|
||||
private static void RunTest<T>()
|
||||
@@ -25,6 +31,6 @@ public class ShadersTests
|
||||
{
|
||||
T shader = (T)Activator.CreateInstance(typeof(T), 0f, new int2(1280, 720))!;
|
||||
|
||||
D2D1TestRunner.RunAndCompareShader(in shader, 1280, 720, $"{typeof(T).Name}.png");
|
||||
D2D1TestRunner.RunAndCompareShader(in shader, 1280, 720, $"{typeof(T).Name}.png", $"{typeof(T).Name}.png");
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする