POV-Ray : Newsgroups : povray.binaries.images : yet another mengersponge... : Re: yet another mengersponge... Server Time
19 Aug 2024 02:26:28 EDT (-0400)
  Re: yet another mengersponge...  
From: Vahur Krouverk
Date: 12 Mar 2001 13:42:22
Message: <3AAD18B2.5A8A84C@aetec.ee>
Bill DeWitt wrote:
> 
>     Are you saying that this is an isosurface? I have been expecting to see
> a fractal isosurface soon but I didn't know one had been made.

No, I wrote that! :-) Yes, it is isosurface, like this (POVMan 0.7 is
required for running it, more complete example comes with
documentation):

#declare xyf=function{
    shader{
        shader_file "menger.slp"
        "rec_depth" 20
    }
}
isosurface {
    function { 
        xyf
    }
    contained_by { box { -1.0,1.0 } }
    all_intersections
    max_gradient 100
    accuracy 0.001
    texture {
      ...
    } 
    scale 2
}


shader file is as follows:
iso_function menge(float rec_depth = 8){

    float testfirst(output float mx, mn){

        float rv = -1;
        mx *= 3;
        mn *= 3;
        float i;
        extern float rec_depth;
        for (i=0; i<rec_depth;i+=1){
            if(mx<=1 && mn <= 1){
                rv = 1;
                break;
            }
            else{
                mx = abs(mod(mx*3+1, 6) -1);
                mn = abs(mod(mn*3+1, 6) -1);
            }
        }
        return rv;
    }

    float retv = -1;
    if (testfirst(abs(xcomp(P)),abs(ycomp(P))) == 1 ||
        testfirst(abs(xcomp(P)),abs(zcomp(P))) == 1 ||
         testfirst(abs(zcomp(P)),abs(ycomp(P))) == 1)
      retv = 1;

    return retv;
}


Post a reply to this message

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