POV-Ray : Newsgroups : povray.binaries.scene-files : Patina Macro Enhancement : Patina Macro Enhancement Server Time
1 Sep 2024 18:17:02 EDT (-0400)
  Patina Macro Enhancement  
From: James A Coons
Date: 29 Oct 2004 22:35:00
Message: <web.4182fccfd2ef10f0d3c06d7b0@news.povray.org>
Here is an updated Patina Function to use with Textures (Renamed to
Create_Patina(). Note that I removed the "no_shadow" from the Light Sources
to produce a more realistic result and used some realistic textures. I don't
have the entire rendered image (I'll have to do it again), but I did pull
partial renders to show the possible results (attached). I think it adds a
bit
to include turbulence (more on this later).

// Original Patina() Macro // by Rune S. Johansen 2003
//
// I don't know that much about how patina should look, but I've got the
// impression that it's not dependent on light source location, like
// subsurface scattering is? If it's more a matter of curvature of the
// surface and nearby surfaces, then this macro might be sufficient:
//
// Modified by JAC for different effects.
//   1. Renamed function to "Create_Patina" in case changes are made.
//   2. This version uses a Texture_Map instead of Color_Map.
//   3. Can use to create variable color, reflectivity, crand, etc.
//   4. Changed lights to spotlights to improve appearance.
//   5. Added turbulence for effect.
//   6. Amount of textures can be controlled in Texture_Map.
//   7. Notice that when the "Floor" plane is part of the Patina
//      Object, colors appear to "bleed" onto it.
//   8. Surfaces perpendicular to an axis are not affected as much
//      as non-perpendicular surfaces.

#include "colors.inc"
#include "metals.inc"
global_settings {max_trace_level 25}

#macro Create_Patina (Obj,Blur,Samples,Stream)
   // By Rune S. Johansen 2003
   #local FN =
      function {
         pigment {
            average
            pigment_map {
               #local C = 0;
               #while (C<Samples)
                  [1 object{Obj rgb 0, rgb 1}
                     translate <
                        rand(Stream)-rand(Stream),
                        rand(Stream)-rand(Stream),
                        rand(Stream)-rand(Stream)
                     >*Blur
                  ]
                  #local C = C+1;
               #end
            }
         }
      }
   function {FN(x,y,z).red}
#end

// Create Source Object for "Create_Patina"
#declare Object =
   union {
      plane {y,0}
      box {-1,1 scale <3.2,1.0,0.7> translate y}
      box {-1,1 scale <1.0,1.0,3.0> translate y}
      box {-1,1 scale <0.5,0.7,3.5> translate 0.7*y}
      sphere {4*y, 0.85}
      torus {2.4, 0.5 translate y}
      box {-1,1 scale <1.1, 2.0, 1.1> translate 2*y}
      // need to add rotate cube to show how "flat"
      // surfaces differ from "non-flat" surfaces.
      scale 2
   }
object {
   Object
   texture {
      Create_Patina(Object, 2.0, 256, seed(0) )
      // turbulence 0.5
      // NOTE: This uses a texture_map instead of a color_map
      texture_map {
         [0/4 pigment {P_Silver1} finish {ambient 0 diffuse 0.6} ]
         [1/4 pigment {P_Brass1}  finish {ambient 0 diffuse 0.6} ]
         [2/4 pigment {P_Chrome1} finish {ambient 0 diffuse 0.6 reflection
0.5 specular 0.5} ]
         [4/4 pigment {P_Copper1} finish {ambient 0 diffuse 0.6 reflection
1.0 specular 1.0} ]

/*
         [0.10 pigment {color (Blue+Green+White)/5}
            finish {reflection 0.4}
            // normal {agate 0.01 bump_size 0.01}
            ]
         [0.30 pigment {color (Blue+Green+White)/5}
            // normal {agate 2.0 bump_size 1.0 scale 0.75 accuracy 1e-9}
            ]
         [0.90 pigment {color (Blue+Green+White)/5}
            // normal {agate 4.0 bump_size 2.0 scale 0.75 accuracy 1e-9}
            finish {crand 0.5}
            ]
*/
      }
   }
   // finish {ambient 0.6 reflection 0 diffuse 0.3}
}

// Set Up Environment

camera {location <9,12,-13> look_at 3*y}

//
***********************************************************************************************************************
*
// Sky Sphere (pigmented or plain) /Sky
//
***********************************************************************************************************************
*
#declare Sky_Radius = 500000;          // Radius of Sky Sphere
sphere { <0.0, 0.0, 0.0>, Sky_Radius*5 translate <0,-Sky_Radius,0>
   texture {
      pigment {granite // omega -0.5 // octaves 8 // lambda 2.0 // omega 0.5
         scale 1250000*2 scale <1,0.50,1>*2 turbulence x*0.25
         pigment_map {
            [0.00 rgb <060,102,175>/255] // Dark Blue
            [0.30 rgb <060,102,175>/255] // Dark Blue
            [0.80 rgb <199,198,205>/255] // White
            [1.00 rgb <199,198,205>/255] // White
            }
      }
      finish {ambient 1.0}
      }
   finish {ambient 0.3 diffuse 0.0 reflection 0.1}
   inverse
   no_shadow
   scale <100,20,100>
}

//light_source {< 2, 3,-1>*100, color rgb <1.2,1.2,0.9>*3}
//light_source {<-2, 3,-2>*100, color rgb <0.5,0.5,0.8>*2}
light_source {< 2, 3,-1>*100
   color rgb <1.2,1.2,0.9>*3
   spotlight
   point_at <0, 0, 0>
   radius 5*10
   tightness 50
   falloff 8/0.7
}
light_source {<-2, 3,-2>*100
   color rgb <0.5,0.5,0.8>*2
   spotlight
   point_at <0, 0, 0>
   radius 5*10
   tightness 50
   falloff 8*0.7
}


Post a reply to this message


Attachments:
Download 'patina_00_demo_01.jpg' (98 KB)

Preview of image 'patina_00_demo_01.jpg'
patina_00_demo_01.jpg


 

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