//crackle city scape //by tek #version 3.5; //scene controls #declare boOrthoCam = false; //set this to false for a perspective view with a nice sunset. #declare boSphereCam = false;//true; #declare gboWet = false; //includes #include "functions.inc" #include "rad_def.inc" //global set up global_settings { max_trace_level 5 radiosity { Rad_Settings(Radiosity_Fast, on, on) } photons { spacing 0.02//0.03 // specify the density of photons //count 10000 // alternatively use a total number of photons //gather min, max // amount of photons gathered during render [20, 100] //media max_steps [,factor] // media photons //jitter 1.0 // jitter phor photon rays //max_trace_level 5 // optional separate max_trace_level //adc_bailout 1/255 // see global adc_bailout //save_file "filename" // save photons to file //load_file "filename" // load photons from file //autostop 0 // photon autostop option //radius 10 // manually specified search radius // (---Adaptive Search Radius---) //steps 1 //expand_thresholds 0.2, 40 } } #default { pigment { rgb 1 } finish { diffuse 1 ambient 0 } } //city controlling functions #declare gfOneMetre = 0.01; #declare nMetric = 1; #declare fRoads = 0.3; #declare fEpsilon = 0.01; #declare pCracks = pigment { crackle solid metric nMetric poly_wave 1.5 colour_map { [0 rgb 0] [1 rgb 1] } } #declare f_Cracks1 = function { pigment { pCracks //scale 0.5 } } #declare f_Cracks2 = function { pigment { crackle metric nMetric pigment_map { [0.0 rgb 0] [1.0 rgb 1] } //scale 0.5 } } //textures #declare gfWindowHeight = 2; #macro m_RoadTextureMap( fRoadAndPathWidth ) #local fRoadWidth = fRoadAndPathWidth*0.8; //create elements to go in a texturemap statement. #local tCentreStripe = texture { pigment { rgb 1 } finish { specular 0.3 roughness 0.03 } scale gfOneMetre } #local tEdgeStripe = texture { pigment { rgb <1,1,0> } finish { specular 0.3 roughness 0.03 } scale gfOneMetre } #local tTarmac = texture { pigment { rgb 0.2 } finish { specular 1 roughness 0.2 #if ( gboWet ) reflection { 0.3, 0.8 } #else //reflection { 0.15 } #end //if gboWet } normal { //facets 10 //coords 0.06 spotted 10 scale 0.02 } scale gfOneMetre } #local tPavement = texture { pigment { rgb 0.7 } finish { #if ( gboWet ) specular 1 roughness 0.03 reflection 0.3 diffuse 0.7/fBmod #else specular 0.2 roughness 0.07 #end //if gboWet } normal { spotted 1 scale 0.06 } scale gfOneMetre } [fRoadWidth*0.03 tCentreStripe] [fRoadWidth*0.03 tTarmac] [fRoadWidth*0.45 tTarmac] [fRoadWidth*0.45 tCentreStripe] [fRoadWidth*0.50 tCentreStripe] [fRoadWidth*0.50 tTarmac] [fRoadWidth*0.90 tTarmac] [fRoadWidth*0.90 tEdgeStripe] [fRoadWidth*0.93 tEdgeStripe] [fRoadWidth*0.93 tTarmac] [fRoadWidth*1.00 tTarmac] [fRoadWidth*1.00 tPavement] #end //macro #declare tBuildings = texture { #local fWindowBar = 0.1; function { min ( min ( x-floor(x), 1-x+floor(x) ), min ( min ( y-floor(y), 1-y+floor(y) ), 1//min ( z-floor(z), 1-z+floor(z) ) ))*2 } texture_map { [fWindowBar pigment { rgb 0.3 } finish { specular 0.3 roughness 0.1 } //pigment { rgb 1 } ] [fWindowBar #local fLightsOn = 0;//0.5; //0 = no lights on 1 = all lights on cells warp { repeat z } //don't randomize values along z, because we have no window bars along z. texture_map { [fLightsOn pigment { rgb <1.2,1.1,1>*0.7 }//<1,0.8,0.6> } finish { reflection { 0.5, 1.0 } conserve_energy diffuse 0 ambient 0.5 specular 1 roughness 0.004 } normal { spotted 0.1 scale 3 warp { repeat x offset y } warp { repeat y offset z } //warp { repeat z offset x } } ] [fLightsOn pigment { rgb <0.3,1,0.7>*0.1 } finish { reflection { 0.5, 1.0 } conserve_energy diffuse 0.5 ambient 0 specular 1 roughness 0.004 } normal { spotted 0.1 scale 3 warp { repeat x offset y } warp { repeat y offset z } //warp { repeat z offset x } } ] } //texture map (cells) ] } //texture map (window/frame) scale <1,gfWindowHeight,1>*gfOneMetre rotate <0,22.5,0> //misalign it from the building edges (which all seem to lie at 45 degrees) } //texture //objects #declare oCrackScape = isosurface { function { min ( max ( y - int(f_Cracks1(x,0,z).red*3/(gfWindowHeight*gfOneMetre))*(gfWindowHeight*gfOneMetre), //quantise to window height, so it always meets the edge of a window :) fRoads - f_Cracks2(x,0,z).red ), y ) } max_gradient 3 accuracy 0.0002 contained_by { sphere { 0, 100 } } //plane { y, 0 texture { function { f_Cracks2(x,0,z).red } texture_map { m_RoadTextureMap( fRoads-fEpsilon ) [fRoads-fEpsilon tBuildings ] /*[fRoads+fEpsilon tBuildings ] [fRoads+fEpsilon pigment { rgb 1 } ]*/ } } } //the scene camera { #if ( boOrthoCam ) orthographic #end #if ( boSphereCam ) spherical #end #declare fOrthoSize = 0.3;//40; #declare image_dim = sqrt(image_width*image_height); //kind of average dimension right x*image_width/image_dim*fOrthoSize up y*image_height/image_dim*fOrthoSize direction z*fOrthoSize*0.5 #if ( boSphereCam ) #local fAngle = 120; h_angle fAngle*image_width/image_dim v_angle fAngle*image_height/image_dim #end rotate <-30,-20,0> #declare vCamPos = <0,0,-2>; #declare vCamPos = trace ( oCrackScape, vCamPos + y*100, -y ); #declare vCamPos = vCamPos + 1.4*gfOneMetre*y;// + <0,1.5,0.02>;// translate vCamPos #if ( boOrthoCam ) location vCamPos+10*y//<1,1,-1>*20 look_at vCamPos #end } #declare gvSunDir = vnormalize(<2,3,1>); sky_sphere { pigment { spotted scale 0.004 poly_wave 20 colour_map { [0.0 rgb 0] [1.0 rgb 5] } } pigment { bozo scale 0.7 colour_map { [0 rgb <1,0,3>/3 transmit 0.1] [1 rgb <0,2,3>/3 transmit 0.1] } } //sun pigment { gradient gvSunDir scale 2 translate -gvSunDir poly_wave 50 colour_map { [0 rgb <3,2,1>*0.3+0.7 transmit 1] [1 rgb <3,2,1>*0.3+0.7 transmit 0] } } //cunning cloud trick pigment { wrinkles scale <0.7,0.3,0.7> translate 0.03*y poly_wave 2.5 colour_map { [0.0 rgb 1.5 transmit 1] [1.0 rgb 1.5 transmit 0] } //translate -0.2*y } pigment { wrinkles scale <0.7,0.3,0.7> poly_wave 2.5 colour_map { [0.0 rgb 0.5 transmit 1] [1.0 rgb 0.5 transmit 0] } //translate -0.2*y } } light_source { gvSunDir*10000 rgb <3,2,1>*0.2 + 0.8 //area_light x*100,y*100,8,8 circular orient photons { refraction on reflection on //area_light } } /* light_source { <-1,0.5,2>*10000 rgb 0.1 shadowless //area_light x*100,y*100,8,8 circular orient } */ object { oCrackScape bounded_by { sphere { vCamPos, 3 } } //this rather neatly restricts the area photons are fired at to be only around the camera. photons{ target 1.0 // spacing multiplier for photons hitting the object refraction on reflection on //collect off // ignore photons //pass_through // do not influence photons } }