POV-Ray : Newsgroups : povray.binaries.images : 'Accidental' isosurface Server Time
18 May 2024 03:16:19 EDT (-0400)
  'Accidental' isosurface (Message 11 to 20 of 68)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: clipka
Subject: Re: 'Accidental' isosurface
Date: 20 Nov 2009 08:10:49
Message: <4b069559$1@news.povray.org>
scott schrieb:

> Better?  There are still artifacts due to the discrete nature of the df3 
> file, but I'm working on it.

That's an interesting effect though. Looks like knitwear or the like.


Post a reply to this message

From: waggy
Subject: Re: 'Accidental' isosurface
Date: 20 Nov 2009 18:05:01
Message: <web.4b07204bce81d185f99d05c80@news.povray.org>
"scott" <sco### [at] scottcom> wrote:
> Better?  There are still artifacts due to the discrete nature of the df3
> file, but I'm working on it.
>
> Generating a df3 file from code outside of POV is not very hard.  And I just
> copied the formulas to generate the fractal from the websites referenced.

I modified the (illegal, but still renders) recursive function formulation
posted by Warp and managed to get a straight SDL isosurface.  This is the result
of six iterations.  The render time isn't too terribly bad if you can find a
good combination of accuracy and max_gradient.  Due to the object's fractal
nature, the reported maximum gradient doesn't help, though.

Shutdown Warning: The maximum gradient found was 1019075328.000, but
 max_gradient of the isosurface was set to 2048.000. The isosurface may contain
 holes! Adjust max_gradient to get a proper rendering of the isosurface.

-David


Post a reply to this message


Attachments:
Download 'mandelbulb8i6.015.png' (602 KB)

Preview of image 'mandelbulb8i6.015.png'
mandelbulb8i6.015.png


 

From: CShake
Subject: Re: 'Accidental' isosurface
Date: 20 Nov 2009 18:10:24
Message: <4b0721e0$1@news.povray.org>
waggy wrote:
> I modified the (illegal, but still renders) recursive function formulation
> posted by Warp and managed to get a straight SDL isosurface.  This is the result
> of six iterations.  The render time isn't too terribly bad if you can find a
> good combination of accuracy and max_gradient.  Due to the object's fractal
> nature, the reported maximum gradient doesn't help, though.
> 
> Shutdown Warning: The maximum gradient found was 1019075328.000, but
>  max_gradient of the isosurface was set to 2048.000. The isosurface may contain
>  holes! Adjust max_gradient to get a proper rendering of the isosurface.
> 
> -David
> 
> ------------------------------------------------------------------------
> 
Nice!
Now figure out how to zoom in to get all the fun details... ;)

Chris


Post a reply to this message

From: waggy
Subject: Re: 'Accidental' isosurface
Date: 20 Nov 2009 21:10:01
Message: <web.4b074bd3ce81d185f99d05c80@news.povray.org>
CShake wrote:
> Nice!
> Now figure out how to zoom in to get all the fun details... ;)

Thanks!

Since it's a just an isosurface, all you have to do is move the camera closer
and adjust the accuracy and max_gradient proportional to the "zoom level".

This is still six iterations.

~David


Post a reply to this message


Attachments:
Download 'mandelbulb8i6-closer.png' (346 KB)

Preview of image 'mandelbulb8i6-closer.png'
mandelbulb8i6-closer.png


 

From: waggy
Subject: Re: 'Accidental' isosurface
Date: 20 Nov 2009 23:10:02
Message: <web.4b076760ce81d185f99d05c80@news.povray.org>
Oh, and here is the same view with the isosurface function limited to eight
iterations.

I just found the function also works well, and is far, far quicker, as a media
density.

Good times.

~David


Post a reply to this message


Attachments:
Download 'mandelbulb8i8-closer.png' (346 KB)

Preview of image 'mandelbulb8i8-closer.png'
mandelbulb8i8-closer.png


 

From: CShake
Subject: Re: 'Accidental' isosurface
Date: 21 Nov 2009 02:06:05
Message: <4b07915d@news.povray.org>
waggy wrote:
> Oh, and here is the same view with the isosurface function limited to eight
> iterations.
> 
> I just found the function also works well, and is far, far quicker, as a media
> density.
> 
> Good times.
> 
> ~David

Well, I'm seeing that the actual surface generation and rendering is 
probably best left to people like you who seem to get good results, so I 
figured I might as well go another direction with it.

Instead of going for the full 3d, as many of you are, I decided to make 
a way to get 2d 'slices' of this beast that allow for nice smooth 
coloring based on divergence rate, like most of the pictures for the 
original Mandelblot, instead of only edge finding like everyone seems to 
be doing with this so far. I wrote some code that will generate 
grayscale images based on number of iterations according to various 
parameters.

Here is one slice, generated with parameters mirroring povray:
center = <0.7275,0.272,0.5>
right = <0.001,0,0>
up = <0,0.001,0>
n = 8
max_iterations = 200
This image is NOT pov-created, but can be used for patterns and the 
like. It was originally generated at 5000x5000 (.png) which took about a 
minute, then downsized for uploading here.

