sabato 14 marzo 2015

Water pool raytraced

In this post, we will show how to generate a water pool using POV Ray, and how to create a relistic wave effect on the pool water using the Isosurface command line.
Here is the code for POV Ray file:
// POV-Ray 3.7 Scene File "Prova7.pov"   basato su woodbox
// author:  Max
// Date:   14/03/2015
//--------------------------------------------------------------------------
#version 3.7;
global_settings{ assumed_gamma 1.0 }
#default{ finish{ ambient 0.1 diffuse 0.9 }}
//--------------------------------------------------------------------------
#include "colors.inc"
#include "textures.inc"
#include "glass.inc"
#include "metals.inc"
#include "golds.inc"
#include "stones.inc"
#include "woods.inc"
#include "shapes.inc"
#include "shapes2.inc"
#include "functions.inc"
#include "math.inc"
#include "transforms.inc"
//--------------------------------------------------------------------------
// camera ------------------------------------------------------------------
#declare Camera_0 = camera {/*ultra_wide_angle*/ angle 75      // vista frontale
                            location  <0.0 , 2.0 ,-8.0>
                            right     x*image_width/image_height
                            look_at   <0.0 , -1.0, 0.0>}
#declare Camera_1 = camera {/*ultra_wide_angle*/ angle 70   // vista diagonale
                            location  <4.0 , 7.5 ,-5.0>
                            right     x*image_width/image_height
                            look_at   <1.0 , 0.0 , -2.5>}
#declare Camera_2 = camera {/*ultra_wide_angle*/ angle 90 // vista lato destro
                            location  <4.0 , 1.0 , 0.0>
                            right     x*image_width/image_height
                            look_at   <0.0 , 0.0 , 0.0>}
#declare Camera_3 = camera {/*ultra_wide_angle*/ angle 40        // vista dall'alto
                            location  <0.0 , 20.0 ,-2.00-0.001>
                            right     x*image_width/image_height
                            look_at   <0.0 , 1.0 , -2.00>}
camera{ Camera_0 }

// sole ---------------------------------------------------------------------
light_source{<-3500,2000,-1500> color rgb<1,0.85,0.85> }

// cielo ---------------------------------------------------------------------
plane{<0,2,0>,2 hollow 
       texture{ pigment{ bozo turbulence 0.95
                         color_map { [0.00 rgb <0.25, 0.32, 1.0>*0.8]
                                     [0.50 rgb <0.25, 0.32, 1.0>*0.8]
                                     [0.70 rgb <1,1,1>]
                                     [0.85 rgb <0.25,0.25,0.25>]
                                     [1.0 rgb <0.5,0.5,0.5>]}
                        scale<1,1,1.5>*2.5  translate<-2,0,0>
                       }
                finish {ambient 1 diffuse 0} }     
       scale 10000}

// nebbia sul terreno -------------------------------------------------
fog { fog_type   2
      distance   75
      color      White 
      fog_offset 0.1
      fog_alt    2.5
      turbulence 1.8
    }
//---------------------------------------------
//----------------------------- Piscina trama
#declare Piscina_Tex =
          texture{ T_Wood4
            finish { specular 0.25 roughness 0.115 ambient 0.2 }
                  
                 } // fine della trama

//---------------------------------------------
//----------------------------- Piscina dimensioni
#declare Piscina_X = 5.00;
#declare Piscina_Y = 2.00;
#declare Piscina_Z = 8.00;
#declare Piscina_Interno_Size = <5,-2,8>;
#declare Bordo = 0.30; 

//---------------------------------------------
#declare Piscina_Transformation =
  transform{ rotate<0,0,0>
             translate<-2.5,0.10,-6>
           } // fine della trasformazione
//---------------------------------------------
#declare Piscina_Interno =
  box{<0,-Piscina_Y,0>,<Piscina_X,Piscina_Y,Piscina_Z>  
     } //--------------------------------------
#declare Piscina_Esterno =
  box{<-Bordo, -Piscina_Y-0.01, -Bordo> ,
      <Piscina_X+Bordo,0.001,Piscina_Z+Bordo>
     } //--------------------------------------
//---------------------------------------------
#declare Piscina =
difference{
 object{ Piscina_Esterno texture{Piscina_Tex}}
 object{ Piscina_Interno texture{Piscina_Tex}}
} // fine della differenza
//--------------------------------------------- 

