User Tools

Site Tools


user:mgough:mandelbulbs-povray

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
user:mgough:mandelbulbs-povray [2010/05/19 10:54]
mgough
user:mgough:mandelbulbs-povray [2010/05/19 11:04] (current)
mgough
Line 1: Line 1:
 +====== Povray Mandelbulbs ======
 +===== Overview =====
 +Rendering 3d Mandelbulbs with povray.
  
 +Drawing Mandelbrot Fractals is mighty interesting and will wow your friends, but why stop there. ​ There has been recent developments in rendering the fractals in three dimensions - this results in a Mandelbulb! ​ The history and development can be found at the following link:
 +
 +http://​www.skytopia.com/​project/​fractal/​mandelbulb.html
 +
 +===== Requirements =====
 +
 +1) GCC development environment.\\
 +2) Povray installation.\\
 +3) Mandelbulb povray script. - http://​www.skytopia.com/​projects/​fractal/​2mandelbulb.html (The link appears to be dead, so I will include the source scripts for download)\\
 +
 +===== Povray Installation =====
 +
 +1.  Open a shell\\
 +2.  create a temporary directory somewhere to unpack the POV-Ray distribution\\
 +for example:
 +\\
 +    user@machine:​~>​ mkdir ~/povray/
 +\\
 +3. Get the POV-Ray for GNU/Linux binary package from the POV-Ray website\\
 +      This can be done by right clicking on the following link and choosing 'Save Link As.../Save Link Target As...':​\\
 +\\
 +http://​www.povray.org/​redirect/​www.povray.org/​ftp/​pub/​povray/​Official/​Linux/​povlinux-3.6.tgz\\
 +\\
 +Save this package in the new directory you just created, for example /​home/<​username>/​povray/​.\\
 +\\
 +4. switch back to the shell\\
 +\\
 +5. change into the directory where you just saved the package:\\
 +For example\\
 +\\
 +      user@machine:​~>​ cd ~/povray/
 +\\
 +6. unpack the distribution:​\\
 +\\
 +      user@machine:​~/​povray>​ tar xvfz povlinux.tgz
 +\\
 +You should get a long listing of all files extracted from the package.\\
 +\\
 +7. change into the distribution directory:​\\
 +\\
 +      user@machine:​~/​povray>​ cd povray-3.6
 +\\
 +8. become root:\\
 +\\
 +      user@machine:​~/​povray/​povray-3.6>​ su
 +      Password: <enter root password>​
 +\\
 +9. run the install script:\\
 +\\
 +      root@machine:/​home/​user/​povray/​povray-3.6>​ ./install
 +\\
 +If you previously had no other POV-Ray version installed the installation should run without interruptions. Otherwise there might be additional decisions required.\\
 +\\
 +Check if the install script reports any problems. At the end you will be asked if you want to do a test render. This test render will be without display when run as root.\\
 +\\
 +10. leave the root environment:​\\
 +\\
 +      root@machine:/​home/​user/​povray/​povray-3.6>​ exit
 +\\
 +11. if you had previously installed POV-Ray or if you want to be able to customize your configuration independently from other users:\\
 +\\
 +      user@machine:​~/​povray/​povray-3.6 > ./install user
 +\\
 +This will update the user configuration files in ~/​.povray/​3.6/​.
 +\\
 +12. to test if installation was successful you can run a short test render:\\
 +\\
 +      user@machine:​~/​povray/​povray-3.6>​ ./install test
 +\\
 +If this fails there probably was some problem during the install that required manual action. Check the messages printed by the install script and try to run the install again.\\
 +
 +===== Mandelbulb Scripts =====
 +
 +mbsdl.inc\\
 +<file bash mbsdl.inc>​
 +// Persistence of Vision Ray Tracer Scene Description File
 +
 +// File: mbsdl.inc
 +
 +// Vers: 3.6.1, 3.7
 +
 +// Desc: Mandelbulb Functions in POV-Ray Scene Description Language
 +
 +// Date: 12/18/09
 +
 +// Auth: David Wagner
 +
 +// Cite: http://​www.skytopia.com/​project/​fractal/​2mandelbulb.html
 +
 +
 +
 +// WARNING: Include this file first in a scene.
 +
 +// WARNING: This recursive function is invalid SDL and can crash POV-Ray.
 +
 +
 +
 +#declare mbsdl_recurse = function( mbsdl_r_p_r,​ mbsdl_r_p_theta,​ mbsdl_r_p_phi,​ mbsdl_r_i,​mbsdl_r_i_bailout,​ mbsdl_r_r2_bailout,​ x,y,z, mbsdl_r_x,​mbsdl_r_y,​mbsdl_r_z) {
 +
 +   ​select(mbsdl_r_i > mbsdl_r_i_bailout | pow(mbsdl_r_x,​2) + pow(mbsdl_r_y,​2) + pow(mbsdl_r_z,​2) >​mbsdl_r_r2_bailout,​ 0, 
 +
 +      mbsdl_recurse( mbsdl_r_p_r,​mbsdl_r_p_theta,​ mbsdl_r_p_phi,​ mbsdl_r_i+1,​mbsdl_r_i_bailout,​ mbsdl_r_r2_bailout,​ x,y,z,
 +
 +      ​
 +
 +         x + pow(pow(mbsdl_r_x,​2) + pow(mbsdl_r_y,​2) + pow(mbsdl_r_z,​2) , 0.5*mbsdl_r_p_r)
 +
 +             * sin( atan2( sqrt(pow(mbsdl_r_x,​2) + pow(mbsdl_r_y,​2)),​ mbsdl_r_z) * mbsdl_r_p_theta)
 +
 +             * cos( atan2(mbsdl_r_y,​mbsdl_r_x) * mbsdl_r_p_phi),​
 +
 +          ​
 +
 +         y + pow(pow(mbsdl_r_x,​2) + pow(mbsdl_r_y,​2) + pow(mbsdl_r_z,​2) , 0.5*mbsdl_r_p_r)
 +
 +             * sin( atan2( sqrt(pow(mbsdl_r_x,​2) + pow(mbsdl_r_y,​2)),​ mbsdl_r_z) * mbsdl_r_p_theta)
 +
 +             * sin( atan2(mbsdl_r_y,​mbsdl_r_x) * mbsdl_r_p_phi),​
 +
 +           
 +
 +         z + pow(pow(mbsdl_r_x,​2) + pow(mbsdl_r_y,​2) + pow(mbsdl_r_z,​2) , 0.5*mbsdl_r_p_r)
 +
 +             * cos( atan2( sqrt(pow(mbsdl_r_x,​2) + pow(mbsdl_r_y,​2)),​ mbsdl_r_z) * mbsdl_r_p_theta)
 +
 +      ),
 +
 +      1/( mbsdl_r_i+log(log(mbsdl_r_r2_bailout) / log((mbsdl_r_i>​(mbsdl_r_i_bailout-1))+pow(mbsdl_r_x,​2)+pow(mbsdl_r_y,​2)+pow(mbsdl_r_z,​2))) / log(mbsdl_r_p_r) )
 +
 +   ​)//​end recursion select loop
 +
 +};
 +
 +
 +
 +#declare f_mandelbulb = function(x,​y,​z,​ mbsdl_f_p_r,​ mbsdl_f_p_theta,​ mbsdl_f_p_phi, ​ mbsdl_f_i_bailout,​ mbsdl_f_r_bailout){
 +
 +    mbsdl_recurse( mbsdl_f_p_r,​ mbsdl_f_p_theta,​ mbsdl_f_p_phi,​1,​int(mbsdl_f_i_bailout-1),​ pow(mbsdl_f_r_bailout,​2),​ x,y,z, x,y,z)
 +
 +}
 +</​file>​
 +mbsdl_basic.pov\\
 +<file bash mbsdl_basic.pov>​
 +// Persistence of Vision Ray Tracer Scene Description File
 +
 +// File: mbsdl_basic.pov
 +
 +// Vers: 3.6, 3.7
 +
 +// Desc: Basic Scene Example
 +
 +// Date: 12/18/09
 +
 +// Auth: David Wagner
 +
 +// Cite: http://​www.skytopia.com/​project/​fractal/​2mandelbulb.html
 +
 +
 +
 +#version 3.6;
 +
 +
 +
 +#include "​mbsdl.inc"​ // Include this first.
 +
 +#include "​colors.inc"​
 +
 +
 +
 +global_settings {
 +
 +  assumed_gamma 1.0
 +
 +}
 +
 +
 +
 +// ----------------------------------------
 +
 +
 +
 +camera {
 +
 +  location ​ <0.0, 0.5, -4.0>
 +
 +  direction 1.5*z
 +
 +  right     ​x*image_width/​image_height
 +
 +  look_at ​  <​0.0,​ 0.0,  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>
 +
 +}
 +
 +
 +
 +// ----------------------------------------
 +
 +
 +
 +plane {
 +
 +  y, -1
 +
 +  pigment { color rgb <​0.7,​0.5,​0.3>​ }
 +
 +}
 +
 +
 +
 +isosurface {
 +
 +  function {f_mandelbulb(x,​y,​z,​ 8,8,8, 3, 3)}
 +
 +  threshold 1/3
 +
 +  max_gradient 20
 +
 +  accuracy 0.001
 +
 +  contained_by {sphere{<​0,​0,​0>,​4.8}}
 +
 +  texture {
 +
 +    pigment {
 +
 +      function { f_mandelbulb(x,​y,​z,​ 8,8,8, 20, 3 ) }
 +
 +      scale 1.05
 +
 +      frequency 8
 +
 +      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>​ ]
 +
 +      }
 +
 +    }
 +
 +    finish{
 +
 +      specular 0.6
 +
 +    }
 +
 +  }
 +
 +}
 +
 +</​file>​
 +
 +===== Running the Scripts =====
 +Running povray to render the mandelbulbs is quite easy.\\
 +\\
 +  povray mbsdl_basic.pov
 +\\
 +The program will now open an x-window and render the mandelbulb line by line.\\
 +\\
 +The terminal will show render staticsics and any options you may have used to perform the raytrace. ​ All you have left to do is let it render, and impress your friends!\\
 +\\
 +The final render will be saved in the current directory as mbsdl_basic.png\\
 +\\
 +And here is the result!
 +{{:​user:​mgough:​mbsdl_basic.png|}}
 +
 +There are many options you can play with to get differing results, it's up to your imagination!\\
user/mgough/mandelbulbs-povray.txt · Last modified: 2010/05/19 11:04 by mgough