POV-Ray : Newsgroups : povray.general : Help with Blobs : Re: Help with Blobs Server Time
29 Jul 2024 12:28:34 EDT (-0400)
  Re: Help with Blobs  
From: Norbert Kern
Date: 17 Oct 2012 12:00:01
Message: <web.507ed48f2980527cc21bdf370@news.povray.org>
"Stephen" <mcavoys_AT_aolDOT.com> wrote:

> I must admit that the IRTC is a resource I seldom use.

Of course it's a personal style question.
Personally I always look first to existent codes.

One good spline hourglass solution comes frm Tekno Frannansa (IRTC round
Desert), which I changed a bit for a wallpaper of my own...

Code is:

//our time is running out, our time is running out, can't put us on the ground,
you can't stop us screaming out, how did it come to this?
//+kfi0 +kff1 (remove these to render only pass 2)

//scene switches, these sometimes get overridden later.
#if (1)
 //standard
 #declare glassEnabled = on;
 #declare rad = on;
 #declare useRadFile = off;
 #declare areaLights = on;
 #declare hfMip = 0;
 #declare maxInter = 12;
#else
 //low quality test
 #declare glassEnabled = off;
 #declare rad = off;
 #declare useRadFile = off;
 #declare areaLights = off;
 #declare hfMip = 2;
 #declare maxInter = 10;
#end

#include "rad_def.inc"
#include "shapes.inc"

global_settings {
        assumed_gamma 2.2
 max_intersections maxInter
#if (rad)
 radiosity {
         brightness 1
  #if (!useRadFile | frame_number<final_frame)
   Rad_Settings(Radiosity_Fast,on,on)
   #declare radRender = on;
  #end
  gray_threshold 0

 }
#end
}


#if (rad)
 #default { pigment { rgb 1 } finish { diffuse .7 ambient 0 } }
#else
 #default { pigment { rgb 1 } finish { diffuse .7 ambient .3 } }
#end

#declare hourglassSpline = array[9] {
  <1, -9>,
  <1, -1>,
  <0.87, -0.5>,
  <0.12, -0.1>,
  <0.007, 0>,
  <0.12, 0.1>,
  <0.87, 0.5>,
  <1, 1>,
  <1, 9>
}
#declare hourglassNumPoints = dimension_size (hourglassSpline,1);

#declare hourglassShapeInner =
 sor {
  hourglassNumPoints
  #local i=0;
  #while (i < hourglassNumPoints)
   hourglassSpline[i]
   #local i = i+1;
  #end
  sturm
  scale <1,1.5,1>
 }

#declare hourglassShapeInnerShift = //nudge outwards fractionally
 #local f = 0.005;
 sor {
  hourglassNumPoints
  #local i=0;
  #while (i < hourglassNumPoints)
   hourglassSpline[i]+f*u
   #local i = i+1;
  #end
  sturm
  scale <1,1.5,1>
 }

#declare hourglassShapeOuter =
 #local f = 0.01;
 sor {
  hourglassNumPoints
  #local i=0;
  #while (i < hourglassNumPoints)
   hourglassSpline[i]*<.92,.99>+<.08,0>+f*u
   #local i = i+1;
  #end
  sturm
  scale <1,1.5,1>
 }

