POV-Ray : Newsgroups : povray.binaries.images : 'Accidental' isosurface : Re: 'Accidental' isosurface Server Time
28 Sep 2024 15:16:05 EDT (-0400)
  Re: 'Accidental' isosurface  
From: waggy
Date: 22 Nov 2009 14:15:00
Message: <web.4b098d69ce81d185f99d05c80@news.povray.org>
"abram" wrote:

> So is this a function that you have defined within povray for the isosurface or
> are you using a df3 file?

It's a pair of functions, one to do the iterations, and another to return a
value suitable for making an isosurface.  The plan was to add additional
functions better suited to use as a pattern, media, etc.

> Instead of fiddling with user-definable functions within povray I added a new
> function to povray's fnintern.cpp which allowed me to render mandelbulbs with
> povray.

I agree, and thanks for making the patch available.  I may take a whack at
modifying it to use  PM 2Ring's trigless algorithm.

> I really think the functional approach is superior to the voxel approach since
> getting 1000x1000x1000 voxels is time consuming and space consuming.
>
> But if you did define your own function in isosurface I'd love to see it.

OK.  I've avoided posting it since it's an illegal recursive function and can
crash 3.7.  It seems to work only when there is just one recursive function
defined, and this recursive function does not call any other user-defined
function.  There are posts to this site showing how to unroll these type of
functions using macros to make everything legal, and I may try that, as well.

However, to make a good isosurface I found it necessary to modify the return
value so it is no longer strictly a step function returning a value proportional
to just the iteration number.  It seems this is needed so the isosurface's
surface normal can be calculated correctly, and it also speeds rendering and
works with lower max_gradient and larger accuracy values.  I probably don't have
the quite the right formulation yet, but what's below works pretty well.

~David Wagner

P.S. Attached are some Easter eggs courtesy of the Basic scene template.

// Persistence of Vision Ray Tracer Scene Description File
// File: mandelbulb.inc
// Vers: 3.6.1, 3.7
// Desc: Mandelbulb Functions
// Date: 11/18/09
// Auth: David Wagner


//Making the return value a float by adding how close to the radius of
convergence REALLY helps!
//Returns 0 to mb_imax+2?  Taking off 3 seems to work best.
//This new version seems to have interior surfaces, too.

#declare mb_fn_iterator_frac = function(mb_i,mb_imax, mb_in, x,y,z,
mb_ix,mb_iy,mb_iz) {
   select(mb_i > mb_imax | pow(mb_ix,2) + pow(mb_iy,2) + pow(mb_iz,2) >4, 0,
      mb_fn_iterator_frac(mb_i+1,mb_imax, mb_in, x,y,z,

         x + pow(pow(mb_ix,2) + pow(mb_iy,2) + pow(mb_iz,2) , mb_in/2)
             * sin( atan2( sqrt(pow(mb_ix,2) + pow(mb_iy,2)), mb_iz) * mb_in)
             * cos( atan2(mb_iy,mb_ix) * mb_in),

         y + pow(pow(mb_ix,2) + pow(mb_iy,2) + pow(mb_iz,2) , mb_in/2)
             * sin( atan2( sqrt(pow(mb_ix,2) + pow(mb_iy,2)), mb_iz) * mb_in)
             * sin( atan2(mb_iy,mb_ix) * mb_in),

         z + pow(pow(mb_ix,2) + pow(mb_iy,2) + pow(mb_iz,2) , mb_in/2)
             * cos( atan2( sqrt(pow(mb_ix,2) + pow(mb_iy,2)), mb_iz) * mb_in)
         ),
      mb_i + 1/(pow(mb_ix,2) + pow(mb_iy,2) + pow(mb_iz,2) -3 )
      )//end select
   };

#declare mb_fn_iso = function(x,y,z, mb_fn_n, mb_fn_iterations) {
   ( mb_fn_iterations - mb_fn_iterator_frac(0,mb_fn_iterations-1, mb_fn_n,
x,y,z, x,y,z) -0.5 )
   / mb_fn_iterations
   };

/*
  The iteration number is negated so the inside is defined correctly.
  Taking off 0.5 here may be a mistake now that the iteration is no longer an
integer...
    but it seems to work best for isosurfaces.
*/

/*
//Use the include file as follows:

#include "mandelbulb.inc"

#local mb_n=8;           // Mandelbulb Power
#local mb_iterations=6;
#local mb_zoom=2;        // Use higher values for tighter views.

isosurface {
  function { mb_fn_iso(y, x, z, mb_n, mb_iterations) }
  threshold 0.0
  contained_by { sphere { <0,0,0>, 1.2 } } //Power 8

  //For power 8
  accuracy     pow(2,-mb_iterations  )  /32 /mb_zoom
  max_gradient pow(2, mb_iterations/2)  *32 *mb_zoom

texture{pigment{color White}}
finish{ambient 0 diffuse 0.9 phong 0.1 specular 0.0}
}
*/


Post a reply to this message


Attachments:
Download 'mb_pattern_basic_set.png' (134 KB)

Preview of image 'mb_pattern_basic_set.png'
mb_pattern_basic_set.png


 

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