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: