#https://www.shadertoy.com/view/MlfXRS

pixels = W:1024 H:1024

x = from -512 to 511 W
y = from -512 to 511 H

px = x + y
py = x + y
pz = x + y
pw = 2.0*y

k = exp2(17)
pt = px
px = py*0.5
py = pz*0.5
pz = pw*0.5
pw = pt*0.5
pw = -2.0*floor(py)
py = py + pw
pz = pz + pw
r = px/k
g = py/k
b = pz/k

k = exp2(16)
pt = px
px = py*0.5
py = pz*0.5
pz = pw*0.5
pw = pt*0.5
pw = -2.0*floor(py)
py = py + pw
pz = pz + pw
r = r + px/k
g = g + py/k
b = b = pz/k

k = exp2(15)
pt = px
px = py*0.5
py = pz*0.5
pz = pw*0.5
pw = pt*0.5
pw = -2.0*floor(py)
py = py + pw
pz = pz + pw
r = r + px/k
g = g + py/k
b = b = pz/k

k = exp2(14)
pt = px
px = py*0.5
py = pz*0.5
pz = pw*0.5
pw = pt*0.5
pw = -2.0*floor(py)
py = py + pw
pz = pz + pw
r = r + px/k
g = g + py/k
b = b = pz/k

k = exp2(13)
pt = px
px = py*0.5
py = pz*0.5
pz = pw*0.5
pw = pt*0.5
pw = -2.0*floor(py)
py = py + pw
pz = pz + pw
r = r + px/k
g = g + py/k
b = b = pz/k

k = exp2(12)
pt = px
px = py*0.5
py = pz*0.5
pz = pw*0.5
pw = pt*0.5
pw = -2.0*floor(py)
py = py + pw
pz = pz + pw
r = r + px/k
g = g + py/k
b = b = pz/k

k = exp2(11)
pt = px
px = py*0.5
py = pz*0.5
pz = pw*0.5
pw = pt*0.5
pw = -2.0*floor(py)
py = py + pw
pz = pz + pw
r = r + px/k
g = g + py/k
b = b = pz/k

k = exp2(10)
pt = px
px = py*0.5
py = pz*0.5
pz = pw*0.5
pw = pt*0.5
pw = -2.0*floor(py)
py = py + pw
pz = pz + pw
r = r + px/k
g = g + py/k
b = b = pz/k

k = exp2(9)
pt = px
px = py*0.5
py = pz*0.5
pz = pw*0.5
pw = pt*0.5
pw = -2.0*floor(py)
py = py + pw
pz = pz + pw
r = r + px/k
g = g + py/k
b = b = pz/k

k = exp2(8)
pt = px
px = py*0.5
py = pz*0.5
pz = pw*0.5
pw = pt*0.5
pw = -2.0*floor(py)
py = py + pw
pz = pz + pw
r = r + px/k
g = g + py/k
b = b = pz/k

k = exp2(7)
pt = px
px = py*0.5
py = pz*0.5
pz = pw*0.5
pw = pt*0.5
pw = -2.0*floor(py)
py = py + pw
pz = pz + pw
r = r + px/k
g = g + py/k
b = b = pz/k

k = exp2(6)
pt = px
px = py*0.5
py = pz*0.5
pz = pw*0.5
pw = pt*0.5
pw = -2.0*floor(py)
py = py + pw
pz = pz + pw
r = r + px/k
g = g + py/k
b = b = pz/k

k = exp2(5)
pt = px
px = py*0.5
py = pz*0.5
pz = pw*0.5
pw = pt*0.5
pw = -2.0*floor(py)
py = py + pw
pz = pz + pw
r = r + px/k
g = g + py/k
b = b = pz/k

k = exp2(4)
pt = px
px = py*0.5
py = pz*0.5
pz = pw*0.5
pw = pt*0.5
pw = -2.0*floor(py)
py = py + pw
pz = pz + pw
r = r + px/k
g = g + py/k
b = b = pz/k

k = exp2(3)
pt = px
px = py*0.5
py = pz*0.5
pz = pw*0.5
pw = pt*0.5
pw = -2.0*floor(py)
py = py + pw
pz = pz + pw
r = r + px/k
g = g + py/k
b = b = pz/k

k = exp2(2)
pt = px
px = py*0.5
py = pz*0.5
pz = pw*0.5
pw = pt*0.5
pw = -2.0*floor(py)
py = py + pw
pz = pz + pw
r = r + px/k
g = g + py/k
b = b = pz/k

k = exp2(1)
pt = px
px = py*0.5
py = pz*0.5
pz = pw*0.5
pw = pt*0.5
pw = -2.0*floor(py)
py = py + pw
pz = pz + pw
r = r + px/k
g = g + py/k
b = b = pz/k