// terreno erboso
difference{
 plane{ <0,1,0>, 0
        texture{
         pigment{ color rgb<0.35,0.65,0>*0.7}
         normal { bumps 0.75 scale 0.015 }
         finish { phong 0.1 }
        } // fine della trama   
      }// fine del piano
 object{ Piscina_Esterno 
        texture{ Piscina_Tex }
         transform Piscina_Transformation
       } // buco della piscina
} // fine del terreno
//---------------------------------------
//---------------------------------------
// Mettere la piscina:
object{ Piscina
        transform Piscina_Transformation }  
//---------------------------------------  
//---------------------------------------  

// acqua trasparente //-------------
#declare Acqua_materiale = 
material{   
 texture{
   pigment{ rgbf <0.92,0.99,0.96,0.45> }
   finish { diffuse 0.1 reflection 0.3 
            specular 0.8 roughness 0.0003
            phong 1 phong_size 400}
 } // fine della trama --------------------
 interior{ ior 1.3 caustics 0.15 
 } // fine di interior -------------------
} // fine del materiale --------------------

//---------------------------------------
// modulazione del materiale Pigmento 
#declare Pigment_01 = 
 pigment{ bumps
          turbulence 0.30
          scale <3,1,3>*0.12
          translate<1,0,0>
 } // fine del pigmento
//---------------------------------------
#declare Pigment_Function_01 =
function {
  pigment { Pigment_01 }
} // fine della funzione
//---------------------------------------
// modulazione della funzione pigmento

isosurface {
 function{
   y
   +Pigment_Function_01(x,y,z).gray*0.2 
 } //
 contained_by{
   box{<-Bordo,-Piscina_Y-1.01,-Bordo>,
       < Piscina_X+Bordo,1, Piscina_Z+Bordo>
      } //
    } // fine di contained_by
 accuracy 0.01
 max_gradient 2
 material{ Acqua_materiale }

 // scalare the Pigment_01 se necessario! 
 transform  Piscina_Transformation 
} // fine di isosurface ------------------
Here is the picture resulted from the file:


sabato 7 marzo 2015

A whole scene example

This is another example of a whole scene constructed with POV Ray, the picture is based on the woodbox.pov file; has been recreated modifing position and other charactheristic of the example.

// POV-Ray 3.7 Scene File "Prova6.pov"   basato su woodbox
// author:  Max
// Date:   07/03/2015

#version 3.7;
global_settings { assumed_gamma 1.2 }

#include "colors.inc"
#include "textures.inc"
#include "shapes.inc"
#include "metals.inc"
#include "glass.inc"
#include "woods.inc"

camera {
   location <-5, 22, -26.5>
   angle 45
   right x*image_width/image_height
   look_at <0,0,0>
}


#declare Dist=80.0;
light_source {< -50, 25, -50> color White
     fade_distance Dist fade_power 2
  area_light <-40, 0, -40>, <40, 0, 40>, 3, 3
   adaptive 2
   jitter
}
light_source {< 50, 10,  -4> color Gray30
     fade_distance Dist fade_power 2
  area_light <-20, 0, -20>, <20, 0, 20>, 3, 3
   adaptive 1
  jitter
}
light_source {< 0, 200,  0> color Gray30
     fade_distance Dist fade_power 1
        area_light <-30, 0, -30>, <30, 0, 30>, 3, 3
        adaptive 1
        jitter
}

sky_sphere {
    pigment {
        gradient y
        color_map {
            [0, 1  color Gray60 color Gray80]
        }
    }
}

#declare M_Legno18b =
colour_map {
    [0.00 0.35   color rgbf < 0.50, 0.26, 0.12, 0.10>
                 color rgbf < 0.54, 0.29, 0.13, 0.20>]
    [0.35 0.45   color rgbf < 0.54, 0.29, 0.13, 0.20>
                 color rgbf < 0.55, 0.28, 0.10, 0.70>]
    [0.45 0.50   color rgbf < 0.55, 0.28, 0.10, 0.70>
                 color rgbf < 0.50, 0.23, 0.15, 0.95>]
    [0.50 0.70   color rgbf < 0.50, 0.23, 0.15, 0.95>
                 color rgbf < 0.56, 0.29, 0.17, 0.70>]
    [0.70 0.95   color rgbf < 0.56, 0.29, 0.17, 0.70>
                 color rgbf < 0.54, 0.29, 0.13, 0.20>]
    [0.95 1.00   color rgbf < 0.54, 0.29, 0.13, 0.20>
                 color rgbf < 0.50, 0.26, 0.12, 0.10>]
}


