/*
=================================================
Light propagation in a spherical droplet, forming
primary and secondary rainbows
-------------------------------------------------
Created by Søren Peo Pedersen - see my user page
at http://da.wikipedia.org/wiki/Bruger:Peo
=================================================
*/
#declare PrimaryRays=yes;
// Use "no" for light propagation in secondary rainbow,
// or "yes" for light propagation in primary rainbow.
#if (PrimaryRays)
// Rendition of light propagation for primary rainbow's light propagation:
#local pgmSpectrum1=pigment { // Pigment for first spectrum "fan-out"
radial
color_map {
[0.0000 color rgbt <.5,0,1,1>]
[0.1429 color rgbt <.5,0,1,.5>]
[0.2857 color rgbt < 0,0,1,.5>]
[0.4286 color rgbt < 0,1,1,.5>]
[0.5714 color rgbt < 0,1,0,.5>]
[0.7143 color rgbt < 1,1,0,.5>]
[0.8571 color rgbt < 1,0,0,.5>]
[1.0000 color rgbt < 1,0,0,1>]
}
frequency 200
rotate <90,0,-13.1>
translate <-3.806586,1.70909106,0>
scale 1/1.67
}
#local pgmSpectrum2=pigment { // Pigment for second spectrum "fan-out"
radial
color_map {
[0.0000 color rgbt <1,1,1,1>]
[0.5000 color rgbt <1,1,1,0>]
[1.0000 color rgbt <1,1,1,1>]
}
frequency 200
rotate <90,0,-13.1>
translate <-3.806586,1.70909106,0>
scale 1/1.67
}
union {
difference { // Incoming white light beam
box {<-100,.67,-.0001>,<0,.83,.0001>}
sphere {0,1}
pigment {
gradient y
color_map {
[0.0 color rgbt<1,1,1,1>]
[0.2 color rgbt<1,1,1,.9>]
[0.3 color rgbt<1,1,1,.5>]
[0.5 color rgbt<1,1,1,0>]
[0.7 color rgbt<1,1,1,.5>]
[0.8 color rgbt<1,1,1,1,.9>]
[1.0 color rgbt<1,1,1,1>]
}
scale .16
translate <0,.67,0>
}
finish {
ambient 1
diffuse 0
}
no_shadow
no_reflection
rotate <0,0,-20.825>
}
difference { // First "rainbow-colored" beam inside droplet
cylinder {<0,0,-.0001>,<0,0,.0001>,1} // Disc w. same diameter as droplet
plane {<0,1,0>,0 rotate <0,0,-14.9> translate <-0.7141428,.7,0>} // Cut-off
plane {<0,-1,0>,0 rotate <0,0,-13.1> translate <-0.6,.8,0>} // boundaries
pigment {
gradient x
pigment_map {
[0 pgmSpectrum2]
[1 pgmSpectrum1]
}
scale 1.67
translate <-.7,0,0>
}
finish {
ambient 1
diffuse 0
}
rotate <0,0,-20.825>
no_shadow
no_reflection
}
merge { // Second "rainbow-colord" beam inside droplet - "crossing over" itself
difference { // The portion to the left of the "cross-over" point
cylinder {<0,0,.0003>,<0,0,.0002>,1} // Droplet-sized disc
plane {<0,-1,0>,0 rotate <0,0,45> translate <1,.12,0>} // Cut-off
plane {<0,1,0>,0 rotate <0,0,25> translate <1,-.09,0>} // boundaries
}
difference { // The portion to the right of the "cross-over" point
cylinder {<0,0,.0003>,<0,0,.0002>,1} // Droplet-sized disc
plane {<0,1,0>,0 rotate <0,0,45> translate <1,.12,0>} // Cut-off
plane {<0,-1,0>,0 rotate <0,0,25> translate <1,-.09,0>} // boundaries
}
pigment {
radial
color_map {
[0.0000 color rgbt <.5,0,1,1>]
[0.1429 color rgbt <.5,0,1,.5>]
[0.2857 color rgbt < 0,0,1,.5>]
[0.4286 color rgbt < 0,1,1,.5>]
[0.5714 color rgbt < 0,1,0,.5>]
[0.7143 color rgbt < 1,1,0,.5>]
[0.8571 color rgbt < 1,0,0,.5>]
[1.0000 color rgbt < 1,0,0,1>]
}
frequency 18
rotate <90,0,-35>
translate <.606514871,-.273485129,0>
}
finish {
ambient 1
diffuse 0
}
no_shadow
no_reflection
}
difference { // The "rainbow-colored light" leaving the droplet at lower left corner:
box {<-100,0,-.0001>,<0,10,.0001> rotate <0,0,32.825> translate <-.113,-.994,0>}
plane {<0,-1,0>,0 rotate <0,0,8.825> translate <-.565,-.805,0>}
cylinder {<0,0,-1>,<0,0,1>,1} // Cut away part that would fall inside droplet
pigment {
radial
color_map {
[0.0000 color rgbt < 1,0,0,1>]
[0.1429 color rgbt < 1,0,0,0>]
[0.2857 color rgbt < 1,1,0,0>]
[0.4286 color rgbt < 0,1,0,0>]
[0.5714 color rgbt < 0,1,1,0>]
[0.7143 color rgbt < 0,0,1,0>]
[0.8571 color rgbt <.5,0,1,0>]
[1.0000 color rgbt <.5,0,1,1>]
}
frequency 15
rotate <-90,0,20.825>
translate <0.416125,-.65268,0>
}
finish {ambient 1 diffuse 0}
no_shadow
no_reflection
}
}
#else
// Rendition of light propagation for secondary rainbow's light propagation:
#local pgmSpectrum1=pigment { // Pigment for "rainbow-colored" part of first beam inside droplet
radial
color_map {
[0.0000 color rgbt < 1,0,0,1>]
[0.1429 color rgbt < 1,0,0,.5>]
[0.2857 color rgbt < 1,1,0,.5>]
[0.4286 color rgbt < 0,1,0,.5>]
[0.5714 color rgbt < 0,1,1,.5>]
[0.7143 color rgbt < 0,0,1,.5>]
[0.8571 color rgbt <.5,0,1,.5>]
[1.0000 color rgbt <.5,0,1,1>]
}
frequency 200
rotate <90,0,-.9>
translate <-3.7364,-0.69606,0>
scale 1/1.7
}
#local pgmSpectrum2=pigment { // Pigment for white part of first "rainbow-colored" beam inside droplet
radial
color_map {
[0.0000 color rgbt <1,1,1,1>]
[0.5000 color rgbt <1,1,1,0>]
[1.0000 color rgbt <1,1,1,1>]
}
frequency 200
rotate <90,0,-.9>
translate <-3.8364,-0.69606,0>
scale 1/1.7
}
union {
difference { // White-to "rainbow-colored" beam inside droplet
cylinder {<0,0,-.0001>,<0,0,.0001>,1}
plane {<0, 1,0>,0 rotate <0,0,-.9> translate <-.657,-.757,0>}
plane {<0,-1,0>,0 rotate <0,0, .9> translate <-.777,-.637,0>}
pigment {
gradient x
pigment_map {
[0 pgmSpectrum2]
[1 pgmSpectrum1]
}
scale 1.7
translate <-.8,0,0>
}
finish {ambient 1 diffuse 0}
no_shadow
no_reflection
}
merge {
difference { // Lower part of self-crossing beam at right-ahdn side inside droplet
cylinder {<0,0,.0002>,<0,0,.0003>,1}
plane {< 1,0,0>,0 rotate <0,0,-6 > translate <.622,-.692,0>}
plane {<-1,0,0>,0 rotate <0,0, 6 > translate <.787,-.727,0>}
}
difference { // Upper part of self-crossing beam at right-ahdn side inside droplet
cylinder {<0,0,.0002>,<0,0,.0003>,1}
plane {<-1,0,0>,0 rotate <0,0,-6 > translate <.622,-.692,0>}
plane {< 1,0,0>,0 rotate <0,0, 6 > translate <.787,-.727,0>}
}
pigment {
radial
color_map {
[0.0000 color rgbt < 1,0,0,1>]
[0.1429 color rgbt < 1,0,0,.5>]
[0.2857 color rgbt < 1,1,0,.5>]
[0.4286 color rgbt < 0,1,0,.5>]
[0.5714 color rgbt < 0,1,1,.5>]
[0.7143 color rgbt < 0,0,1,.5>]
[0.8571 color rgbt <.5,0,1,.5>]
[1.0000 color rgbt <.5,0,1,1>]
}
frequency 30
rotate <90,0,84>
translate <.702661,0.075435,0>
}
finish {ambient 1 diffuse 0}
no_shadow
no_reflection
}
merge { // Right-hand part of self-crossing beam at top of droplet
difference {
cylinder {<0,0,.0004>,<0,0,.0005>,1}
plane {<0,-1,0>,0 rotate <0,0, 6 > translate <.637,.777,0>}
plane {<0, 1,0>,0 rotate <0,0,-6 > translate <.772,.642,0>}
}
difference { // Left-hand part of self-crossing beam at top of droplet
cylinder {<0,0,.0004>,<0,0,.0005>,1}
plane {<0, 1,0>,0 rotate <0,0, 6 > translate <.637,.777,0>}
plane {<0,-1,0>,0 rotate <0,0,-6 > translate <.772,.642,0>}
}
pigment {
radial
color_map {
[0.0000 color rgbt < 1,0,0,1>]
[0.1429 color rgbt < 1,0,0,.5>]
[0.2857 color rgbt < 1,1,0,.5>]
[0.4286 color rgbt < 0,1,0,.5>]
[0.5714 color rgbt < 0,1,1,.5>]
[0.7143 color rgbt < 0,0,1,.5>]
[0.8571 color rgbt <.5,0,1,.5>]
[1.0000 color rgbt <.5,0,1,1>]
}
frequency 30
rotate <90,0,-6>
translate <.06228,0.716595,0>
}
finish {ambient 1 diffuse 0}
}
no_shadow
no_reflection
rotate <0,0,5>
}
difference { // "Rainbow-colored" beam leaving the droplet
box {<-10,0,.0002>,<.3,10,.0003> rotate <0,0,38.325> translate <-.827,.557,0>}
plane {<0,-1,0>,0 rotate <0,0,14.325> translate <-.697,.717,0>}
cylinder {<0,0,-1>,<0,0,1>,1}
pigment {
radial
color_map {
[0.0000 color rgbt < 1,0,0,1>]
[0.1429 color rgbt < 1,0,0,0>]
[0.2857 color rgbt < 1,1,0,0>]
[0.4286 color rgbt < 0,1,0,0>]
[0.5714 color rgbt < 0,1,1,0>]
[0.7143 color rgbt < 0,0,1,0>]
[0.8571 color rgbt <.5,0,1,0>]
[1.0000 color rgbt <.5,0,1,1>]
}
frequency 15
rotate <90,0,-21.3>
translate <-0.59003,0.744316,0>
}
finish {ambient 1 diffuse 0}
no_shadow
no_reflection
}
difference { // Incoming white light beam
box {<-100,-1,-.0001>,<0,-.87,.0001>}
sphere {0,1}
pigment {
gradient y
color_map {
[0.0 color rgbt<1,1,1,1>]
[0.2 color rgbt<1,1,1,.9>]
[0.3 color rgbt<1,1,1,.5>]
[0.5 color rgbt<1,1,1,0>]
[0.7 color rgbt<1,1,1,.5>]
[0.8 color rgbt<1,1,1,1,.9>]
[1.0 color rgbt<1,1,1,1>]
}
scale .13
translate <0,-1,0>
}
finish {
ambient 1
diffuse 0
}
no_shadow
no_reflection
rotate <0,0,-20.825>
}
#end
difference { // Droplet - actually a hemisphere for appearance reasons
sphere {0,1}
plane {<0,0,1>,.001}
pigment {color rgbt<.7,.8,1,.7>}
finish {
phong 1
phong_size 80
reflection .6
metallic
}
}
camera { // Viewpoint
up <0,1,0> right <1,0,0> // Assume square-shaped image format
location <-.2,0,-2.5>
look_at <-.2,0,0>
}
light_source { // Light
<-10,0,-10>
color rgb 1.5
rotate <0,0,-20.825>
}
----
POV-Ray "code" for the landscape with rainbows, observer and "droplet cloud":
/*
=================================================
"Landscape" showing the formation of two rainbows
-------------------------------------------------
Created by Søren Peo Pedersen - see my user page
at http://da.wikipedia.org/wiki/Bruger:Peo
=================================================
*/
plane { // Flat terrain in the foreground
<0,1,0>,0
pigment {color rgb <.65,.7,.6>}
finish {ambient .4}
}
plane {<0,0,-1>,0 // Invisible surface carrying the grey "cloud"
pigment {
cylindrical
color_map {
[0.0 color rgbt<1,1,1,1>]
[0.5 color rgbt<.7,.7,.7,0>]
[1.0 color rgbt<.5,.5,.5,0>]
}
rotate <90,0,0>
scale 7
translate <8,8,0>
turbulence .3
}
finish {ambient 1 diffuse 0}
}
sky_sphere { // Provides a sky with light blue color gradient
pigment {
gradient y
color_map {
[0 color rgb <.1,.3,.2>]
[.5 color rgb <.65,.7,.6>]
[.5 color rgb <.8,.9,1>]
[1 color rgb <.2,.5,1>]
}
translate -.5
scale 2
turbulence .1
}
}
union { // The observer in the lower, left-hand corner
sphere {0,1 scale <.2,.8,.2> pigment {color rgb <0,0,1>} finish {ambient .5}}
sphere {<0,1,0>,.2 pigment {color rgb <1,.7,.4>} finish {ambient .5}}
translate <-6.5,0,-4>
}
#macro ColorFunction(Plads) // Creates a color from the spectrum (from 0=red to 1=purple)
#local U=4.9999*(Plads-int(Plads*4.9999)/4.9999);
#switch (Plads)
#range (0.0,0.2) color rgb < 1 , U , 0 > #break
#range (0.2,0.4) color rgb <1-U, 1 , 0 > #break
#range (0.4,0.6) color rgb < 0 , 1 , U > #break
#range (0.6,0.8) color rgb < 0 ,1-U, 1 > #break
#range (0.8,1.0) color rgb < U , 0 , 1 > #break
#end
#end
#macro Beam(Num,Primay) // Renders a white incoming beam, and a colored "returned" beam
#local R=seed(145*Num);
#local Lgd=11+rand(R)*3;
#if (Primay)
#local Vinkel=42.3-20.825-1.7*Num;
#else
#local Vinkel=50.7-20.825+2.9*Num;
#end
merge {
cylinder {0,<Lgd,0,0>,.01
pigment {ColorFunction(Num)}
finish {ambient 1 diffuse 0}
rotate <0,0,Vinkel>
translate <-6.5,1,-4>
no_shadow
}
cylinder {
<-100,0,0>,0,.01
rotate <0,0,-20.825>
translate <-6.5+Lgd*cos(radians(Vinkel)),1+Lgd*sin(radians(Vinkel)),-4>}
pigment {color rgb 1}
finish {ambient 1 diffuse 0}
}
#end
// Light beams forming the primary rainbow:
#object {Beam(0.00,yes)}
#object {Beam(0.25,yes)}
#object {Beam(0.50,yes)}
#object {Beam(0.75,yes)}
#object {Beam(1.00,yes)}
// Light beams forming the secondary rainbow:
#object {Beam(0.00,no)}
#object {Beam(0.25,no)}
#object {Beam(0.50,no)}
#object {Beam(0.75,no)}
#object {Beam(1.00,no)}
// Totally transparent pigment set of primary and secondary arc
#local ArcPgmt0=pigment {
cylindrical
color_map {
[0.0 color rgbt<1,1,1,1>]
[0.00001 color rgbt<1,0,1,1>]
[0.022 color rgbt<0,0,1,1>]
[0.044 color rgbt<0,1,1,1>]
[0.066 color rgbt<0,1,0,1>]
[0.088 color rgbt<1,1,0,1>]
[0.11 color rgbt<1,0,0,1>]
[0.11 color rgbt<1,1,1,1>]
[0.39 color rgbt<1,1,1,1>]
[0.39 color rgbt<1,0,0,1>]
[0.40 color rgbt<1,1,0,1>]
[0.41 color rgbt<0,1,0,1>]
[0.42 color rgbt<0,1,1,1>]
[0.43 color rgbt<0,0,1,1>]
[0.44 color rgbt<1,0,1,1>]
[0.44 color rgbt<1,1,1,1>]
[1.0 color rgbt<1,1,1,1>]
}
}
// Slightly non-transparent pigment set of primary and secondary arc
#local ArcPgmt1=pigment {
cylindrical
color_map {
[0.0 color rgbt<1,1,1,1>]
[0.00001 color rgbt<1,0,1,.7>]
[0.022 color rgbt<0,0,1,.7>]
[0.044 color rgbt<0,1,1,.7>]
[0.066 color rgbt<0,1,0,.7>]
[0.088 color rgbt<1,1,0,.7>]
[0.11 color rgbt<1,0,0,0>]
[0.11 color rgbt<1,1,1,1>]
[0.39 color rgbt<1,1,1,1>]
[0.39 color rgbt<1,0,0,.2>]
[0.40 color rgbt<1,1,0,.2>]
[0.41 color rgbt<0,1,0,.2>]
[0.42 color rgbt<0,1,1,.2>]
[0.43 color rgbt<0,0,1,.2>]
[0.44 color rgbt<1,0,1,.2>]
[0.44 color rgbt<1,1,1,1>]
[1.0 color rgbt<1,1,1,1>]
}
}
// Surface carrying the two rainbows in front of the grey "cloud"
plane {<-1,0,0>,0
pigment {
radial
pigment_map {
[0.0 ArcPgmt1]
[0.2 ArcPgmt0]
[0.8 ArcPgmt0]
[1.0 ArcPgmt1]
}
rotate <0,0,90>
scale <4.18495,4.18495,7>
translate <0,1,-4>
}
finish {ambient 1 diffuse 0}
hollow
no_shadow
}
// Viewpoint
camera {
location <-5,5,-15>
look_at <1,4,0>
}
// "Infinitely" remote light source with parallel rays:
light_source {
<-1000,0,0>
color rgb 1.5
rotate <0,0,-20.825>
parallel
}