POV-Ray : Newsgroups : povray.pov4.discussion.general : Tree Fractals : Re: Tree Fractals Server Time
25 Apr 2024 17:11:25 EDT (-0400)
  Re: Tree Fractals  
From: waggy
Date: 3 Dec 2009 22:00:01
Message: <web.4b187b0bc3dd15e7f99d05c80@news.povray.org>
"Gerhard Oosthuizen" wrote:
> It would be nice to have a fractal object for trees and lightning.
> Tree-like fractal textures would also be nice for veins and leaves.

If you don't mind breaking the rule against recursive functions, it isn't too
difficult to make a fractal pattern.  The following scene uses a function
derived from the bifurcation diagram of the logistic map[1] as a pattern.
Although this example only shows it used as a planar pattern, it could also be
mapped to three dimensions in various other ways.  With a little turbulence it
might make a decent lightning.  With some more tweaking, you could likely get a
tree or at least a scrubby bush out of it.

Since I read the POV-Ray docs about how turbulence works[2], I have thought it
should be possible to make a fractal_warp that could be applied to existing
patterns...

Cheers!

[1] http://en.wikipedia.org/wiki/File:LogisticMap_BifurcationDiagram.png

[2] http://www.povray.org/documentation/view/3.6.1/407/#s02_05_12_06_04

// ----------------------------------------
// Persistence of Vision Ray Tracer Scene Description File
// File: logistic_map_pattern.pov
// Vers: 3.6, 3.7
// Desc: Logistic Map Pattern Example
// Date: 12/03/09
// Auth: David Wagner
// Cite: http://en.wikipedia.org/wiki/Logistic_map
//
// Render at 16:9 with +A0.5 +AM2 +R2 -J

#include "colors.inc"

// ----------------------------------------

// Returns the distance to the nearest logistic value after lm_imin iterations.
#declare lm_i_distance_min = function( lm_r, lm_pop, lm_val, lm_nearestpop,
lm_i, lm_istart, lm_iend ) {
   select(lm_i > lm_iend, 0,
     lm_i_distance_min(
       lm_r,
       lm_r*lm_pop*(1-lm_pop),
       lm_val,
       select(lm_i > lm_istart & ( (abs(lm_pop-lm_val) <
abs(lm_nearestpop-lm_val)) ),0,
         lm_nearestpop,
         lm_pop),
       lm_i+1, lm_istart, lm_iend ),
     abs(lm_val-lm_nearestpop) )//end select
   };


// Calls the recursive iterating function.
#declare lm_fn_distance_min = function( lm_r, lm_val, lm_istart, lm_iend ) {
  lm_i_distance_min(lm_r,0.5, lm_val, 1, 0, lm_istart, lm_iend)
  };

// ----------------------------------------

plane {
  y, -1
  texture{
    pigment { function { lm_fn_distance_min(abs(mod(z,4)), abs(mod(x,1)), 20,
100)}
    poly_wave 0.25
      color_map{[0 Yellow][0.2 1.2*Goldenrod][0.2 White][0.5 Black][1 Blue]}
      translate z*1.04
      }//end pigment
  }//end texture
}

sphere {
  0.0, 1
  texture {
    pigment {
    function { lm_fn_distance_min(mod(abs(z),4), abs(mod(x,1)), 20, 100)}
    poly_wave 0.25
      color_map {
        [0.00 color rgb <1.0,0.4,0.2> ]
        [0.33 color rgb <0.2,0.4,1.0> ]
        [0.66 color rgb <0.4,1.0,0.2> ]
        [1.00 color rgb <1.0,0.4,0.2> ]
      }
    }//end pigment
    normal{function{-lm_fn_distance_min(mod(abs(z),4), abs(mod(x,1)), 20, 100) }
    poly_wave 2
      }
    finish{
      specular 0.3//0.6
    }
    translate z*3
  }//end texture
}

// ----------------------------------------

camera {
  location  <0.0, 0.5-1., -4.0>
  direction 1.5*z
  right     x*image_width/image_height
  look_at   <0.0, 0.0-1,  0.0>
}

sky_sphere {
  pigment {
    gradient y
    color_map {
      [0.0 rgb <0.6,0.7,1.0>]
      [0.7 rgb <0.0,0.1,0.8>]
    }
  }
}

light_source {
  <0, 0, 0>            // light's position (translated below)
  color rgb <1, 1, 1>  // light's color
  translate <-30, 30, -30>
}

// ----------------------------------------


Post a reply to this message


Attachments:
Download 'logistic_map_pattern.png' (215 KB)

Preview of image 'logistic_map_pattern.png'
logistic_map_pattern.png


 

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