public void Execute(ThreadIds ids) { int offset = ids.X + ids.Y * 1; float pow = Hlsl.Pow(B[offset], 2); // 9 B[offset] = Sigmoid(pow); // 0.9998766 }
/// <inheritdoc/> 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); }
void Kernel(ThreadIds id) { int offset = id.X + id.Y * 1; float pow = Hlsl.Pow(xBuffer[offset], 2); // 9 xBuffer[offset] = Sigmoid(pow); // 0.9998766 }
/// <inheritdoc/> public float4 Execute() { float2 uv = (ThreadIds.XY - (float2)DispatchSize.XY * 0.5f) / DispatchSize.Y; float3 col = 0; float t = time * 0.3f; for (float i = 0.0f; i <= 1.0f; i += 1.0f / NumberOfLayers) { float d = Hlsl.Frac(i + t); float s = Hlsl.Lerp(5.0f, 0.5f, d); float f = d * Hlsl.SmoothStep(1.0f, 0.9f, d); col += Tex(new float3(uv.X * s, uv.Y * s, i * 4.0f)).XYZ *f; } col /= NumberOfLayers; col *= new float3(2, 1.0f, 2.0f); col = Hlsl.Pow(col, 0.5f); return(new(col.X, col.Y, col.Z, 1.0f)); }
// Various distance metrics. private static float Distance(Float2 p) { if (SHAPE == 0) { return(Hlsl.Length(p)); } else { p = Hlsl.Abs(p); } switch (SHAPE) { case 1: return(Hlsl.Max(Hlsl.Length(p), (p.X + p.Y) * 0.7071f + 0.015f)); case 2: return(Hlsl.Max((p.X + p.Y) * 0.7071f, Hlsl.Max(p.X, p.Y))); case 3: return(Hlsl.Pow(Hlsl.Dot(Hlsl.Pow(p, 3), 1), 1.0f / 3.0f)); default: return((p.X + p.Y) * 0.7071f); } }