#declare Trama_pavimento =
    texture { pigment { P_WoodGrain18A color_map { M_Wood18A }}}
    texture { pigment { P_WoodGrain12A color_map { M_Legno18b }}}
    texture {
        pigment { P_WoodGrain12B color_map { M_Legno18b }}
        finish { reflection 0.25 }
    }

#declare Pavimento =
plane { y,0
    texture { Trama_pavimento
        scale 2.5
        rotate y*90
        rotate <10, 0, 15>
        translate z*4
    }
}

#declare T0 = texture { T_Wood15 }

#declare T =
texture { T0
    finish { specular 0.50 roughness 0.1 ambient 0.25 }
}

#declare T1 = texture { T translate  x*10 rotate <0, 87, 0> }
#declare T2 = texture { T translate  y*10 rotate <0,  1, 0> }
#declare T3 = texture { T translate -x*10 rotate  <0, 90, 0> translate z*10}

#declare Pannello_frontale =
box      { <-5.75, 0.00, -0.5>,
           < 5.75, 1.75,  0.0> }

#declare Bordo_fronte_alto   =
cylinder { <-5.75, 1.75,  0.0>,
           < 5.75, 1.75,  0.0>, 0.5 }

#declare Bordo_fronte_destro =
cylinder { < 5.75, 0.00,  0.0>,
           < 5.75, 1.75,  0.0>, 0.5 }

#declare Bordo_fronte_sinistro  =
cylinder { <-5.75, 0.00,  0.0>,
           <-5.75, 1.75,  0.0>, 0.5 }

#declare Angolo_as_fronte  = sphere   { <-5.75, 1.75,  0.0>, 0.5 }
#declare Angolo_ad_fronte  = sphere   { < 5.75, 1.75,  0.0>, 0.5 }


#declare Pannello_sinistro      = box { <-0.50, 0, -5.75>, <0.50, 1.75, 5.75> }
#declare Bordo_sinistro_alto   = cylinder { <0, 1.75, -5.75>, <0, 1.75, 5.75>, 0.5 }

#declare Parte_sinistra =
intersection {
    union {
        object { Pannello_sinistro       }
        object { Bordo_sinistro_alto    }
    }
    plane { x, 0 }
    texture { T2 scale 2.5}
    bounded_by { box { <-0.501, 0.01, -5.251>, <0.01, 2.251, 5.251> } }
}

#declare Fronte_scatola =
intersection {
    union {
        object { Pannello_frontale      }
        object { Bordo_fronte_alto   }
        object { Bordo_fronte_sinistro  }
        object { Bordo_fronte_destro }
        object { Angolo_as_fronte  }
        object { Angolo_ad_fronte  }
    }
    plane { z, 0 }
    texture { T1 scale 2.5}
    bounded_by { box { <-6.251, 0.01, -0.51>, <6.251, 2.251,  0.01> }}
}
#declare Fondo_scatola = box {<-5.75, 0.0, -5.75> <5.75, 0.25, 5.75> texture {T3} }
#declare Coperchio_scatola =    box {<-5.75, 0.0, -5.75> <5.75, 0.25, 5.75>
    translate -5.25*z    // mette il fulcro nell'origine
    rotate x*35          // apre il coperchio
    translate 5.25*z     // muove il fulcro indietro e
    translate y*2        //sposta in alto
    texture {T3 scale 2.5}
}
#declare Scatola =
union {
    object { Fronte_scatola translate -z*5.25}
    object { Fronte_scatola scale <1,1,-1> translate z*5.25}
    object { Parte_sinistra translate -x*5.75 }
    object { Parte_sinistra scale <-1,1,1> translate x*5.75 }
    object { Coperchio_scatola  }
    object { Fondo_scatola }
}
#declare Sfere =
union {

