Add parentheses for clarity where needed (IDE0048)
このコミットが含まれているのは:
1 親
553c7a4014
コミット
ce1097e7d9
47ファイル変更
+222
-198
検索条件に一致するファイルはありません
@@ -52,7 +52,7 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader<float4>
|
||||
|
||||
switch (SHAPE)
|
||||
{
|
||||
case 1: return Hlsl.Max(Hlsl.Length(p), (p.X + p.Y) * 0.7071f + 0.015f);
|
||||
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;
|
||||
@@ -62,7 +62,7 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader<float4>
|
||||
// GLSL's mod function
|
||||
private static float Mod(float x, float y)
|
||||
{
|
||||
return x - y * Hlsl.Floor(x / y);
|
||||
return x - (y * Hlsl.Floor(x / y));
|
||||
}
|
||||
|
||||
// A standard square grid 2D blobby Truchet routine: Render circles
|
||||
@@ -79,11 +79,11 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader<float4>
|
||||
|
||||
if (rnd < 0.5f) p.Y = -p.Y;
|
||||
|
||||
float d = Hlsl.Min(Distance(p - 0.5f * sc), Distance(p + 0.5f * sc)) - 0.5f * sc;
|
||||
float d = Hlsl.Min(Distance(p - (0.5f * sc)), Distance(p + (0.5f * sc))) - (0.5f * sc);
|
||||
|
||||
if (SHAPE == 4)
|
||||
{
|
||||
d += (0.5f - 0.5f / Hlsl.Sqrt(2.0f)) * sc;
|
||||
d += (0.5f - (0.5f / Hlsl.Sqrt(2.0f))) * sc;
|
||||
}
|
||||
|
||||
if (rnd < 0.5f) d = -d;
|
||||
@@ -100,18 +100,18 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader<float4>
|
||||
float fl = -p.Z;
|
||||
float obj = Truchet(p.XY);
|
||||
|
||||
obj = Hlsl.Max(obj, Hlsl.Abs(p.Z) - 0.125f) - Hlsl.SmoothStep(0.03f, 0.25f, -obj) * 0.1f;
|
||||
obj = Hlsl.Max(obj, Hlsl.Abs(p.Z) - 0.125f) - (Hlsl.SmoothStep(0.03f, 0.25f, -obj) * 0.1f);
|
||||
|
||||
float studs = 1e5f;
|
||||
const float sc = 0.5f;
|
||||
float2 q = p.XY + 0.5f * sc;
|
||||
float2 q = p.XY + (0.5f * sc);
|
||||
float2 iq = Hlsl.Floor(q / sc) + 0.5f;
|
||||
|
||||
q -= iq * sc;
|
||||
|
||||
if (Mod(iq.X + iq.Y, 2.0f) > 0.5f)
|
||||
{
|
||||
studs = Hlsl.Max(Hlsl.Length(q) - 0.1f * sc - 0.02f, Hlsl.Abs(p.Z) - 0.26f);
|
||||
studs = Hlsl.Max(Hlsl.Length(q) - (0.1f * sc) - 0.02f, Hlsl.Abs(p.Z) - 0.26f);
|
||||
}
|
||||
|
||||
objID = fl < obj && fl < studs ? 0 : obj < studs ? 1 : 2;
|
||||
@@ -136,7 +136,7 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader<float4>
|
||||
|
||||
for (int i = 0; i < iter; i++)
|
||||
{
|
||||
float d = M(ro + rd * t);
|
||||
float d = M(ro + (rd * t));
|
||||
|
||||
shade = Hlsl.Min(shade, k * d / t);
|
||||
t += Hlsl.Clamp(d, 0.01f, 0.25f);
|
||||
@@ -158,7 +158,7 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader<float4>
|
||||
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);
|
||||
float d = M(p + (n * hr));
|
||||
|
||||
occ += (hr - d) * sca;
|
||||
sca *= 0.7f;
|
||||
@@ -184,7 +184,7 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader<float4>
|
||||
public float4 Execute()
|
||||
{
|
||||
int2 coords = new(ThreadIds.X, DispatchSize.Y - ThreadIds.Y);
|
||||
float2 u = (coords - (float2)DispatchSize.XY * 0.5f) / DispatchSize.Y;
|
||||
float2 u = (coords - ((float2)DispatchSize.XY * 0.5f)) / DispatchSize.Y;
|
||||
float3 r = Hlsl.Normalize(new float3(u, 1));
|
||||
float3 o = new(0, time / 2.0f, -3);
|
||||
float3 l = o + new float3(0.25f, 0.25f, 2.0f);
|
||||
@@ -194,21 +194,21 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader<float4>
|
||||
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(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++)
|
||||
{
|
||||
d = M(o + r * t);
|
||||
d = M(o + (r * t));
|
||||
|
||||
if (Hlsl.Abs(d) < 0.001f) break;
|
||||
|
||||
t += d * 0.7f;
|
||||
glow += 0.2f / (1.0f + Hlsl.Abs(d) * 5.0f);
|
||||
glow += 0.2f / (1.0f + (Hlsl.Abs(d) * 5.0f));
|
||||
}
|
||||
|
||||
int gObjID = objID;
|
||||
float3 p = o + r * t;
|
||||
float3 p = o + (r * t);
|
||||
float3 n = Normal(p);
|
||||
float2 uv = p.XY;
|
||||
float sc = 0.5f;
|
||||
@@ -216,21 +216,21 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader<float4>
|
||||
|
||||
uv -= iuv * sc;
|
||||
|
||||
float2 uv2 = p.XY + 0.5f * sc;
|
||||
float2 uv2 = p.XY + (0.5f * sc);
|
||||
float2 iuv2 = Hlsl.Floor(uv2 / sc) + 0.5f;
|
||||
|
||||
uv2 -= iuv2 * sc;
|
||||
|
||||
float bord = Hlsl.Max(Hlsl.Abs(uv.X), Hlsl.Abs(uv.Y)) - 0.5f * sc;
|
||||
float bord = Hlsl.Max(Hlsl.Abs(uv.X), Hlsl.Abs(uv.Y)) - (0.5f * sc);
|
||||
|
||||
bord = Hlsl.Abs(bord) - 0.002f;
|
||||
d = Truchet(p.XY);
|
||||
|
||||
float lSc = 20.0f;
|
||||
float pat = (Hlsl.Abs(Hlsl.Frac((uv.X - uv.Y) * lSc - 0.5f) - 0.5f) * 2.0f - 0.5f) / lSc;
|
||||
float pat2 = (Hlsl.Abs(Hlsl.Frac((uv.X + uv.Y) * lSc + 0.5f) - 0.5f) * 2.0f - 0.5f) / lSc;
|
||||
float pat = ((Hlsl.Abs(Hlsl.Frac(((uv.X - uv.Y) * lSc) - 0.5f) - 0.5f) * 2.0f) - 0.5f) / lSc;
|
||||
float pat2 = ((Hlsl.Abs(Hlsl.Frac(((uv.X + uv.Y) * lSc) + 0.5f) - 0.5f) * 2.0f) - 0.5f) / lSc;
|
||||
float sf = Hlsl.Dot(Hlsl.Sin(p.XY - Hlsl.Cos(p.YX * 2.0f)), 0.5f);
|
||||
float sf2 = Hlsl.Dot(Hlsl.Sin(p.XY * 1.5f - Hlsl.Cos(p.YX * 3.0f)), 0.5f);
|
||||
float sf2 = Hlsl.Dot(Hlsl.Sin((p.XY * 1.5f) - Hlsl.Cos(p.YX * 3.0f)), 0.5f);
|
||||
float4 col1 = Hlsl.Lerp(new float4(1, 0.75f, 0.6f, 0), new float4(1, 0.85f, 0.65f, 0), Hlsl.SmoothStep(-0.5f, 0.5f, sf));
|
||||
float4 col2 = Hlsl.Lerp(new float4(0.4f, 0.7f, 1, 0), new float4(0.3f, 0.85f, 0.95f, 0), Hlsl.SmoothStep(-0.5f, 0.5f, sf2) * 0.5f);
|
||||
|
||||
@@ -283,13 +283,13 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader<float4>
|
||||
|
||||
ld /= lDist;
|
||||
|
||||
float at = 1.0f / (1.0f + lDist * lDist * 0.125f);
|
||||
float at = 1.0f / (1.0f + (lDist * lDist * 0.125f));
|
||||
float sh = SoftShadow(p, l, n, 8);
|
||||
float ao = CalculateAO(p, n);
|
||||
float df = Hlsl.Max(Hlsl.Dot(n, ld), 0);
|
||||
float sp = Hlsl.Pow(Hlsl.Max(Hlsl.Dot(Hlsl.Reflect(r, n), ld), 0), 32);
|
||||
|
||||
float4 c = oCol * (df * sh + sp * sh + 0.5f) * at * ao;
|
||||
float4 c = oCol * ((df * sh) + (sp * sh) + 0.5f) * at * ao;
|
||||
|
||||
c = Hlsl.Sqrt(Hlsl.Max(c, 0));
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする