sabato 15 agosto 2015

Still learning

For new raytraced stuff, I started learning human 3D modeling.
Here some picture of example of CGI.






Now it's time to improve the quality of the models created.

mercoledì 5 agosto 2015

A coloumn in the water

A different picture created using a code with sea surface definition ad a new sky.

#version 3.6; // 3.7;
global_settings{ assumed_gamma 2.0

noise_generator 2 }
  
#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      // 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 , 2.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_0}   

//radiosità-----------------------------------------------------------------

 


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

// 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}
// nebbia ---------------------------------------------------------------------
fog{fog_type   2
    distance   50
    color      White
    fog_offset 0.1
    fog_alt    2.0
    turbulence 0.8}


//--------------------------------------------------------------------------
//---------------------------- oggetti in scena ----------------------------
//--------------------------------------------------------------------------

    #declare Acqua_trama = texture{ Polished_Chrome }

// pigmento per la modulazione Isosurface
// e trama pigmento delle normali
#declare Pigmento_01 =
pigment { bumps  
          turbulence 0.17
          scale <2,1,1>
} // fine pigmento
//---------------------------------------
#declare Pigmento_funzione_01 =
function {
  pigment { Pigmento_01 }
} // fine della funzione
//---------------------------------------

// dimensioni x/z della scatola Isosurface
#local Scala_x = 20; 
#local Scala_z = 14;
#local Iso_inizio =<-Scala_x,-1.0,-Scala_z>;
#local Iso_fine   =< Scala_x, 1.0, Scala_z>;
//---------------------------------------
isosurface {

  function{
    y
   -Pigmento_funzione_01(x, y, z).gray* 0.92 
  } //

  contained_by { box {Iso_inizio,Iso_fine} }
  accuracy 0.01
  max_gradient 2

  texture{ Polished_Chrome
           normal { pigment_pattern {  Pigmento_01 } }
         }
  // non scalare la Isosurface!
  // scalare il Pigmento_01 se necessario! 
translate <0, -0.3, 0>
} // fine di isosurface ------------------------
//---------------------------------------------



difference{ // ci allontaniamo dalla trama del pigmento
 plane{<0,1,0>, 0 }
 box { Iso_inizio,Iso_fine  }
 texture{
    Acqua_trama 
    normal{
     pigment_pattern{ Pigmento_01 }, 5}
          }
     translate<0,0.0,0>
     }

// ------------------------------------------------------------- Nocciolo di colonna spezzata                               
// ---------------------------------------------------- "Macro Colonna_01( )
#macro Nocciolo_colonna_01 (  Nocciolo_colonna_altezza__, //
                           Colonna_suddivisione__,  // 
                           C_Raggio_base__,
                           C_Raggio_punta__
                        ) //---------------------------------
//------------------------------------------------------------------------------------
#local Taglia_punta_r__  = 2*pi*C_Raggio_punta__ /Colonna_suddivisione__*1/sqrt(2);
#local Taglia_base_r__ = 2*pi*C_Raggio_base__/Colonna_suddivisione__*1/sqrt(2);
#local Taglia_punta_distanza__ = C_Raggio_punta__  +Taglia_punta_r__ *1/sqrt(2);
#local Taglia_base_distanza__= C_Raggio_base__ +Taglia_base_r__*1/sqrt(2);
#local R_fine_ = +Taglia_base_r__*0.1;

// -----------------------------------------------------------------------------------
difference{ // nocciolo della colonna
cone { <0,0,0>,C_Raggio_base__,<0,Nocciolo_colonna_altezza__,0>,C_Raggio_punta__
     } // end of cone -----------------------------------

 #local Nr = 0;     // start
 #local Fine_nr = Colonna_suddivisione__; // end

 #while (Nr< Fine_nr)

 cone{ <Taglia_base_distanza__,-R_fine_,                          0>, Taglia_base_r__,
       <Taglia_punta_distanza__ , Nocciolo_colonna_altezza__ + R_fine_,0>, Taglia_punta_r__
       rotate<0,Nr * 360/Fine_nr,0>     
     } // fine del cono -----------------------------------
 #local Nr = Nr + 1;    // prossimo Nr
 #end // ---------------  fine del ciclo


} // fine differenza
#end //------------------------------------------------------------------ fine della macro
//------------------------------------------------------------------------------------




//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
#declare Trama_pietra = // Trama in pietra del nocciolo di colonna
         texture { T_Grnt12
                   normal { agate 0.35 scale 0.05}
                   finish { phong 0.2 }
                   scale 1
                 } // fine della trama

#declare Trama_nocciolo_colonna = // suddivisioni verticali
        texture { gradient<0,1,0> scale <1,0.67,1> turbulence 0.01 
                   texture_map{ [0.00 Trama_pietra ]
                                [0.001 pigment{ color rgb <1,1,1>*0.1} ]
                                [0.005 pigment{ color rgb <1,1,1>*0.1} ]
                                [0.006 Trama_pietra ]
                                [1.00 Trama_pietra ]
                              } // end of texture_map     
                 } // end of texture ------------------------------------
//-----------------------------------------------------------------------

//-----------------------------------------------------------------------
object{ Nocciolo_colonna_01 ( 2.0, // Column_Total_Height,  //
                           16,   // Column_Subdivision, // intero ~ 16
                           0.35, // Column_Base_Radius,
                           0.20  // Column_Top_Radius, 
                  ) //---------------------------------

        texture { Trama_nocciolo_colonna} 
        scale<1,1,1>  rotate< 0,0,0>  translate<0,-0.4,1.2> 
      } // fine di "Colonna_01(...) ---------------------------------------
//------------------------------------------------------------------- end 




Here is the picture genereated by the code.

 

martedì 4 agosto 2015

A simple way to generate a greek coloumn

Here is the code to generate with Pov Ray a greek coloumn kernel.

#version 3.6; // 3.7;
global_settings{ assumed_gamma 2.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      // 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 , 2.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_0}

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

// cielo ---------------------------------------------------------------------
sky_sphere { pigment { gradient <0,1,0>
                       color_map { [0.00 rgb <1.0,1.0,1.0>]
                                   [0.30 rgb <0.0,0.15,1.0>]
                                   [0.70 rgb <0.0,0.15,1.0>]
                                   [1.00 rgb <1.0,1.0,1.0>]
                                 }
                       scale 2        
                     } // end of pigment
           } //end of skysphere

// nebbia ---------------------------------------------------------------------
fog{fog_type   2
    distance   50
    color      White
    fog_offset 0.1
    fog_alt    2.0
    turbulence 0.8}

// terreno ------------------------------------------------------------------
plane{ <0,1,0>, 0
       texture{ pigment{ color rgb <0.825,0.65,0.35>}
                normal { bumps 0.95 scale 0.025  }
                finish { phong 0.1 }
              } // end of texture
     } // end of plane
//--------------------------------------------------------------------------
//---------------------------- oggetti in scena ----------------------------
//--------------------------------------------------------------------------



// ------------------------------------------------------------- Nocciolo di colonna spezzata                               
// ---------------------------------------------------- "Macro Colonna_01( )
#macro Nocciolo_colonna_01 (  Nocciolo_colonna_altezza__, //
                           Colonna_suddivisione__,  // 
                           C_Raggio_base__,
                           C_Raggio_punta__
                        ) //---------------------------------
//------------------------------------------------------------------------------------
#local Taglia_punta_r__  = 2*pi*C_Raggio_punta__ /Colonna_suddivisione__*1/sqrt(2);
#local Taglia_base_r__ = 2*pi*C_Raggio_base__/Colonna_suddivisione__*1/sqrt(2);
#local Taglia_punta_distanza__ = C_Raggio_punta__  +Taglia_punta_r__ *1/sqrt(2);
#local Taglia_base_distanza__= C_Raggio_base__ +Taglia_base_r__*1/sqrt(2);
#local R_fine_ = +Taglia_base_r__*0.1;

// -----------------------------------------------------------------------------------
difference{ // nocciolo della colonna
cone { <0,0,0>,C_Raggio_base__,<0,Nocciolo_colonna_altezza__,0>,C_Raggio_punta__
     } // end of cone -----------------------------------

 #local Nr = 0;     // start
 #local Fine_nr = Colonna_suddivisione__; // end

 #while (Nr< Fine_nr)

 cone{ <Taglia_base_distanza__,-R_fine_,                          0>, Taglia_base_r__,
       <Taglia_punta_distanza__ , Nocciolo_colonna_altezza__ + R_fine_,0>, Taglia_punta_r__
       rotate<0,Nr * 360/Fine_nr,0>     
     } // fine del cono -----------------------------------
 #local Nr = Nr + 1;    // prossimo Nr
 #end // ---------------  fine del ciclo


} // fine differenza
#end //------------------------------------------------------------------ fine della macro
//------------------------------------------------------------------------------------




//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
#declare Trama_pietra = // Trama in pietra del nocciolo di colonna
         texture { T_Grnt12
                   normal { agate 0.35 scale 0.05}
                   finish { phong 0.2 }
                   scale 1
                 } // fine della trama

#declare Trama_nocciolo_colonna = // suddivisioni verticali
        texture { gradient<0,1,0> scale <1,0.67,1> turbulence 0.01 
                   texture_map{ [0.00 Trama_pietra ]
                                [0.001 pigment{ color rgb <1,1,1>*0.1} ]
                                [0.005 pigment{ color rgb <1,1,1>*0.1} ]
                                [0.006 Trama_pietra ]
                                [1.00 Trama_pietra ]
                              } // end of texture_map     
                 } // end of texture ------------------------------------
//-----------------------------------------------------------------------

//-----------------------------------------------------------------------
object{ Nocciolo_colonna_01 ( 2.5, // Column_Total_Height,  //
                           32,   // Column_Subdivision, // intero ~ 16
                           0.35, // Column_Base_Radius,
                           0.20  // Column_Top_Radius, 
                  ) //---------------------------------

        texture { Trama_nocciolo_colonna} 
        scale<1,1,1>  rotate< 0,0,0>  translate<0,0,0> 
      } // fine di "Colonna_01(...) ---------------------------------------
//------------------------------------------------------------------- end

The resultant picture generated by the code written above.

domenica 2 agosto 2015

Brickwall creation with POV Ray

Following this simple code, you can create a small brick wall covered by a layer of stucco. The stucco could be ruined and aged using only a parameter of a Macro. Here is the code:

#version 3.7;
global_settings { assumed_gamma 1.0
                  noise_generator 2 } // modificare in 2 o 3

light_source {
   < 800, 800,-800>
   rgb 1
}

camera {
   location  <0.2, 0.0,-28.0>
   look_at   <0.0, 0.0,  0.0>
   right x*image_width/image_height // mantenere le proporzioni dell'immagine
   angle 65
}

//====== Preparare lo stucco Stucco ======

#declare L2=0.33; //clock;  //Set amount of decay of stucco, higher value is more decay. animate
#declare PRugoso= pigment { //Cemento
   wrinkles
   scale 0.25
   colour_map {
      [0, rgb 0.5]
      [L2, rgb 0.89]
   }
}
#declare Stucco= pigment {    //Stucco
   granite
   scale 0.15
   colour_map {
      [0, rgb 0.96]
      [1, rgb 1]
   }
}

#declare Stucem= pigment {       //Stucco & Cemento
   pigment_pattern{
      wrinkles
      scale 0.25
   }
   pigment_map {
      [L2, PRugoso]
      [L2, Stucco]
   }
}

#declare HF_Stucco=height_field {  //Viene trasformato in hightfield
   function 1000, 1000{               //500,500 per il test, valori superiori vanno meglio ma controllare la memoria
      pigment{Stucem }
   }
   translate -0.5
   rotate -90*x
   scale <20,20,2>
   pigment {                         //Usare il cemento per colorare lo stucco
      pigment_pattern {
         wrinkles
         scale 0.25
      }
      color_map {
         [L2, rgb 0.5]
         [L2, rgb <1,1,0.95>]
      }
      warp {planar z, 0}
      translate <-0.5, -0.5, 0>
      rotate <180,0,0>
      scale <40,40,2>
   }
}

//====== Mettere alcuni mattoni ======

//Taglia           : dimensioni del mattone nel vettore x, y, z
//Cemento         : larghezza della giunzione.
//Turbolenza etc : controlla la deformazione della pietra.
#macro Muromatt(Taglia, Cemento, Turbolenza, Octaves, Lambda, Omega)

   #local Mattone= pigment {
      boxed                                // un mattone singolo ...
      scale <Taglia.x/2,Taglia.y/2,Taglia.z/2>
      translate <Taglia.x/2+Cemento,Taglia.y/2+Cemento,0>
      warp {repeat x*(Taglia.x+Cemento)}      // ... ripetuto molte volte.
      warp {repeat y*(2*(Taglia.y+Cemento))}
   }

   #declare FMuromatt= function {
      pigment {
         pigment_pattern {
            gradient y
            warp {repeat y}
            scale <1,2*(Taglia.y+Cemento),1>
         }
         pigment_map {
            [0.5, Mattone
                  warp {                  // deformare i mattoni ...
                     turbulence Turbolenza
                     octaves Octaves
                     lambda Lambda
                     omega Omega
                  }
                  translate <0,-(Cemento/2),0>
            ]
            [0.5, Mattone                  // ... riga per riga.
                  warp {
                     turbulence Turbolenza
                     octaves Octaves
                     lambda Lambda
                     omega Omega
                  }
                  translate <(Taglia.x/2)+Cemento,(Taglia.y+(Cemento/2)),0>
            ]
         }
      }
   }
#end

#declare Parete=pigment {
   Muromatt(<4,1.25,1>,0.3,<0.15,0.1,0>,6,0.7,0.5)
   function{FMuromatt(x,y,z).gray}
   pigment_map {                    // dare struttura ai giunti ...
      [0, granite
          scale 0.1
          colour_map {
            [0, rgb 0][1, rgb 0.3]
          }
      ]
      [0.05, crackle                // ... e ai mattoni.
             scale <3,1,1>
             turbulence 0.5
             colour_map {
               [0, rgb 0.34][1, rgb 0.5]
             }
      ]
   }
   scale 0.04
}

#declare HF_Parete=height_field {      // Costruire la parete
   function 1000, 1000 {   //500,500 per il test, valori superiori vanno meglio, ma controllare la memoria
      pigment{Parete}
   }
   smooth
   translate -0.5
   rotate <-90,0,0>
   scale <33,33,1>
   pigment {
      Parete
      pigment_map {
         [0, rgb 0.6]
         [0.05, wrinkles
                turbulence 0.3
                scale <2,0.3,1>
                colour_map {
                  [0.0, rgb <0.5,0.3,0.25>]
                  [0.15, rgb <0.5,0.3,0.25>/1.3]
                  [0.3, rgb <0.5,0.3,0.25>]
                  [0.6, rgb <0.6,0.3,0.25>/1.6]
                  [0.8, rgb <0.5,0.3,0.25>]
                  [1.0, rgb <0.5,0.3,0.35>/2]
               }
         ]
      }
      translate <-0.5, -0.5, 0>
      rotate -90*x
      warp {planar y, 0}
      scale <33,33,1>
   }
}

object {HF_Stucco}
object {HF_Parete  translate <0,0,-0.75>}


And the picture generated by the code written above.


lunedì 15 giugno 2015

Unity 3D training

I started 1 year ago my training using the Unity 3D software to develop videogames using C#.
I attach an image of a videogame developed in few weeks using this software. The game is called Corridore, is an easy infinite runner.

sabato 4 aprile 2015

A small reflective box

Here we show the code to generate a reflective box that simulate mirrors, these generates infinite reflection of objects inside the box.

#version 3.7;
global_settings {
   assumed_gamma 1.0
   max_trace_level 25
}

#default {finish {ambient 0}}

#include "colors.inc" 
#include "stones.inc"

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

#declare CamLoc = < 1.5, 3.5,-7>;

camera {
    location CamLoc
    up y*image_height/image_width  right x
    look_at < 0, 1, 0>
    angle 35
}
light_source {CamLoc, color rgb 0.3}
light_source {<-50, 150,-180>, color White}
light_source {< 20, 25, 75>, color rgb 0.5}
//*******************************************
box {<-50,-1,-50>, < 50, 0, 50>
    texture {
        pigment {checker color rgb < 0.15, 0.1, 0.5>, color White}
    }
}


#declare Bordorag = 0.05;
union {
    box {<-1, 0,-1>, < 1, 2, 1>
        texture {
            pigment {color White filter 1}
        }
        interior_texture {
            pigment {color rgb 0}
            finish {reflection 0.85}
        }
        no_shadow
    }

    cylinder {<-1, 0,-1>, < 1, 0,-1>, Bordorag}
    cylinder {< 1, 0,-1>, < 1, 0, 1>, Bordorag}
    cylinder {< 1, 0, 1>, <-1, 0, 1>, Bordorag}
    cylinder {<-1, 0, 1>, <-1, 0,-1>, Bordorag}

    cylinder {<-1, 2,-1>, < 1, 2,-1>, Bordorag}
    cylinder {< 1, 2,-1>, < 1, 2, 1>, Bordorag}
    cylinder {< 1, 2, 1>, <-1, 2, 1>, Bordorag}
    cylinder {<-1, 2, 1>, <-1, 2,-1>, Bordorag}

    cylinder {<-1, 0,-1>, <-1, 2,-1>, Bordorag}
    cylinder {< 1, 0,-1>, < 1, 2,-1>, Bordorag}
    cylinder {< 1, 0, 1>, < 1, 2, 1>, Bordorag}
    cylinder {<-1, 0, 1>, <-1, 2, 1>, Bordorag}

    sphere {<-1, 0,-1>, Bordorag*2}
    sphere {< 1, 0,-1>, Bordorag*2}
    sphere {< 1, 0, 1>, Bordorag*2}
    sphere {<-1, 0, 1>, Bordorag*2}

    sphere {<-1, 2,-1>, Bordorag*2}
    sphere {< 1, 2,-1>, Bordorag*2}
    sphere {< 1, 2, 1>, Bordorag*2}
    sphere {<-1, 2, 1>, Bordorag*2}

    texture {
        pigment {color Red}
    }
    translate y*Bordorag
}


sphere {< 0.3, 1.5, 0.4>, 0.35
    texture {
        pigment {color rgb < 0.5, 0, 0>}
        finish {
            reflection {0.5 metallic}
            diffuse 0.4

            brilliance 2
            specular 1 roughness 0.01
            metallic
        }
    }
}

sphere {<-0.5, 0.5,-0.2>, 0.1
    texture {
        pigment {color rgb < 1, 1, 0>}
        finish {
            reflection {0.5 metallic}
            diffuse 0.4

            brilliance 2
            specular 1 roughness 0.01
            metallic
        }
    }
}
box {<-0.3,-0.1,-0.2>, < 0.5, 0.1, 0.2>
   
             texture { T_Grnt5
                 //normal { agate 0.15 scale 0.15}
                   finish { phong 0.5 }
                   scale 1
                 } // end of texture

    translate < 0.5, 0.3,-0.5>
}

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

Here is the picture generated by the code:

sabato 21 marzo 2015

A simple way to create a dust whirpool

Here we show how to create a simple picture of a dust whirpool, using the scattering media materials generated by POV Ray.

#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_posizione = < 0.00, 1.70,-5.50>;  // vista frontale
#declare Camera_guarda_a = < 0.00, 3.2, 0.00>;
#declare CAmera_angolo = 55 ; // in gradi
//--------------------------------------------------------------------------------------------------------<<<<
camera{ /*ultra_wide_angle*/  
        location CAmera_posizione
        right     x*image_width/image_height
        angle CAmera_angolo  
        look_at   Camera_guarda_a
      }
//------------------------------------------------------------------------------------------------------<<<<<
//------------------------------------------------------------------------------------------------------<<<<<

// sole ---------------------------------------------------------------------
light_source{<1500,2500,-2500> color White*0.85}          
// cielo ---------------------------------------------------------------------

sky_sphere { pigment { gradient <0,1,0>
                       color_map { [0.00 rgb <1.0,1.0,1.0>*0.5]
                                   [0.30 rgb <0.4,0.4,1.0>*0.5]
                                   [0.75 rgb <0.4,0.4,1.0>*0.5]
                                   [1.00 rgb <1.0,1.0,1.0>*0.5]
                                 }
                       scale 3        
                     }
           } //fine del cielo
// nebbia ---------------------------------------------------------------------
fog{fog_type   2
    distance   50
    color      White*0.5
    fog_offset 0.1
    fog_alt    2.0
    turbulence 0.8}

// terreno ------------------------------------------------------------------
plane{ <0,1,0>, 0
       texture{ pigment{ color rgb <1.00,0.95,0.85>*0.5} 
                normal { bumps 0.95 scale 0.025  }
                finish { phong 0.1 }
              } //fine della trama
     } // fine del piano

//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//---------------------------- oggetto in scena ----------------------------
//--------------------------------------------------------------------------


// oggetto di diffusione della luce "tornado di polvere"

cylinder{ <0,0,0>,<0,100,0>,1.5
        pigment { rgbt 1 }
        hollow  

       interior{ //---------------------
          media{ scattering{ 1, <1,1,1> 
                             extinction  2.5 }
                 absorption rgb< 0.65, 0.89, 0.89>*2
                 // densità 1
                 density{ spiral2 8
                          turbulence 0.25
                          color_map {
                                [0.00 rgb 0.00] // bordo
                                [0.50 rgb 0.20] //
                                [1.00 rgb 1.00] // centro
                              } // fine della color_map 
                          rotate<90,0,0>
                          scale<1,0.5,1>
                        } // fine della densità 1
                 // densità 2
                 density{ cylindrical
                     turbulence 1.5
                     frequency 1
                       color_map {
                                [0.00 rgb 0.00] // bordo
                                [0.50 rgb 0.25] //
                                [0.85 rgb 1.00] //
                                [1.00 rgb 0.50] // centro
                              } // end color_map 
                     scale<1,1,1>
                     } // fine della densità 2
                
               }
            } // fine dell'interior


 rotate<0,0,-25>
 translate <   0.00, 0.15, 0.5>
}

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


Here is the picture generated by the code:

martedì 17 marzo 2015

How to create a rocky crater

In this post we will sho how to use the command height_field, to generate a rocky crater picture using POV Ray. First of all, a data picture have to be generated using greyscale and some tricks to have 2D for the crater.
Here is the code to generate the picture map.
#version 3.7;
global_settings { assumed_gamma 2.0 hf_gray_16 }


#include "colors.inc"

// piano colorato con pieghe

plane {z,10
 hollow on
 pigment{wrinkles
  color_map{
   [0 White*0.4]
   [1 White]
  }
 }
}

// Luce principale crea il cratere maggiore
light_source {0 color 1  spotlight point_at z*10
  radius 7 falloff 11
}

// Luce fioca addolcisce i bordi esterni del cratere
light_source {0 color .25  spotlight point_at z*10
  radius 2 falloff 15
}
                                                                      
// Luce stretta crea il picco centrale
light_source {0 color .3  spotlight point_at z*10
  radius 0 falloff 1.3
}

// Luce spot negativa crea interno del cratere
light_source {0 color -0.9  spotlight point_at z*10
  radius 5 falloff 9.5
}  

// Luce negativa stretta contrasta il luce del picco centrale
light_source {0 color -.25  spotlight point_at z*10
  radius 3 falloff 8
}
 //Luce spostata crea un secondo cratere
light_source {0 color 0.5  spotlight point_at z*10  translate <1,1.5,0> 
  radius 0.1 falloff 5
}


// Luce fioca negativa spostata crea interno del secondo cratere
light_source {0 color -0.30  spotlight point_at z*10 translate <1,1.5,0> 
  radius 0.2 falloff 2
}

light_source {0 color 0.5  spotlight point_at z*10 translate <-2,-1.5,0>
  radius 3 falloff 11
}

The picture generated by this code is below.





A second file is needed to generate the final 3D picture of the crater.
The code is below.
#version 3.7;
global_settings { assumed_gamma 1.5 }

#include "colors.inc"
#include "stones.inc"


camera{ location <0,14,-24>
        right     x*image_width/image_height
        direction z*5
        look_at 0
      }

light_source{<1000,2000,-2000> White}

height_field {
  "crater_dat.png" smooth
                  texture{ T_Stone1
                normal { agate 0.25 scale 0.10 rotate<0,0,0> }
                finish { phong 2 }
                rotate<0,0,0> scale 1.5 translate<0,0,0>
              } // end of texture



  translate <-.5, 0, -.5>
  scale <17, 1.75, 17>
}


Final picture obtained using the height_field command is this.


domenica 15 marzo 2015

Floating objects on sea

Here it is an example how to combine Isosurface command, and functions to create a picture of objects floating on the sea.
Please following the code below:
// POV-Ray 3.7 Scene File "Prova8.pov"
// 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 , 3.0 ,-12.0>
                            right     x*image_width/image_height
                            look_at   <0.0 , 1.0 , 0.0>}

camera{Camera_0}

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

// cielo ---------------------------------------------------------------------
plane{<0,2,0>,2 hollow 
       texture{ pigment{ bozo turbulence 0.95
                         color_map { [0.00 rgb <0.25, 0.30, 1.0>*0.7]
                                     [0.50 rgb <0.25, 0.30, 1.0>*0.7]
                                     [0.70 rgb <1,1,0.9>]
                                     [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< 0,0,0>
                       }
                finish {ambient 1 diffuse 0} }     
       scale 10000}

// nebbia sullo sfondo -------------------------------------------------
fog { fog_type   2
      distance   75
      color      White 
      fog_offset 0.1
      fog_alt    2.5
      turbulence 1.8
    }
// -------------------------------------------------------------------



//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
#declare Acqua_trama = texture{ Polished_Chrome }

// pigmento per la modulazione Isosurface
// e trama pigmento delle normali
#declare Pigmento_01 =
pigment { bumps  
          turbulence 0.17
          scale <2,1,1>
} // fine pigmento
//---------------------------------------
#declare Pigmento_funzione_01 =
function {
  pigment { Pigmento_01 }
} // fine della funzione
//---------------------------------------

// dimensioni x/z della scatola Isosurface
#local Scala_x = 20; 
#local Scala_z = 14;
#local Iso_inizio =<-Scala_x,-1.0,-Scala_z>;
#local Iso_fine   =< Scala_x, 1.0, Scala_z>;
//---------------------------------------
isosurface {

  function{
    y
   -Pigmento_funzione_01(x, y, z).gray* 0.92 
  } //

  contained_by { box {Iso_inizio,Iso_fine} }
  accuracy 0.01
  max_gradient 2

  texture{ Polished_Chrome
           normal { pigment_pattern {  Pigmento_01 } }
         }
  // non scalare la Isosurface!
  // scalare il Pigmento_01 se necessario! 
translate <0, -0.3, 0>
} // fine di isosurface ------------------------
//---------------------------------------------



difference{ // ci allontaniamo dalla trama del pigmento
 plane{<0,1,0>, 0 }
 box { Iso_inizio,Iso_fine  }
 texture{
    Acqua_trama 
    normal{
     pigment_pattern{ Pigmento_01 }, 5}
          }
     translate<0,0.0,0>
     }

//cornice di legno
difference{
box{ <-7.00,-1.00, 0.00>,< 0.00, 0.50, 7.00> } 
box{ <-6.70,-1.11, 0.50>,<-0.50, 0.61, 6.70> } 

     texture { T_Wood1
               finish { phong 1 }
             } // end of texture

     rotate<0,45,0> translate<0,0,-5>
   } // fine della cornice  ---------------------------


//sfera galleggiante
 sphere { <0,0.2,0>, 1

        texture { T_Wood3
                  finish { phong 1.0 reflection 0.01}
                }

          scale<1,1,1>   
       }  // fine della sfera -----------------------------------


Here is the picture generated by the code.

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.