    // Nella scatola
    sphere { <1.5, 1.5, -0.75>, 1.25
        texture {
            T_Wood14
            finish { specular 0.35 roughness 0.05 ambient 0.3 }
            translate x*1
            rotate <15, 10, 0>
            translate y*2
        }
    }
    // Nella scatola
    sphere { <-1.5, 1.25,  0.5>, 1
        texture { T_Wood18
            finish { specular 0.25 roughness 0.025 ambient 0.35 }
            scale 0.33
            translate x*1
            rotate <10, 20, 30>
            translate y*10
        }
    }
    // Nella scatola
    sphere { <-0.75, 1.0, -1.5>, 0.75
        texture { T_Wood10
            finish { specular 0.5 roughness 0.1 ambient 0.35 }
            translate x*1
            rotate <30, 10, 20>
        }
    }

    // Fuori dalla scatola
    sphere { <-0.75, 0.75, -7.5>, 0.75
        texture { T_Wood4
            finish { specular 0.25 roughness 0.115 ambient 0.2 }
        }
    }
    // Fuori dalla scatola
    sphere { <-2.25, 0.45, -7.5>, 0.45
        texture { T_Wood20
            finish { specular 0.15 roughness 0.15 ambient 0.3 }
            rotate <45, 10, 45>
            translate x*10
        }
    }

    // Fuori dalla scatola
    sphere { <-7.5, 0.95, 0.8>, 0.95
    
      material {
        texture {
          pigment { color rgbf <0.98, 1.0, 0.99, 0.75> }
          finish { F_Glass4 }
          }
        interior {I_Glass caustics 1}
        }
      }
    // Fuori dalla scatola 
    sphere { <-15.5, 0.95, 0.8>, 1.2
      material {
        texture {
          pigment { color rgbf <0.98, 1.0, 0.99, 0.75> }
          finish { F_Glass4 }
          }
        interior {I_Glass caustics 1}
        }
      } 
    // Fuori dalla scatola
    sphere { <-7.00, 0.75, -2.0>, 0.75 texture { T_Copper_2B} }
    // Fuori dalla scatola
    sphere { <-1.75, 0.40, -7.4>, 0.40 texture { T_Brass_3B} }
}
union {
    object { Pavimento }
    object { Scatola }
    object { Sfere }
    rotate -y*45
}


Here the picture generated.

domenica 1 marzo 2015

Vortex simulation

How to create a simple vortex on POV Ray, using the instruction union and difference.
// POV-Ray 3.7 Scene File "Prova4.pov"
// author:  Max
// Date:   01/03/2015
//--------------------------------------------------------------------------
#if (version < 3.7) global_settings{ assumed_gamma 1.0 } #end
//--------------------------------------------------------------------------
#include "colors.inc"
#include "textures.inc"
//--------------------------------------------------------------------------
// camera ------------------------------------------------------------------
#declare Camera_0 = camera {ultra_wide_angle angle 65          // vista frontale
                            location  <0.0 , 3.0 ,-3.5>
                            right     x*image_width/image_height
                            look_at   <0.0 ,-0.5 , 0.0>}
camera{Camera_0}

// sole ---------------------------------------------------------------------
light_source{<1500,3000,-3000> color White}
// cielo ---------------------------------------------------------------------
plane{<0,1,0>,1 hollow no_shadow
       texture{ pigment{ Bright_Blue_Sky scale 1
                        }
                finish {ambient 1 diffuse 0} }     
       scale 10000}
// nebbia ---------------------------------------------------------------------

fog{fog_type   2
    distance   20
    color      rgb<1,0.98,0.9>
    fog_offset 0.1
    fog_alt   1
    turbulence 0.8}
 
   
// terreno ------------------------------------------------------------------
// dimensioni del foro:
#declare ForointernoR = 1.00;
#declare Foroscala  = 1.25;
#declare ForoR      = 0.75;

//-------------------------
// piano forato:
union{
difference{

plane{<0,1,0>, 0 }
cylinder{<0,-ForoR,0>, <0,0.001,0>,ForointernoR+ForoR scale Foroscala}
cylinder{<0,  -100,0>, <0,0.001,0>,ForointernoR scale Foroscala}
          } // fine della differenza
         
torus{ ForointernoR+ForoR, ForoR
       translate<0,-ForoR,0>scale Foroscala}