C++ source available on request, the only dependencies are ImageMagick 
for creating the image file itself, and a compiler supporting OpenMP.


Post a reply to this message


Attachments:
Download 'mb_slice_demo.jpg' (270 KB)

Preview of image 'mb_slice_demo.jpg'
mb_slice_demo.jpg


 

From: PM 2Ring
Subject: Re: 'Accidental' isosurface
Date: 21 Nov 2009 11:10:01
Message: <web.4b080fc0ce81d185f4c648ed0@news.povray.org>
"scott" <sco### [at] scottcom> wrote:

> Hehe I just did the same :-)  Mine was 1024x1024x1024 df3 file which took
> about half an hour multithreaded under c#.net (I decided the speedup I could
> get by easy multithreading in c# outweighed the speedup I could get with C++
> over C#).  The render only took about 2 minutes, it's just an isosurface and
> a few lights.

Nice work, Scott. And others!

I have a slow old machine, with only 768MB of RAM, so my renders take a bit


I'm especially jealous of that special version of povray that can do custom
fractal functions. :) But I suppose it's probably slower than using a density
file. (I haven't played with them much before, and I'm frankly amazed at how
fast those things parse, even fairly huge ones.)

I *think* I figured a way to do this Mandelbulb function using standard SDL. We
don't need the ability to do arbitrarily deep iterations, since 6 or
7 are quite adequate. So we could unroll the iteration loop... into a veritable
rats' nest of functions, which would probably involve lots of duplicated
evaluations & be incredibly slow. :)

> > I haven't optimized the code too far yet, it's still using the trig
> > functions, but it can be used for any value N.
>
> Yeh mine too, it looks like there should be a way to lose the trig even with
> N=8, but it might get a bit scary...

You can lose the trig functions by using the formulae of sin(2t) & cos(2t) in
terms of sin(t) & cos(t). We want the 8th power, so we just double the angle 3
times. My first explorations of the Mandelbulb used Python to generate the voxel
data, but I translated my code to C today, and it should compile with no
problems on any system (if it supports doubles :)).

To avoid clutter, I'll post my C source in a separate message in this thread.

> The issue is that the isosurface is still made up of millions of little cube
> shaped voxels, I think the only way to improve that is to write a
> fractal-ray tracer too!  Or maybe patch POV...

Your renders look a fair bit smoother than mine. What accuracy are you using on
the isosurface, and what sort of max_gradient for that size grid? The one below
uses max_gradient 1072, accuracy 0.002.

The pigment on the attached image is just function{sqrt(x*x+z*z)*4.5}, with an
old favourite colour map I created many years ago when I was writing 2D
Mandelbrot programs on the Amiga.


Post a reply to this message


Attachments:
Download 'mandelbulbg8sa90.jpg' (160 KB)

Preview of image 'mandelbulbg8sa90.jpg'
mandelbulbg8sa90.jpg


 

From: PM 2Ring
Subject: Re: 'Accidental' isosurface
Date: 21 Nov 2009 11:20:00
Message: <web.4b08128dce81d185f4c648ed0@news.povray.org>
Simple "Mandelbulb" C source code.

Compile with

gcc -o Mandelbulb Mandelbulb.c -lm -O3


/*
 * Mandelbulb
 *
 * Written by PM 2Ring November 2009.
 * Converted from Python to C, 2009.11.21
 *
 */

/*

From http://www.skytopia.com/project/fractal/mandelbulb.html

Similar to the original 2D Mandelbrot , the 3D formula is defined by:

z -> z^n + c

....but where 'z' and 'c' are hypercomplex ('triplex') numbers, representing
Cartesian x, y, and z coordinates. The exponentiation term is defined by:

{x,y,z}^n = r^n {sin(theta*n) * cos(phi*n), sin(theta*n) * sin(phi*n),
cos(theta*n)}
where
r = sqrt(x^2 + y^2 + z^2)
theta = atan2(sqrt(x^2+y^2), z)
phi = atan2(y, x)
n is the order of the 3D Mandelbulb. Use n=8 to find the exact object in this
article.

The addition term in z -> z^n + c is similar to standard complex addition,
and is simply defined by:

{x,y,z}+{a,b,c} = {x+a, y+b, z+c}

The rest of the algorithm is similar to the 2D Mandelbrot!

*/

#include <math.h>
#include <stdio.h>
#include <time.h>

//Compute sin(8t) & cos(8t) given r*sin(t), r*cos(t) & r
void trig8(double *ps, double *pc, double r)
{
    //int i;
    double c = *pc, s = *ps, t;

    if (r > 0.0)
    {
        s /= r;
        c /= r;
        //Iterate formulae for sin(2t) & cos(2t) 3 times
        //to get sin(8t) & cos(8t)
        //for (i=0; i<3; i++)
        //{
            t = 2.0*s*c; c = c*c - s*s; s = t;
            t = 2.0*s*c; c = c*c - s*s; s = t;
            t = 2.0*s*c; c = c*c - s*s; s = t;
        //}

        *ps = s;
        *pc = c;
    }
}

