Recently I've been looking at Povray, pyprocessing, and cfdg (version 3.0) as tools for creating digital images. I have branched two separate blogs where I mainly explore jruby + processing and processing.py

Saturday, 5 May 2012

Pure Povray Stochastic Menger Sponge

//+W1280
//+H1024
#version 3.7;

global_settings{
  assumed_gamma 1.0
  radiosity{
    pretrace_start 0.04
    pretrace_end 0.01
    count 200
    recursion_limit 3
    nearest_count 10
    error_bound 0.5
  }
}

#include "functions.inc"
#include "colors.inc"
#include "stones1.inc"
#include "metals.inc"

camera { 
  location  <0, 0, 800> 
  look_at <0, 0, 0> 
  right <1.25, 0, 0>
}

sky_sphere { pigment {
    function{abs(y)}
    color_map { [0.0 color blue 0.6] [1.0 color rgb 1] } 
  }
}

light_source {<-50,400,800> color rgb 1}

#declare data = array[20][3] // menger sponge data generated using python
{
{-1, -1, -1}, 
{-1, -1, 0}, 
{-1, -1, 1}, 
{-1, 0, -1}, 
{-1, 0, 1}, 
{-1, 1, -1}, 
{-1, 1, 0}, 
{-1, 1, 1}, 
{0, -1, -1}, 
{0, -1, 1}, 
{0, 1, -1}, 
{0, 1, 1}, 
{1, -1, -1}, 
{1, -1, 0}, 
{1, -1, 1}, 
{1, 0, -1}, 
{1, 0, 1}, 
{1, 1, -1}, 
{1, 1, 0}, 
{1, 1, 1} 
}

#declare RandW = seed(123);
#declare sz = 2;

#macro makemenger(d)
#if (d=0)
#if (rand(RandW) < 0.8)
box{-0.5,0.5}
texture{ T_Stone21 }
#else 
sphere{<0, 0, 0>, 0.5} 
texture{ T_Chrome_5E }
#end
#else
#local i=0;
union {
  #while (i<20)
  object { makemenger(d-1) translate<data[i][0], data[i][1], data[i][2]> scale 1/3}
  #local i=i+1;
  #end 
}
#end
#end
 
object{ 
makemenger(sz) 
scale<300, 300, 300>
rotate<0, 30, 10>
} 
PovRAY rendered

No comments:

Post a Comment

Followers

Blog Archive

About Me

My photo
Pembrokeshire, United Kingdom
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2