 texture{Polished_Chrome 
         normal {spiral1  20  0.25  sine_wave   
                 turbulence 0.1 rotate<90,0,0> scale <0.25,0.5,0.25> }
         finish {ambient 0.15 diffuse 0.85 reflection 0.35}}
 } // fine dell'unione 

 //sfera sospesa
 sphere { <0,-ForoR,0>, ForoR/3

        texture { pigment{ color rgb<0.75, 0.75, 0.75>}
                  finish { phong 1.0 reflection 0.01}
                }

          scale<1,1,1>  rotate<0,0,0>  translate<0,0.5,0> 
       }  // fine della sfera -----------------------------------

//-----------------------------------------------------------------------fine

Here the picture obtained from the program written above.

A simple water scene

Here are some instruction how to create a flat water surface with a blue sky. The water effect is only simulated, no real waves are created by this code.

// POV-Ray 3.6 Scene File "Prova2.pov"
// created Max
// date:    01/03/2015

#include "colors.inc"
#include "textures.inc"
#include "textures.inc"

global_settings { assumed_gamma 1.1 }

// telecamera -----------------------------------------------------------
#declare Cam0 = camera {/*ultra_wide_angle*/ angle 65
                        location  <0.0 , 1.0 ,-3.0>
                        look_at   <0.0 , 0.8 , 0.0>}
camera{Cam0}

// sole ---------------------------------------------------------------
light_source{<1500,3000,-2500> color White}

// nebbia ---------------------------------------------------------------
fog{fog_type   2   distance 85  color rgb<1,0.99,0.9>
    fog_offset 0.1 fog_alt  2.0 turbulence 0.2}
   
// cielo ---------------------------------------------------------------------
plane{<0,1,0>,1 hollow 
       texture{ pigment{ bozo turbulence 0.99
                         color_map { [0.5 rgb <0.30, 0.30, 1.0>*1]
                                     [0.6 rgb <1,1,0.9>]
                                     [1.0 rgb <0.2,0.2,0.2>]}
                         scale 3.5 translate<10,0,9>
                       }
                finish {ambient 1 diffuse 0} }     
       scale 10000}
//--------------------------------------------------------------------------
  

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

plane{<0,1,0>, 0
      texture{pigment{ rgb <0.2, 0.2, 0.2> }
              normal { bumps 0.18 scale <1,0.25,0.35>*1 turbulence 0.8 }
              finish { ambient 0.05 diffuse 0.55
                       brilliance 6.0 phong 0.8 phong_size 120
                       reflection 0.6 }
             }
     }
//--------------------------------------------------------------------
#declare Asta_H = 1.75;
#declare Asta_R = 0.20;
#declare Asta =   // Oggetto      
union{

 cylinder {<0,-Asta_H,0>,<0,Asta_H,0>,Asta_R translate<0,0,0>
          texture{pigment{spiral1 2
                          color_map{[0.0 White]
                                    [0.5 White]
                                    [0.5 rgb<1,0.5,0>]
                                    [1.0 rgb<1,0.5,0>]}
                                    rotate<90,0,0>
                                    scale<1,0.3,1>}
                  normal {bumps 0.3 scale 0.025}
                  finish {ambient 0.05 diffuse 0.95
                          phong 1 reflection 0.05}
                  }
           }
 union{
   cylinder{<0,-0.05,0>,<0,0.05,0>,Asta_R+0.05 translate<0,Asta_H.0>}
   sphere {<0,0,0>,Asta_R+0.05 translate<0,Asta_H+0.1,0> }
   torus {1.0,0.1 scale 0.12  translate<0,Asta_H+0.01,0>}
      
   texture{pigment{color White}
           normal {bumps 0.3 scale 0.025}
           finish {ambient 0.15 diffuse 0.85 phong 1 reflection 0.05}}}
}// fine di Asta --------  

//---------------------------------------------------------------------
object{Asta scale 1 rotate<0,0,2> translate <-1.0,0,3>}     
          
//----------------------------------------------------------------- fine





domenica 21 settembre 2014

A simple POV Ray file

This is a simple demonstration of a POV Ray file, written example.

