Welcome to Fractal Forums

Fractal Math, Chaos Theory & Research => (new) Theories & Research => Topic started by: DarkBeam on February 05, 2015, 06:35:41 PM




Title: Infinite staircase DE
Post by: DarkBeam on February 05, 2015, 06:35:41 PM
 ;D Yeah this is totally crazy but fun result, a helicoidal staircase that goes on infinitely :alien:

Code:
// valid for thickness << abs hstep, and hstep must be < 0
u = atan2(y,x); v = sqrt(x*x+y*y);
h2 = Hstep/2; h3 = n*Hstep;
split(u * n / twopi,intpu,fracpu);
u = fracpu *twopi/n;
z = (z-intpu*Hstep);
split(z/h3,intpz,fracpz);
z = z-intpz*h3;
DE = -u;
if (u-h2 > -z) DE = z-h2;
else if (u+h2 < -z) DE = z+h2;
DE = abs(DE) - Thick;
v = abs(v - Position);
v = abs(v - Wstep);
DE = max(DE,v);

Shown here together with his best friend, the infinite checkerboard :D

(http://i.imgur.com/M6qLpfJ.jpg)

Oh my ;)


Title: Re: Infinite staircase DE
Post by: knighty on February 05, 2015, 07:52:34 PM
Niiice!
:thumbsup1:


Title: Re: Infinite staircase DE
Post by: eiffie on February 05, 2015, 10:44:06 PM
Nice formula and render!


Title: Re: Infinite staircase DE
Post by: DarkBeam on February 06, 2015, 12:41:37 AM
Oh I am very honored, masters of raytracing :embarrass:
Thanks a lot!
Just hoping I transcribed correctly, 2 days of fight to finally reveal it :)


Title: Re: Infinite staircase DE
Post by: cKleinhuis on February 06, 2015, 12:51:54 AM
nice, tststs no shadertoy implementation? and beside, how does this de behave when hybridised with another de ?  :D hehe


Title: Re: Infinite staircase DE
Post by: DarkBeam on February 07, 2015, 10:55:58 AM
Forgot to tell ...

1. Formula is approximated! If thickness is big, some cuts will be shown, the trouble will be evident for big N values probably.

2. Hstep must be < 0

:)


Title: Re: Infinite staircase DE
Post by: subblue on February 17, 2015, 09:24:14 PM
Very interesting!
Can you explain some of the terms of the algorithm, for instance how are
split(.., .., ..), intpu, fracpu, intpz, fracpz defined?


Title: Re: Infinite staircase DE
Post by: DarkBeam on February 17, 2015, 10:02:55 PM
Split should ... split a number into its int and fractional part:

Split(5.844,a,b) -> a=5 and b=0.844 :)

Please try to implement. I don't know if I copied right...


Title: Re: Infinite staircase DE
Post by: TruthSerum on May 23, 2015, 10:17:07 PM
Here it is in GLSL:

Code:
void split(float x, inout float a, inout float b) {
    a = floor(x);
    b = fract(x);
}

float map(vec3 p) {
    float x=p.x, y=p.z, z=p.y;
    float u, v, h2, h3, n=8.0;
    float intpu, fracpu;
    float intpz, fracpz;
    float DE;
    float Thick=0.5, Position=0.5;
    float Hstep=-1.0, Wstep=1.0;
    float twopi = 6.28318530718;
   
    // valid for thickness << abs hstep, and hstep must be < 0
    u = atan(y,x); v = sqrt(x*x+y*y);
    h2 = Hstep/2.0; h3 = n*Hstep;
    split(u * n / twopi,intpu,fracpu);
    u = fracpu *twopi/n;
    z = (z-intpu*Hstep);
    split(z/h3,intpz,fracpz);
    z = z-intpz*h3;
    DE = -u;
    if (u-h2 > -z) DE = z-h2;
    else if (u+h2 < -z) DE = z+h2;
    DE = abs(DE) - Thick;
    v = abs(v - Position);
    v = abs(v - Wstep);
    DE = max(DE,v);
    return DE;
}

Here is how I tried (and failed) to trace it:

Code:
float trace(vec3 o, vec3 r) {
    float t = 0.0;
    for (int i = 0; i < 64; ++i) {
        float d = map(o + r * t);
        if (abs(d)<3.5) break;
        t += d * 0.08;
    }
    return t;
}

Very blocky results:

(http://i.imgur.com/7avsZTj.png)


Title: Re: Infinite staircase DE
Post by: DarkBeam on May 24, 2015, 11:15:31 AM
Thinking... :D
Instead of floor and frac what if you use

Void split(float x, inout float a, inout float b) {
    a = round(x);
    b = x-a;
}

Try also thickness 0.1 position 2.0

:)

Formula isn't perfect for all combinations but should work normally. Thanks for trying


Title: Re: Infinite staircase DE
Post by: TruthSerum on May 24, 2015, 01:47:26 PM
I tried it with these parameter changes, but I could not improve the result  :-\

FYI GLSL has only floor/fract, but not round. I implemented:

Code:
float round(float x) {
    return floor(x + 0.5);
}


Title: Re: Infinite staircase DE
Post by: DarkBeam on May 25, 2015, 12:08:56 AM
Too bad I cannot help further at this time. I am sorry. :sad1:


Title: Re: Infinite staircase DE
Post by: visual.bermarte on May 26, 2015, 05:37:38 PM
Not perfect but not bad neither :)
(http://orig13.deviantart.net/e727/f/2015/146/7/e/staircase_by_bermarte-d8utgue.jpg)


Title: Re: Infinite staircase DE
Post by: TruthSerum on May 26, 2015, 05:58:22 PM
Now to compute normals :)


Title: Re: Infinite staircase DE
Post by: DarkBeam on May 27, 2015, 12:31:28 PM
The problem is I don't remember exactly all the details now and assembly uses some different funcs. So try to disassemble the m3f ;)
The mb3d function has perfect normals and all actually. (see 1st post)


Title: Re: Infinite staircase DE
Post by: visual.bermarte on June 01, 2015, 03:00:09 AM
It goes a little bit better using
Code:
a=sign(x)*floor(abs(x)+0.5);