//hourglass objects, origin = pinch in the glass.
union {
 #declare sand =
  texture {
   pigment {
    //checker rgb 0, rgb 1 scale .3 //surreal!
    crackle
    solid
    scale 0.001
    #local f=1;//.7; //radiosity tends to multiply the colour by itself (through
interreflection) so balance for that. maybe, or could use gray_threshold
    colour_map {
     [0 rgb <pow(0.9,f),pow(.8,f),pow(0.5,f)>] //0.9,0.8,0.5
     [1 rgb <pow(1,f),pow(1,f),pow(0.9,f)>] //1,1,0.9
    }
   }
   finish {
    //specular 1 roughness 0.01
    phong 1 phong_size 100
   }
   normal {
    facets 1
    coords 1
    scale 0.001
   }
  }

 //upper sand
 intersection {
  object { hourglassShapeInner }
  height_field {
   function 512/pow(2,hfMip), 512/pow(2,hfMip) {
    max(0,0.13+0.15*sin(pi*20*sqrt((x-0.5)*(x-0.5)+(y-0.5)*(y-0.5))))
   }
   translate -.5
   scale <2,0.4,2>
   translate 0.2*y
  }
  plane {-y,-0.02 }
  texture { sand }
  no_shadow
 }

 //lower sand
 intersection {
  object {hourglassShapeInner}
  height_field {
   function 2048/pow(2,hfMip),2048/pow(2,hfMip) {//why do programmers always use
power of 2's???! :)
    pigment {
     average
     pigment_map {
      [1 spotted  translate 7/0.6 scale 0.6]
      [0.03 spotted scale <0.01,0.05,0.05> rotate 47 warp { turbulence 0.2
octaves 2 } ]
     }
    }
   }
   smooth
   translate -0.5
   scale <2,0.8,2>
   translate -0.7*y
  }
  texture { sand }
 }

 //falling sand
 union {
  cylinder { <0,0,0>, <0,1,0>, .01 }
  hollow on
  texture {
   pigment_pattern {
    slope { -z }
    pigment_map {
     [0 rgb 0]
     [1
      average
      pigment_map {
       [0.2 gradient y poly_wave 5]
       [1 crackle solid scale 0.001]
      }
     ]
    }
   }
   texture_map {
    [0.4 pigment { rgbt 1 }]
    [0.4 sand]
   }
  }
  scale 0.721*y
  translate -0.7*y
 }

 //pile of sand
 cone { -0.7*y, 0.2, -0.5*y, 0 texture { sand } }


 //glass
#if (glassEnabled)
 difference {
  object { hourglassShapeOuter }// scale <1.03,.99,1.03> }
  object { hourglassShapeInnerShift } //avoid coincidence with sand.
  texture {
   pigment { rgbt 1 }
   finish { phong 2 phong_size 600 reflection { 0, 1 fresnel } conserve_energy }
  }
  interior_texture {
   pigment { rgbt 1 }
   finish { reflection { 0, 1 fresnel } conserve_energy } //no specular
  }
  interior { ior 1.5 }
 }
#end //glassEnabledg


#ifdef (radRender)
 //infinite desert
 plane { y, -1 texture { sand } }
#else
 //background
 plane { -z, -1000 pigment { rgb 0 } no_reflection no_shadow }
#end

 translate <-0.5,0.4,1.5>

 scale 1000 //fix some accuracy problems in the mesh. Looks like pov's got a
hard coded threshold...
}

#declare BC = <pow(4/7,1/2.2),pow(5.5/7,1/2.2),1>;
sky_sphere {pigment {planar colour_map {[0 rgb
0.3*<pow(BC.x,4),pow(BC.y,4),pow(BC.z,4)>*1.5][1 rgb 0.7*BC*1.5]}}}

fog {
 fog_type 2
 colour rgb BC*0.3
 distance 100*100
 fog_alt 6*100
 fog_offset -7*100
}

fog {
 fog_type 2
 colour rgb (1-BC)*0.5
 distance 500*100
 fog_alt 15*100
 fog_offset -7*100
}

//use a bit of 3 point lighting, but let saved rad be the fill light
light_source { <3,2,-1>*10000, rgb <1,0.9,0.7>*0.8  //key
 #if (areaLights) area_light z*2000,y*2000,4,4 adaptive 1 orient jitter #end
}
light_source { <0.2,1,3>*10000, rgb 1.2*<1,0.9,0.7>*0.8  //highlight
 #if (areaLights) area_light x*10000,y*10000,4,4 adaptive 1 orient jitter #end
}


camera {
 right  -x*image_width/image_height
 up  y
 direction z*1
 angle           100

 scale 1000
}

//   End of code



Have fun
Norbert


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.