// PoVRay 3.7 Scene File " Prato.pov"
// author:  Max
// date:    13 September 2014
//--------------------------------------------------------------------------
#version 3.7;
global_settings{ assumed_gamma 1.0 }
#default{ finish{ ambient 0.1 diffuse 0.9 }} 
//--------------------------------------------------------------------------
#include "colors.inc"
#include "textures.inc"
//#include "glass.inc"
//#include "metals.inc"
//#include "golds.inc"
//#include "stones.inc"
#include "woods.inc"
#include "shapes.inc"
#include "shapes2.inc"
//#include "functions.inc"
#include "math.inc"
//#include "transforms.inc"
#include "skies.inc"

//--------------------------------------------------------------------------
// camera ------------------------------------------------------------------
#declare Camera_0 = camera {/*ultra_wide_angle*/ angle 75      // front view
                            location  <0.0 , 1.0 ,-3.0>
                            right     x*image_width/image_height
                            look_at   <0.0 , 1.0 , 0.0>}
#declare Camera_1 = camera {/*ultra_wide_angle*/ angle 90   // diagonal view
                            location  <2.0 , 4.5 ,-3.0>
                            right     x*image_width/image_height
                            look_at   <0.0 , 1.0 , 0.0>}
#declare Camera_2 = camera {/*ultra_wide_angle*/ angle 90 // right side view
                            location  <3.0 , 1.0 , 0.0>
                            right     x*image_width/image_height
                            look_at   <0.0 , 1.0 , 0.0>}
#declare Camera_3 = camera {/*ultra_wide_angle*/ angle 90        // top view
                            location  <0.0 , 3.0 ,-0.001>
                            right     x*image_width/image_height
                            look_at   <0.0 , 1.0 , 0.0>}
camera{Camera_1}
// sun ---------------------------------------------------------------------
light_source{<-1500,2000,-2500> color White}

           

// sky ---------------------------------------------------------------------

sky_sphere{ S_Cloud4  // 1 - 5
            scale 1         
          } //end of skysphere
//--------------------------------------------------------------------------


// fog ---------------------------------------------------------------------
fog{ fog_type   2
     distance   50
     color      White*0.5
     fog_offset 0.1
     fog_alt    2.0
     turbulence 0.8
   } // end of fog
//--------------------------------------------------------------------------




// fog on the ground -------------------------------------------------
fog { fog_type   2
      distance   50
      color      White  
      fog_offset 0.1
      fog_alt    1.5
      turbulence 1.8
    }

// ground ------------------------------------------------------------
plane { <0,1,0>, 0 
        texture{ pigment{ color rgb<0.35,0.65,0.0>*0.72 }
        normal { bumps 0.75 scale 0.015 }
                 finish { phong 0.1 }
               } // end of texture
      } // end of plane
//--------------------------------------------------------------------------
//---------------------------- objects in scene ----------------------------
//--------------------------------------------------------------------------

union {
   object{ // Wire_Box(A, B, WireRadius, UseMerge)
        Wire_Box(<-1,-0.15,-1>,<1,2,1>, 0.075   , 0)  
       
          texture{ pigment{ hexagon color White color Blue color Red }   
                finish { diffuse 0.9 phong 1 } 
                rotate<60,0,0> scale 0.05 translate<0,0,0>
              } // end of texture 
               
        scale 1  rotate<0, 0,0> translate<0,0.1,0>
      } // ---------------------------------------------   
      
             


      object{ 
         box {<-0.95,-0.10,-0.95>,<0.95,1.95,0.95>}  
       
                      texture{ T_Wood1     
                normal { wood 0.5 scale 0.05}
                finish { phong 1 } 
                rotate<0,0, 0> scale 0.5
              } // end of texture ------------------------


               
        scale 1  rotate<0, 0,0> translate<0,0.1,0>
      } // ------

    }
The result is the picture showed below.


domenica 14 settembre 2014

A new book

I've started a new book around C++ and the POV Ray program, I'm learning in these days. During the next weeks I'll post my findings and pictures related to ray tracing and application on the C++ language as a tto to extend the functionality of the POV Ray program.

Here it is the first sample picture.


sabato 8 febbraio 2014

Libro pubblicato

Ho provveduto a pubblicare su Lulu.com il libro nel quale sono raccolte le considerazioni, e i post scritti in questo blog sulla programmazione C++. Il libro è disponibile al seguente collegamento ipertestuale:
http://www.lulu.com/spotlight/MaxShire

In formato Ebook con immagini.