scale) { float4 z = float4(z0, 1.0); for (int n = 0; n < 4; n++) { z = abs(z); if (z.x < z.y) z.xy = z.yx; if (z.x < z.z) z.xz = z.zx; if (z.y < z.z) z.yz = z.zy; z *= scale; z.xyz -= offset * (scale - 1.0); if (z.z < -0.5 * offset.z * (scale - 1.0)) z.z += offset.z * (scale - 1.0); } return (length(max(abs(z.xyz) - float3(1.0, 1.0, 1.0), 0.0)) - 0.05) / z.w; } // 2Dͷճసߦྻͷੜ float2x2 rotate(in float a) { float s = sin(a), c = cos(a); return float2x2(c, s, -s, c); } // ճస fold // https://www.shadertoy.com/view/Mlf3Wj float2 foldRotate(in float2 p, in float s) { float a = PI / s - atan2(p.x, p.y); float n = PI2 / s; a = floor(a / n) * n; p = mul(rotate(a), p); return p; } inline float DistanceFunction(float3 pos) { // ճసfoldͷద༻ pos.yx = foldRotate(pos.yx, _MengerFold); return dMenger(pos, _MengerOffset, _MengerScale); } Θ͔ͣߦͷίʔυͰෳࡶͳܗঢ়ΛఆٛͰ͖ͨʂ .FOHFS4QPOHF GPME3PUBUF