POV-Ray : Newsgroups : povray.binaries.scene-files : "Crown of diamond" source code Server Time
2 Sep 2024 16:21:59 EDT (-0400)
  "Crown of diamond" source code (Message 1 to 2 of 2)  
From: Tor Olav Kristensen
Subject: "Crown of diamond" source code
Date: 27 May 2000 23:02:17
Message: <3930897A.1324FEC8@hotmail.com>
Below is the source code for an image I posted 27. May to the
povray.binaries.images news group.

Tor Olav

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Copyright 2000 by Tor Olav Kristensen
//
// Except for the code for the DiamondTexture and the DiamondInterior 
// which I borrowed (and modified) from the posting Sigmund Kyrre Aas 
// made to this news group; povray.binaries.scene-files, 26. May 2000:
// "Brilliant diamond".
//
// mailto:tor### [at] hotmailcom
// http://www.crosswinds.net/~tok/tokrays.html
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.1;

#include "colors.inc"

global_settings { 
  ambient_light 0.5
  max_trace_level 30
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#macro Tilt(Thing, Vector)

  #local xAngle = degrees((Vector.z < 0 ? -1 : 1)*
                  acos(vnormalize((x + z)*Vector).x));
  #local yAngle = degrees(acos(vnormalize(Vector).y));

  object {
    Thing
    rotate  xAngle*y
    rotate -yAngle*z
    rotate -xAngle*y
  }

#end // macro Tilt


#macro MCircleSpread(Thing, Radius, NrOfThings, Start)

  #local dAngle = 360/NrOfThings;

  #local Angle = Start*dAngle;
  #local Cnt = 0;
  #while (Cnt < NrOfThings)
    object { 
      Thing 
      translate Radius*x 
      rotate Angle*y
    }
    #local Angle = Angle + dAngle;
    #local Cnt = Cnt + 1;
  #end // while

#end // macro MCircleSpread

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare cR = 1.4; // To adjust the brightness of pigment

#declare RedPigment =
pigment {
  granite 
  turbulence 0.4
  color_map {
    [ 0.0 rgb <0.6, 0.1, 0.1>*cR ]
    [ 0.8 rgb <0.3, 0.0, 0.0>*cR ]
    [ 0.8 rgb <0.6, 0.1, 0.1>*cR ]
    [ 1.0 rgb <0.2, 0.0, 0.0>*cR ]
  }
}

#declare DiamondTexture =
texture { 
  pigment {
    color rgbf <0.81, 0.81, 0.8, 0.8>
  }
  finish {
    ambient 0.01
    diffuse 0.4 
  }
}

