|
![](/i/fill.gif) |
Quadhall wrote:
>
> Well, I'm not sure I have the terminology correct, but here is a "Menger
> gasket" pigment (on a box object). Has anything like this method been
> posted before? It should be a trivial matter to generalize this to a real
> Menger sponge (just add in z functions, and put into an isosurface). Well
> enough blabbing, the scene file is below, followed by the picture,
>
Hmm, this seems to be slow (cos ain't very fast function). I tried
menger with the shader function (3D version is available in POVMan
documentation package) and it rendered same picture 2 times faster. So I
converted shader code to POV-Ray functions and it rendered too 2 times
faster than yours. Perhaps someone can make it even shorter by using
macros?
Here is my code for it:
=============8<========8<=================
#version unofficial MegaPOV 0.7;
camera
{
location <0,0,-6>
look_at <0,0,0>
orthographic
right <1.1,0,0>
up <0,1.1,0>
}
light_source { <0,0,-6> 1 }
#declare recurseDepth = 5;
#declare iterate1=function{
if(1-abs(x),if(1-abs(y),1,0),0)
}
#declare iterate2=function{
if(iterate1(x,y,0),1, if (iterate1(abs(((x*3+1)%6)-1),
abs(((y*3+1)%6)-1),0),1,0))
}
#declare iterate3=function{
if(iterate1(x,y,0),1, if (iterate2(abs(((x*3+1)%6)-1),
abs(((y*3+1)%6)-1),0),1,0))
}
#declare iterate4=function{
if(iterate1(x,y,0),1, if (iterate3(abs(((x*3+1)%6)-1),
abs(((y*3+1)%6)-1),0),1,0))
}
#declare iterate5=function{
if(iterate1(x,y,0),1, if (iterate4(abs(((x*3+1)%6)-1),
abs(((y*3+1)%6)-1),0),1,0))
}
#declare binary5 = function{
if(iterate5(abs(x*3),abs(y*3),0),1,0)
}
#declare two_d_menger=
pigment
{
function{binary5}
color_map
{
[0 color rgb 1 ]
[1 color rgb 0 ]
}
}
box{ <.5,.5,0> <-.5,-.5,-.1> pigment{two_d_menger scale 0.5}
finish{ambient 1} }
Post a reply to this message
|
![](/i/fill.gif) |