POV-Ray : Newsgroups : povray.unofficial.patches : Being able to call DLLs/SOs as user defined functions : Re: Being able to call DLLs/SOs as user defined functions Server Time
3 Mar 2024 11:56:27 EST (-0500)
  Re: Being able to call DLLs/SOs as user defined functions  
From: bugman
Date: 19 Apr 2011 18:05:01
Message: <web.4dae068efa289b21d1576610@news.povray.org>
Thank you Warp. For some reason, I did not get your reply until after I posted
my last message. Anyway, that 'select' function is just the thing I've been
looking for. Using this approach, I was able to render a Mandelbulb in PovRay.
The following code is not very efficient, but it's an interesting demonstration.
Try it out!:

//runtime: 4 minutes, image size: 320x240
camera{location <-2.5,5,5> look_at <-0.5,0,0.25> up z sky z angle 25}
light_source{20*z,1}
#declare f=function(i,x,y,z,xc,yc,zc) {select(i>0 & x*x+y*y+z*z<4, 0,
sqrt(x*x+y*y+z*z),
f(i-1,(x*x-y*y)*(1-z*z/(x*x+y*y))+xc,2*x*y*(1-z*z/(x*x+y*y))+yc,-2*z*sqrt(x*x+y*y)+zc,xc,yc,zc))};
isosurface{function{f(24,x,y,z,x,y,z)-2} threshold 0 max_gradient 10
contained_by{sphere{<-0.5,0,0>,2}} pigment{rgb 1}}

In the process, I discovered something strange and evil about POV-Ray functions.
If I declare any helper functions before my 'f' function, everything goes
haywire. I'm not sure why this is, but it took me quite a while to discover this
problem.


Post a reply to this message

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