#declare DiamondInterior =
interior { 
  caustics 1
  ior 2.417 
  fade_power 1000   // Experiment with
  fade_distance 80  // these values
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

// Also try other numbers here
#declare FacetSides = 8; // This will make 8*9 + 2 = 74 facets 

#declare Brilliant =
intersection {
  plane { y, 0 }
  MCircleSpread(plane { y, 0 rotate  -27*z }, 3.00, FacetSides, 1/2) 
  MCircleSpread(plane { y, 0 rotate  -42*z }, 3.25, FacetSides,  0 )
  MCircleSpread(plane { y, 0 rotate  -47*z }, 3.62, FacetSides, 1/4)
  MCircleSpread(plane { y, 0 rotate  -47*z }, 3.62, FacetSides, 3/4)
  MCircleSpread(plane { y, 0 rotate  -90*z }, 6.20, FacetSides, 1/4)
  MCircleSpread(plane { y, 0 rotate  -90*z }, 6.20, FacetSides, 3/4)
  MCircleSpread(plane { y, 0 rotate -135*z }, 9.10, FacetSides, 1/4)
  MCircleSpread(plane { y, 0 rotate -135*z }, 9.10, FacetSides, 3/4)
  MCircleSpread(plane { y, 0 rotate -137*z }, 9.43, FacetSides,  0 )
  plane { -y, 8.2 }

  bounded_by { cylinder { 0.1*y, -8.3*y, 6.20/cos(pi/FacetSides) } }
}

#declare Diamond = 
object {
  Brilliant
  interior { DiamondInterior }
  texture { DiamondTexture }
}


#declare DimLight = light_source { -3*y, color White*0.15 }

#declare NrOfStringLights = 9;

#declare LightString = // Lights to be put inside diamond
union {
  #declare Cnt = 0;
  #while (Cnt < NrOfStringLights) 
    object { DimLight translate -(Cnt + 0.1)*y }  
    #declare Cnt = Cnt + 1;
  #end // while
}

#declare NrOfRingLights = 8;

#declare LightRing = // Can be used instead of LightString
union {
  MCircleSpread(DimLight, 1, NrOfRingLights, 0.0)
  translate -y
}


#declare LitDiamond =
union {
  object { Diamond }
  object { LightString }
//  object { LightRing }
  translate 4*y
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare vCamera = <5, 2, 0>;

// Make the diamond's crown face the camera
object {
  Tilt(LitDiamond, vCamera) 
//  translate 6*z // To make place for the second copy below
} 

/*
// Second copy of diamond viewed from another angle
object {
  Tilt(LitDiamond, <-1, 2, 0>)
  translate -16*z
}
*/

plane { 
  y, -8
  pigment { color Blue/2 }
  finish {
    ambient 0.2
    specular 0.3
    reflection 0.3
  }
}

sky_sphere {
  pigment { 
    RedPigment 
    scale 4
    rotate -20*y
  }
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare AreaLight =
light_source { 
  50*y, 
  color White*0.6
  area_light 3*x, 3*z, 3, 3
  adaptive 1 
  jitter 
}

Tilt(AreaLight, <-1, 2, 0>)

camera {
  location vCamera*4
  look_at -4*z 
  angle 100
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

From: Børge Berg-Olsen
Subject: Re: "Crown of diamond" source code
Date: 30 May 2000 16:14:10
Message: <3934201C.2F34FA31@dod.no>
Updated file with photons and radiosity, I am not sure if the settings
are sane or not... :-)

Look in binaries.images for a traced version of the source, however that
image is not traced with the new settings for the diamond texture. I
added some parameters after I've traced the image in order to see if I
could get rid of the "dirty" look.


// =====1=======2======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Copyright 2000 by Tor Olav Kristensen
//
// Except for the code for the DiamondTexture and the DiamondInterior 
// which I borrowed (and modified) from the posting Sigmund Kyrre Aas 
// made to this news group; povray.binaries.scene-files, 26. May 2000:
// "Brilliant diamond".
//
// mailto:tor### [at] hotmailcom
// http://www.crosswinds.net/~tok/tokrays.html
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version unofficial MegaPov 0.5;

#include "colors.inc"

global_settings { 
  ambient_light 0.5
  max_trace_level 10
  photons{
    count 20000
 	 spacing .01
    gather 60, 100
    autostop 0
    jitter .4
    max_trace_level 4
    //load_file "brilliant.ph"
  }
  ini_option  "+QR"
  ini_option "Preview_Start_Size=16"
  ini_option "Preview_End_Size=8"

  radiosity{
     count 25
     nearest_count 4
     error_bound 2.5
     recursion_limit 2
     low_error_factor .5
     gray_threshold 0.0
     minimum_reuse 0.015
     brightness 1
     adc_bailout 0.01/(18*2)
  }  
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#macro create_spectrum(nelems,bright)

#local elem=1;

color_map{
#while(elem<=nelems)

  /* h goes from 0 at red end to 1.0 at blue end */
  #local h = (elem-1)/(nelems-1);

  /* co-h goes from 1.0 at red end to 0.0 at blue end */
  #local coh = 1.0 - h; 
  
  #local Huered = 0.9 - (h/0.5);
  #local Hueblue = 1.0 - (coh/0.6);
  
  #if (Huered < 0.0) #local Huered = 0.0; #end
  #if (Hueblue < 0.0)  #local Hueblue = 0.0; #end

  #local Huered=1.0 - (1.0-Huered)*(1.0-Huered);  
  #local Hueblue=1.0 - (1.0-Hueblue)*(1.0-Hueblue);

  #local Huegreen = 1.0 - Huered - Hueblue;

  #if (h>0.85)
    #local Huered = 4*(h-0.85);  // was 4 - changed to 8
  #end
  
  #local ybulge =  -4.0*(h-0.1)*(h-0.6);
  #if (ybulge<0) #local ybulge=0; #end
  
  #local Huered = Huered+ybulge;// * 0.5; // added * 0.5
  #local Huegreen = Huegreen+ybulge;
  
  [bright, color rgb <Huered,Huegreen,Hueblue>]
  #debug
concat("<",str(Huered,0,3),",",str(Huegreen,0,3),",",str(Hueblue,0,3),">\n")
  
  
  #local elem=elem+1;
#end // while
}
#end // macro

#macro Tilt(Thing, Vector)

  #local xAngle = degrees((Vector.z < 0 ? -1 : 1)*
                  acos(vnormalize((x + z)*Vector).x));
  #local yAngle = degrees(acos(vnormalize(Vector).y));

  object {
    Thing
    rotate  xAngle*y
    rotate -yAngle*z
    rotate -xAngle*y
  }

#end // macro Tilt


#macro MCircleSpread(Thing, Radius, NrOfThings, Start)

  #local dAngle = 360/NrOfThings;

  #local Angle = Start*dAngle;
  #local Cnt = 0;
  #while (Cnt < NrOfThings)
    object { 
      Thing 
      translate Radius*x 
      rotate Angle*y
    }
    #local Angle = Angle + dAngle;
    #local Cnt = Cnt + 1;
  #end // while

#end // macro MCircleSpread

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare cR = 1.4; // To adjust the brightness of pigment

#declare RedPigment =
pigment {
  granite 
  turbulence 0.4
  color_map {
    [ 0.0 rgb <0.6, 0.1, 0.1>*cR ]
    [ 0.8 rgb <0.3, 0.0, 0.0>*cR ]
    [ 0.8 rgb <0.6, 0.1, 0.1>*cR ]
    [ 1.0 rgb <0.2, 0.0, 0.0>*cR ]
  }
}

#declare DiamondTexture =
texture { 
  pigment {
    color rgbf <1.0, 1.0, 1.0, 0.95>
  }
  finish {
    // ambient 0.01
    // diffuse 0.4
    ambient 0.1
    diffuse 0.1
    reflection .25
    specular 1
    roughness 0.001
  }
}

#declare DiamondInterior =
interior { 
  caustics 1
  ior 2.417
  dispersion 0.75 
  fade_power 1000   // Experiment with
  fade_distance 80  // these values
  disp_nelems 10 // 10
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

// Also try other numbers here
#declare FacetSides = 8; // This will make 8*9 + 2 = 74 facets 

#declare Brilliant =
intersection {
  plane { y, 0 }
  MCircleSpread(plane { y, 0 rotate  -27*z }, 3.00, FacetSides, 1/2) 
  MCircleSpread(plane { y, 0 rotate  -42*z }, 3.25, FacetSides,  0 )
  MCircleSpread(plane { y, 0 rotate  -47*z }, 3.62, FacetSides, 1/4)
  MCircleSpread(plane { y, 0 rotate  -47*z }, 3.62, FacetSides, 3/4)
  MCircleSpread(plane { y, 0 rotate  -90*z }, 6.20, FacetSides, 1/4)
  MCircleSpread(plane { y, 0 rotate  -90*z }, 6.20, FacetSides, 3/4)
  MCircleSpread(plane { y, 0 rotate -135*z }, 9.10, FacetSides, 1/4)
  MCircleSpread(plane { y, 0 rotate -135*z }, 9.10, FacetSides, 3/4)
  MCircleSpread(plane { y, 0 rotate -137*z }, 9.43, FacetSides,  0 )
  plane { -y, 8.2 } // 8.2 

  bounded_by { cylinder { 0.1*y, -8.3*y, 6.20/cos(pi/FacetSides) } }
}

#declare Diamond = 
object {
  Brilliant
  interior { DiamondInterior }
  texture { DiamondTexture }
}


#declare DimLight = light_source { -3*y, color White*0.15 /* photons {
global refraction on reflection on } */ }

#declare NrOfStringLights = 9;

#declare LightString = // Lights to be put inside diamond
union {
  #declare Cnt = 0;
  #while (Cnt < NrOfStringLights) 
    object { DimLight translate -(Cnt + 0.1)*y }  
    #declare Cnt = Cnt + 1;
  #end // while
}

#declare NrOfRingLights = 8;

#declare LightRing = // Can be used instead of LightString
union {
  MCircleSpread(DimLight, 1, NrOfRingLights, 0.0)
  translate -y
}


#declare LitDiamond =
union {
  object { Diamond }
  object { LightString }
//  object { LightRing }
  translate 4*y
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare vCamera = <5, 2, 0>;

// Make the diamond's crown face the camera
object {
  Tilt(LitDiamond, vCamera)
  photons {
    target
    refraction on
    reflection on
    ignore_photons
  } 
  translate 6*z // To make place for the second copy below
} 


// Second copy of diamond viewed from another angle
object {
  Tilt(LitDiamond, <-1, 2, 0>)
  photons {
    target
    ignore_photons
    refraction on
    reflection on
  } 
  translate -16*z
}

plane { 
  y, -8
  pigment { color Blue/2 }
  finish {
    ambient 0.2
    specular 0.3
    reflection 0.3
  }
  photons { ignore_photons }
}

/*
sky_sphere {
  pigment { 
    color rgb <1, 1, 1> 
    scale 4
    rotate -20*y
  }
}
*/

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare AreaLight =
light_source { 
  50*y, 
  color White*0.6
  area_light 3*x, 3*z, 3, 3
  adaptive 1 
  jitter
  photons {
    global
    area_light
    refraction on
    reflection on
  }
  //create_spectrum(16,0.1) 
}

Tilt(AreaLight, <-1, 2, 0>)

camera {
  location vCamera*4
  look_at -4*z 
  angle 100
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

-- 

------------------------------------------------------------------------
  +47 90 62 71 78          DoD#2101, DoDRT#017, NIC#015, PJ#006, OGM#007
  azo### [at] dodno, Ducati M600              Ubesudlet: Aldri eid en J&%#PS.


Post a reply to this message

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