//Determine if voxel (cx, cy, cz) is in the Mandelbulb
int Mandel3D(double cx, double cy, double cz, int iters)
{
    double x = cx, y = cy, z = cz, w, w2, r, r2, r8,
    sth8, cth8, sph8, cph8;
    int i;

    for (i=0; i<iters; i++)
    {
        //Convert (x, y, z) coordinates to polar (r, th, ph)
        w2 = x*x + y*y;
        w = sqrt(w2);
        r2 = w2 + z*z;
        r = sqrt(r2);
        if (r >= 2.0)
            return 0;

        //Raise (r, th, ph) to the 8th power
        sth8 = w; cth8 = z; trig8(&sth8, &cth8, r);
        sph8 = y; cph8 = x; trig8(&sph8, &cph8, w);

        //(r, th, ph) <- c + (r, th, ph)^8
        r8 = r2 * r2 * r2 * r2;
        x = cx + r8 * sth8 * cph8;
        y = cy + r8 * sth8 * sph8;
        z = cz + r8 * cth8;
    }
    return 1;
}

int Mandelbulb(double vx, double vy, double vz, double scale, int side, int
iters, char *fname)
{
    FILE *f;
    unsigned char *row;
    int i, j, k;
    time_t itime;
    double x, y, z;

    if(!(f = fopen(fname, "wb")))
        return 1;

    if(!(row = (unsigned char *) malloc(side)))
        return 1;

    //Write header: voxel grid dimensions in little endian
    {
        unsigned char lo = side & 0xff, hi = side >> 8;

        fprintf(f, "%c%c%c%c%c%c", hi, lo, hi, lo, hi, lo);
    }

    itime = time(NULL);
    for (k=0; k<side; k++)
    {
        //Planes
        z = vz + scale * k;
        for (j=0; j<side; j++)
        {
            //Rows
            y = vy + scale * j;
            for (i=0; i<side; i++)
                //Voxels
                row[i] = Mandel3D(vx + scale * i, y, z, iters) ? 255 : 0;
            fwrite(row, 1, side, f);
        }

        if (k%10 == 0)
        {
            int n = (int) difftime(time(NULL), itime);

            //fputc('.', stderr);
            fprintf(stderr, "\r %2d:%02d:%02d Plane %d of %d ",
                n/3600, (n/60)%60, n%60, k, side);
        }
    }

    free(row);
    fclose(f);

    return 0;
}

int main(int argc, char *argv[])
{
    int side, iters, rc;
    char *fname;
    double r, scale;

    side = argc > 1 ? atoi(argv[1]) : 100;
    fname = argc > 2 ? argv[2] : "Mandelbulb.df3";
    iters = argc > 3 ? atoi(argv[3]) : 7;

    r = 1.1;    //Mandelbulb Set "radius"
    //r = 1.05 * (1.0 + 2.0 / side);
    scale = 2.0*r / (side - 1);

    rc = Mandelbulb(-r, -r, -r, scale, side, iters, fname);

    fputc('\n', stderr);
    return rc;
}


Post a reply to this message

From: Warp
Subject: Re: 'Accidental' isosurface
Date: 21 Nov 2009 13:49:12
Message: <4b083628@news.povray.org>
scott wrote:
> I think it would be easiest (ie not take 400 years) if you made a
> program in a faster language (eg C++) to write a df3 file, and then used
> POV to render the df3 file as an isosurface.

  Why does it have to be an isosurface? If you created a mesh out of it,
it would probably render about a thousand times faster, in which case
you could start adding fancy texturing, lighting and other effects
without having to wait until the Sun dies.


Post a reply to this message

From: waggy
Subject: Re: 'Accidental' isosurface
Date: 21 Nov 2009 20:50:01
Message: <web.4b089876ce81d185f99d05c80@news.povray.org>
CShake wrote:
> Well, I'm seeing that the actual surface generation and rendering is
> probably best left to people like you who seem to get good results, so I
> figured I might as well go another direction with it.
>
Wow!  That's gorgeous!  I can imagine some good uses for it.

To see about making an animated fly-through, I zoomed way in by using trace() to
place the camera on a surface a few iteration levels above the look_at point on
the iteration ten (10) surface here rendered.  Since I picked starting and
target points more-or-less at random, I have no idea where this surface is, and
there is only a single light source placed at the camera location.  I also
shrunk the contained_by (too much, it turned out) to avoid overheating the CPU
when the sun goes nova.

Are we having too much fun yet?

~David


  Trace Time:       1 hours 45 minutes 26 seconds (6326.522 seconds)
              using 8 thread(s) with 47526.303 CPU-seconds total


Post a reply to this message


Attachments:
Download 'mb8i10_zoom_1.png' (220 KB)

Preview of image 'mb8i10_zoom_1.png'
mb8i10_zoom_1.png


 

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.