7ファイル変更
+499
-6
検索条件に一致するファイルはありません
@@ -17,7 +17,9 @@ namespace ComputeSharp.SwapChain
|
||||
new SwapChainApplication<MengerJourney>(static (texture, time) => new(texture, (float)time.TotalSeconds)),
|
||||
new SwapChainApplication<Octagrams>(static (texture, time) => new(texture, (float)time.TotalSeconds)),
|
||||
new SwapChainApplication<ProteanClouds>(static (texture, time) => new(texture, (float)time.TotalSeconds)),
|
||||
new SwapChainApplication<ExtrudedTruchetPattern>(static (texture, time) => new(texture, (float)time.TotalSeconds))
|
||||
new SwapChainApplication<ExtrudedTruchetPattern>(static (texture, time) => new(texture, (float)time.TotalSeconds)),
|
||||
new SwapChainApplication<PyramidPattern>(static (texture, time) => new(texture, (float)time.TotalSeconds)),
|
||||
new SwapChainApplication<TriangleGridContouring>(static (texture, time) => new(texture, (float)time.TotalSeconds))
|
||||
};
|
||||
|
||||
static void Main()
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
namespace ComputeSharp.SwapChain.Shaders
|
||||
{
|
||||
/// <summary>
|
||||
/// An offset grid of square-based pyramids whose tips have been offset according to an underlying directional noise field.
|
||||
/// The faux lighting is provided via bump mapping. No raymarching was harmed during the making of this example.
|
||||
/// Ported from <see href="https://www.shadertoy.com/view/wlscWX"/>.
|
||||
/// <para>Created by Shane.</para>
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
internal readonly partial struct PyramidPattern : IComputeShader
|
||||
{
|
||||
/// <summary>
|
||||
/// The target texture.
|
||||
/// </summary>
|
||||
public readonly IReadWriteTexture2D<Float4> texture;
|
||||
|
||||
/// <summary>
|
||||
/// The current time Hlsl.Since the start of the application.
|
||||
/// </summary>
|
||||
public readonly float time;
|
||||
|
||||
// Standard 2D rotation formula.
|
||||
private static Float2x2 Rotate2x2(in float a)
|
||||
{
|
||||
float c = Hlsl.Cos(a), s = Hlsl.Sin(a);
|
||||
|
||||
return new(c, -s, s, c);
|
||||
}
|
||||
|
||||
// IQ's Float2 to float hash.
|
||||
private static float Hash21(Float2 p)
|
||||
{
|
||||
return Hlsl.Frac(Hlsl.Sin(Hlsl.Dot(p, new Float2(27.619f, 57.583f))) * 43758.5453f);
|
||||
}
|
||||
|
||||
// Float2 to Float2 hash.
|
||||
private static Float2 Hash22B(Float2 p)
|
||||
{
|
||||
float n = Hlsl.Sin(Hlsl.Dot(p, new Float2(41, 289)));
|
||||
|
||||
return Hlsl.Frac(new Float2(262144, 32768) * n) * 2.0f - 1.0f;
|
||||
}
|
||||
|
||||
// Based on IQ's gradient noise formula.
|
||||
private static float N2D3G(Float2 p)
|
||||
{
|
||||
Float2 i = Hlsl.Floor(p);
|
||||
|
||||
p -= i;
|
||||
|
||||
Float4 v = default;
|
||||
|
||||
v.X = Hlsl.Dot(Hash22B(i), p);
|
||||
v.Y = Hlsl.Dot(Hash22B(i + Float2.UnitX), p - Float2.UnitX);
|
||||
v.Z = Hlsl.Dot(Hash22B(i + Float2.UnitY), p - Float2.UnitY);
|
||||
v.W = Hlsl.Dot(Hash22B(i + 1.0f), p - 1.0f);
|
||||
|
||||
p = p * p * (3.0f - 2.0f * p);
|
||||
|
||||
return Hlsl.Lerp(Hlsl.Lerp(v.X, v.Y, p.X), Hlsl.Lerp(v.Z, v.W, p.X), p.Y);
|
||||
}
|
||||
|
||||
// Two layers of noise.
|
||||
private static float FBM(Float2 p)
|
||||
{
|
||||
return N2D3G(p) * 0.66f + N2D3G(p * 2.0f) * 0.34f;
|
||||
}
|
||||
|
||||
// HLSL mod from GLSL
|
||||
private static float Mod(float x, float y)
|
||||
{
|
||||
return x - y * Hlsl.Floor(x / y);
|
||||
}
|
||||
|
||||
private float BMap(Float2 p)
|
||||
{
|
||||
p = Hlsl.Mul(p, Rotate2x2(-3.14159f / 5.0f));
|
||||
|
||||
if (Mod(Hlsl.Floor(p.Y), 2.0f) < 0.5f)
|
||||
{
|
||||
p.X += 0.5f;
|
||||
}
|
||||
|
||||
Float2 ip = Hlsl.Floor(p);
|
||||
|
||||
p -= ip + 0.5f;
|
||||
|
||||
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;
|
||||
|
||||
if (p.X < offs.X) p.X = 1.0f - (p.X + 0.5f) / Hlsl.Abs(offs.X + 0.5f);
|
||||
else p.X = (p.X - offs.X) / (0.5f - offs.X);
|
||||
|
||||
if (p.Y < offs.Y) p.Y = 1.0f - (p.Y + 0.5f) / Hlsl.Abs(offs.Y + 0.5f);
|
||||
else p.Y = (p.Y - offs.Y) / (0.5f - offs.Y);
|
||||
|
||||
return 1.0f - Hlsl.Max(p.X, p.Y);
|
||||
}
|
||||
|
||||
|
||||
// Standard function-based bump mapping function, with an edge value included for good measure
|
||||
private Float3 DoBumpMap(in Float2 p, in Float3 n, float bumpfactor, ref float edge)
|
||||
{
|
||||
Float2 e = new(0.025f, 0);
|
||||
|
||||
float f = BMap(p);
|
||||
float fx = BMap(p - e.XY);
|
||||
float fy = BMap(p - e.YX);
|
||||
float fx2 = BMap(p + e.XY);
|
||||
float fy2 = BMap(p + e.YX);
|
||||
|
||||
Float3 grad = (new Float3(fx - fx2, fy - fx2, 0)) / e.X / 2.0f;
|
||||
|
||||
edge = Hlsl.Length(new Float2(fx, fy) + new Float2(fx2, fy2) - f * 2.0f);
|
||||
edge = Hlsl.SmoothStep(0.0f, 1.0f, edge / e.X);
|
||||
|
||||
grad -= n * Hlsl.Dot(n, grad);
|
||||
|
||||
return Hlsl.Normalize(n + grad * bumpfactor);
|
||||
}
|
||||
|
||||
|
||||
// A hatch-like algorithm, or a stipple... or some kind of textured pattern
|
||||
private float DoHatch(Float2 p, float res)
|
||||
{
|
||||
p *= res / 16.0f;
|
||||
|
||||
float hatch = Hlsl.Clamp(Hlsl.Sin((p.X - p.Y) * 3.14159f * 200.0f) * 2.0f + 0.5f, 0.0f, 1.0f);
|
||||
|
||||
float hRnd = Hash21(Hlsl.Floor(p * 6.0f) + 0.73f);
|
||||
if (hRnd > 0.66f) hatch = hRnd;
|
||||
|
||||
return hatch;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Execute()
|
||||
{
|
||||
Int2 coordinate = new(ThreadIds.X, DispatchSize.Y - ThreadIds.Y);
|
||||
float iRes = Hlsl.Min(DispatchSize.Y, 800.0f);
|
||||
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, time / 2.0f);
|
||||
Float2 oP = p;
|
||||
float m = BMap(p);
|
||||
Float3 n = new(0, 0, -1);
|
||||
float
|
||||
edge = 0.0f,
|
||||
bumpFactor = 0.25f;
|
||||
|
||||
n = DoBumpMap(p, n, bumpFactor, ref edge);
|
||||
|
||||
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 = Hlsl.Pow(diff, 4.0f);
|
||||
|
||||
float spec = Hlsl.Pow(Hlsl.Max(Hlsl.Dot(Hlsl.Reflect(-ld, n), -rd), 0.0f), 16.0f);
|
||||
float fre = Hlsl.Min(Hlsl.Pow(Hlsl.Max(1.0f + Hlsl.Dot(n, rd), 0.0f), 4.0f), 3.0f);
|
||||
Float3 col = 0.15f * (diff + 0.251f + spec * new Float3(1, 0.7f, 0.3f) * 9.0f + fre * new Float3(0.1f, 0.3f, 1) * 12.0f);
|
||||
float rf = Hlsl.SmoothStep(0.0f, 0.35f, BMap(Hlsl.Reflect(rd, n).XY * 2.0f) * FBM(Hlsl.Reflect(rd, n).XY * 3.0f) + 0.1f);
|
||||
|
||||
col += col * col * rf * rf * new Float3(1, 0.1f, 0.1f) * 15.0f;
|
||||
|
||||
float shade = m * 0.83f + 0.17f;
|
||||
|
||||
col *= shade;
|
||||
col *= 1.0f - edge * 0.8f;
|
||||
|
||||
float hatch = DoHatch(oP / gSc, iRes);
|
||||
|
||||
col *= hatch * 0.5f + 0.7f;
|
||||
|
||||
Float4 color = new(Hlsl.Sqrt(Hlsl.Max(col, 0.0f)), 1);
|
||||
|
||||
texture[ThreadIds.XY] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
namespace ComputeSharp.SwapChain.Shaders
|
||||
{
|
||||
/// <summary>
|
||||
/// Utilizing a 2D simplex grid to construct the isolines of a noise function.
|
||||
/// Ported from <see href="https://www.shadertoy.com/view/WtfGDX"/>.
|
||||
/// <para>Created by Shane.</para>
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
internal readonly partial struct TriangleGridContouring : IComputeShader
|
||||
{
|
||||
/// <summary>
|
||||
/// The target texture.
|
||||
/// </summary>
|
||||
public readonly IReadWriteTexture2D<Float4> texture;
|
||||
|
||||
/// <summary>
|
||||
/// The current time Hlsl.Since the start of the application.
|
||||
/// </summary>
|
||||
public readonly float time;
|
||||
|
||||
// Standard 2D rotation formula.
|
||||
private static Float2x2 Rotate2x2(in float a)
|
||||
{
|
||||
float c = Hlsl.Cos(a), s = Hlsl.Sin(a);
|
||||
|
||||
return new(c, -s, s, c);
|
||||
}
|
||||
|
||||
// IQ's Float2 to float hash.
|
||||
private static float Hash21(Float2 p)
|
||||
{
|
||||
return Hlsl.Frac(Hlsl.Sin(Hlsl.Dot(p, new Float2(27.619f, 57.583f))) * 43758.5453f);
|
||||
}
|
||||
|
||||
// Float2 to Float2 hash.
|
||||
private Float2 Hash22(Float2 p)
|
||||
{
|
||||
float n = Hlsl.Sin(Hlsl.Dot(p, new Float2(41, 289)));
|
||||
|
||||
p = Hlsl.Frac(new Float2(262144, 32768) * n);
|
||||
|
||||
return Hlsl.Sin(p * 6.2831853f + time);
|
||||
}
|
||||
|
||||
// Based on IQ's gradient noise formula.
|
||||
private float N2D3G(Float2 p)
|
||||
{
|
||||
Float2 i = Hlsl.Floor(p);
|
||||
|
||||
p -= i;
|
||||
|
||||
Float4 v = default;
|
||||
|
||||
v.X = Hlsl.Dot(Hash22(i), p);
|
||||
v.Y = Hlsl.Dot(Hash22(i + Float2.UnitX), p - Float2.UnitX);
|
||||
v.Z = Hlsl.Dot(Hash22(i + Float2.UnitY), p - Float2.UnitY);
|
||||
v.W = Hlsl.Dot(Hash22(i + 1.0f), p - 1.0f);
|
||||
|
||||
p = p * p * p * (p * (p * 6.0f - 15.0f) + 10.0f);
|
||||
|
||||
return Hlsl.Lerp(Hlsl.Lerp(v.X, v.Y, p.X), Hlsl.Lerp(v.Z, v.W, p.X), p.Y);
|
||||
}
|
||||
|
||||
|
||||
// The isofunction. Just a Hlsl.Single noise function, but it can be more elaborate.
|
||||
private float IsoFunction(in Float2 p)
|
||||
{
|
||||
return N2D3G(p / 4.0f + 0.07f);
|
||||
}
|
||||
|
||||
// Unsigned distance to the segment joining "a" and "b".
|
||||
private static float DistLine(Float2 a, Float2 b)
|
||||
{
|
||||
b = a - b;
|
||||
|
||||
float h = Hlsl.Clamp(Hlsl.Dot(a, b) / Hlsl.Dot(b, b), 0.0f, 1.0f);
|
||||
|
||||
return Hlsl.Length(a - b * h);
|
||||
}
|
||||
|
||||
// Based on IQ's signed distance to the segment joining "a" and "b".
|
||||
private static float distEdge(Float2 a, Float2 b)
|
||||
{
|
||||
return Hlsl.Dot((a + b) * 0.5f, Hlsl.Normalize((b - a).YX * new Float2(-1, 1)));
|
||||
}
|
||||
|
||||
// Interpolating along the edge connecting vertices v1 and v2 with respect to the isovalue.
|
||||
private static Float2 Interpolate(in Float2 p1, in Float2 p2, float v1, float v2, float isovalue)
|
||||
{
|
||||
return Hlsl.Lerp(p1, p2, (isovalue - v1) / (v2 - v1) * 0.75f + 0.25f / 2.0f);
|
||||
}
|
||||
|
||||
// Isoline function.
|
||||
private static int IsoLine(
|
||||
Float3 n3,
|
||||
Float2 ip0,
|
||||
Float2 ip1,
|
||||
Float2 ip2,
|
||||
float isovalue,
|
||||
float i,
|
||||
ref Float2 p0,
|
||||
ref Float2 p1)
|
||||
{
|
||||
p0 = 1e5f;
|
||||
p1 = 1e5f;
|
||||
|
||||
int iTh = 0;
|
||||
|
||||
if (n3.X > isovalue) iTh += 4;
|
||||
if (n3.Y > isovalue) iTh += 2;
|
||||
if (n3.Z > isovalue) iTh += 1;
|
||||
|
||||
if (iTh == 1 || iTh == 6)
|
||||
{
|
||||
p0 = Interpolate(ip1, ip2, n3.Y, n3.Z, isovalue);
|
||||
p1 = Interpolate(ip2, ip0, n3.Z, n3.X, isovalue);
|
||||
|
||||
}
|
||||
else if (iTh == 2 || iTh == 5)
|
||||
{
|
||||
p0 = Interpolate(ip0, ip1, n3.X, n3.Y, isovalue);
|
||||
p1 = Interpolate(ip1, ip2, n3.Y, n3.Z, isovalue);
|
||||
|
||||
}
|
||||
else if (iTh == 3 || iTh == 4)
|
||||
{
|
||||
p0 = Interpolate(ip0, ip1, n3.X, n3.Y, isovalue);
|
||||
p1 = Interpolate(ip2, ip0, n3.Z, n3.X, isovalue);
|
||||
}
|
||||
|
||||
if (iTh >= 4 && iTh <= 6)
|
||||
{
|
||||
Float2 tmp = p0;
|
||||
|
||||
p0 = p1;
|
||||
p1 = tmp;
|
||||
}
|
||||
|
||||
if (i == 0.0f)
|
||||
{
|
||||
Float2 tmp = p0;
|
||||
|
||||
p0 = p1;
|
||||
p1 = tmp;
|
||||
}
|
||||
|
||||
return iTh;
|
||||
}
|
||||
|
||||
private Float3 SimplexContour(Float2 p)
|
||||
{
|
||||
const float gSc = 8.0f;
|
||||
|
||||
p *= gSc;
|
||||
|
||||
Float2 oP = p;
|
||||
|
||||
p += new Float2(N2D3G(p * 3.5f), N2D3G(p * 3.5f + 7.3f)) * 0.015f;
|
||||
|
||||
Float2 s = Hlsl.Floor(p + (p.X + p.Y) * 0.36602540378f);
|
||||
|
||||
p -= s - (s.X + s.Y) * 0.211324865f;
|
||||
|
||||
float i = p.X < p.Y ? 1.0f : 0.0f;
|
||||
Float2
|
||||
ioffs = new(1.0f - i, i),
|
||||
ip0 = 0,
|
||||
ip1 = ioffs - 0.2113248654f,
|
||||
ip2 = 0.577350269f,
|
||||
ctr = (ip0 + ip1 + ip2) / 3.0f;
|
||||
|
||||
ip0 -= ctr;
|
||||
ip1 -= ctr;
|
||||
ip2 -= ctr;
|
||||
p -= ctr;
|
||||
|
||||
Float3 n3 = default;
|
||||
|
||||
n3.X = IsoFunction(s);
|
||||
n3.Y = IsoFunction(s + ioffs);
|
||||
n3.Z = IsoFunction(s + 1.0f);
|
||||
|
||||
float
|
||||
d = 1e5f,
|
||||
d2 = 1e5f,
|
||||
d3 = 1e5f,
|
||||
d4 = 1e5f,
|
||||
d5 = 1e5f;
|
||||
|
||||
float isovalue = 0;
|
||||
Float2 p0 = default, p1 = default;
|
||||
int iTh = IsoLine(n3, ip0, ip1, ip2, isovalue, i, ref p0, ref p1);
|
||||
|
||||
d = Hlsl.Min(d, distEdge(p - p0, p - p1));
|
||||
|
||||
if (iTh == 7)
|
||||
{
|
||||
d = 0;
|
||||
}
|
||||
|
||||
d3 = Hlsl.Min(d3, DistLine((p - p0), (p - p1)));
|
||||
d4 = Hlsl.Min(d4, Hlsl.Min(Hlsl.Length(p - p0), Hlsl.Length(p - p1)));
|
||||
|
||||
float tri = Hlsl.Min(Hlsl.Min(DistLine(p - ip0, p - ip1), DistLine(p - ip1, p - ip2)), DistLine(p - ip2, p - ip0));
|
||||
|
||||
d5 = Hlsl.Min(d5, tri);
|
||||
d5 = Hlsl.Min(d5, Hlsl.Length(p) - 0.02f);
|
||||
isovalue = -0.15f;
|
||||
|
||||
int iTh2 = IsoLine(n3, ip0, ip1, ip2, isovalue, i, ref p0, ref p1);
|
||||
|
||||
d2 = Hlsl.Min(d2, distEdge(p - p0, p - p1));
|
||||
|
||||
float oldD2 = d2;
|
||||
|
||||
if (iTh2 == 7) d2 = 0.0f;
|
||||
if (iTh == 7) d2 = 1e5f;
|
||||
|
||||
d2 = Hlsl.Max(d2, -d);
|
||||
d3 = Hlsl.Min(d3, DistLine((p - p0), (p - p1)));
|
||||
d4 = Hlsl.Min(d4, Hlsl.Min(Hlsl.Length(p - p0), Hlsl.Length(p - p1)));
|
||||
d4 -= 0.075f;
|
||||
d3 -= 0.0125f;
|
||||
d /= gSc;
|
||||
d2 /= gSc;
|
||||
d3 /= gSc;
|
||||
d4 /= gSc;
|
||||
d5 /= gSc;
|
||||
|
||||
Float3 col = new(1, 0.85f, 0.6f);
|
||||
float sf = 0.004f;
|
||||
|
||||
if (d > 0.0f && d2 > 0.0f) col = new Float3(1, 1.8f, 3) * 0.45f;
|
||||
if (d > 0.0f) col = Hlsl.Lerp(col, new Float3(1, 1.85f, 3) * 0.3f, (1.0f - Hlsl.SmoothStep(0.0f, sf, d2 - 0.012f)));
|
||||
|
||||
col = Hlsl.Lerp(col, new Float3(1.1f, 0.85f, 0.6f), (1.0f - Hlsl.SmoothStep(0.0f, sf, d2)));
|
||||
col = Hlsl.Lerp(col, new Float3(1.5f, 0.9f, 0.6f) * 0.6f, (1.0f - Hlsl.SmoothStep(0.0f, sf, d - 0.012f)));
|
||||
col = Hlsl.Lerp(col, new Float3(1, 0.8f, 0.6f) * new Float3(0.7f, 1.0f, 0.75f) * 0.95f, (1.0f - Hlsl.SmoothStep(0.0f, sf, d)));
|
||||
|
||||
if (d2 > 0.0f) col *= (Hlsl.Abs(Hlsl.Dot(n3, Float3.One)) * 1.25f + 1.25f) / 2.0f;
|
||||
else col *= Hlsl.Max(2.0f - (Hlsl.Dot(n3, Float3.One) + 1.45f) / 1.25f, 0.0f);
|
||||
|
||||
float pat = Hlsl.Abs(Hlsl.Frac(tri * 12.5f + 0.4f) - 0.5f) * 2.0f;
|
||||
|
||||
col *= pat * 0.425f + 0.75f;
|
||||
col = Hlsl.Lerp(col, Float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sf, d5)) * 0.95f);
|
||||
col = Hlsl.Lerp(col, Float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sf, d3)));
|
||||
col = Hlsl.Lerp(col, Float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sf, d4)));
|
||||
col = Hlsl.Lerp(col, Float3.One, (1.0f - Hlsl.SmoothStep(0.0f, sf, d4 + 0.005f)));
|
||||
|
||||
Float2 q = oP * 1.5f;
|
||||
|
||||
col = Hlsl.Min(col, 1.0f);
|
||||
|
||||
float gr = Hlsl.Sqrt(Hlsl.Dot(col, new Float3(0.299f, 0.587f, 0.114f))) * 1.25f;
|
||||
float ns = (N2D3G(q * 4.0f * new Float2(1.0f / 3.0f, 3)) * 0.64f + N2D3G(q * 8.0f * new Float2(1.0f / 3.0f, 3)) * 0.34f) * 0.5f + 0.5f;
|
||||
|
||||
ns = gr - ns;
|
||||
q = Hlsl.Mul(q, Rotate2x2(3.14159f / 3.0f));
|
||||
|
||||
float ns2 = (N2D3G(q * 4.0f * new Float2(1.0f / 3.0f, 3)) * 0.64f + N2D3G(q * 8.0f * new Float2(1.0f / 3.0f, 3)) * 0.34f) * 0.5f + 0.5f;
|
||||
|
||||
ns2 = gr - ns2;
|
||||
ns = Hlsl.SmoothStep(0.0f, 1.0f, Hlsl.Min(ns, ns2));
|
||||
col = Hlsl.Lerp(col, col * (ns + 0.35f), 0.4f);
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Execute()
|
||||
{
|
||||
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) * time / 16.0f;
|
||||
Float3 col = SimplexContour(p);
|
||||
|
||||
uv = coordinate / (Float2)DispatchSize.XY;
|
||||
col *= Hlsl.Pow(16.0f * uv.X * uv.Y * (1.0f - uv.X) * (1.0f - uv.Y), 0.0625f) + 0.1f;
|
||||
|
||||
Float4 color = new(Hlsl.Sqrt(Hlsl.Max(col, 0.0f)), 1);
|
||||
|
||||
texture[ThreadIds.XY] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
バイナリファイルは表示されません。
|
変更後 幅: | 高さ: | サイズ: 1.5 MiB |
バイナリファイルは表示されません。
|
変更後 幅: | 高さ: | サイズ: 1.6 MiB |
@@ -34,13 +34,12 @@
|
||||
<Compile Include="..\..\samples\ComputeSharp.SwapChain\Shaders\TwoTiledTruchet.cs" Link="Shaders\TwoTiledTruchet.cs" />
|
||||
<Compile Include="..\..\samples\ComputeSharp.SwapChain\Shaders\Octagrams.cs" Link="Shaders\Octagrams.cs" />
|
||||
<Compile Include="..\..\samples\ComputeSharp.SwapChain\Shaders\ProteanClouds.cs" Link="Shaders\ProteanClouds.cs" />
|
||||
<Compile Include="..\..\samples\ComputeSharp.SwapChain\Shaders\PyramidPattern.cs" Link="Shaders\PyramidPattern.cs" />
|
||||
<Compile Include="..\..\samples\ComputeSharp.SwapChain\Shaders\TriangleGridContouring.cs" Link="Shaders\TriangleGridContouring.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\..\samples\ComputeSharp.ImageProcessing\city.jpg" Link="Imaging\city.jpg" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Assets\ColorfulInfinity.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
@@ -60,11 +59,20 @@
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Assets\Octagrams.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Assets\ProteanClouds.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Assets\PyramidPattern.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Assets\TriangleGridContouring.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Texture2DTests.Pixels.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Texture2DTests.Pixels.g.cs</LastGenOutput>
|
||||
|
||||
@@ -65,6 +65,20 @@ namespace ComputeSharp.Tests
|
||||
RunAndCompareShader(device, static texture => new ExtrudedTruchetPattern(texture, 0), 0.00011f);
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
public void PyramidPattern(Device device)
|
||||
{
|
||||
RunAndCompareShader(device, static texture => new PyramidPattern(texture, 0), 0.00021f);
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
public void TriangleGridContouring(Device device)
|
||||
{
|
||||
RunAndCompareShader(device, static texture => new TriangleGridContouring(texture, 0), 0.0006f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a given test for a specified shader.
|
||||
/// </summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする