home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Raytrace & Morphing / SOS-RAYTRACE.ISO / programm / scripts / polyray / pots / porcupot.pi < prev   
Encoding:
Text File  |  1993-06-24  |  3.6 KB  |  115 lines

  1. // "Porcupot" a Polyray 1.6 scene file based on the "Utah Teapot"
  2. // By Douglas Otwell
  3. //----------------------------------------------------------------------------
  4. // In Porcupot, I use a displacement function that looks like spikes to  
  5. // give the teapot a porcupine or blowfish surface.  Like Crocpot,
  6. // the displacement follows the surface using the local coordinate (u - v) 
  7. // ability of the bezier patches.
  8. //----------------------------------------------------------------------------
  9.  
  10. // point these to the standard Polyray include files
  11. include "../colors.inc"
  12. include "../texture.inc"
  13.  
  14. viewpoint {
  15.    from <0, 4, -5.5>
  16.    at <0.25, 1, 0>
  17.    up <0,  1, 0>
  18.    angle 53
  19.    resolution 640, 480
  20.    aspect 1.33333 
  21. }
  22.  
  23. background SkyBlue
  24. light <-10, 10, -5>
  25. light <10, 10, -10>
  26.  
  27. //----------------------------------------------------------------------------
  28. // Spine_texture maps the color map to distance from the origin,
  29. // creating layers of color like an onion.
  30. // These colors and the color map below were designed with Lutz Kretzschmar's
  31. // program CMAPPER.
  32. //----------------------------------------------------------------------------
  33. define cream <0.925, 0.871, 0.776>
  34. define brown <0.341, 0.216, 0.000>
  35.  
  36. define spine_texture texture {
  37.    noise surface {
  38.       color white
  39.       position_fn position_spherical
  40.       lookup_fn lookup_sawtooth
  41.       octaves 3
  42.       turbulence 1.5
  43.       ambient 0.3
  44.       diffuse 0.6
  45.       specular 0.8
  46.       microfacet Reitz 10
  47.       color_map(
  48.          [0.000, 0.150, cream, brown]
  49.          [0.150, 0.248, brown, black]
  50.          [0.248, 0.301, black, brown]
  51.          [0.301, 0.407, brown, cream]
  52.          [0.407, 0.549, cream, cream]
  53.          [0.549, 0.646, cream, brown]
  54.          [0.646, 0.664, brown, black]
  55.          [0.664, 0.717, black, brown]
  56.          [0.717, 0.876, brown, cream]
  57.          [0.876, 1.001, cream, cream])
  58.    }
  59. }
  60. define cream_texture texture {
  61.    surface {
  62.       color cream
  63.       specular 0.8
  64.       ambient 0.3
  65.       diffuse 0.6
  66.       microfacet Reitz 10
  67.    }
  68. }
  69.  
  70. define rim_texture    spine_texture
  71. define body1_texture  spine_texture
  72. define body2_texture  spine_texture
  73. define spout_texture  cream_texture
  74. define handle_texture cream_texture
  75. define lid1_texture   cream_texture 
  76. define lid2_texture   spine_texture
  77. define bottom_texture spine_texture
  78.  
  79. //----------------------------------------------------------------------------
  80. // This function is probably overkill.  Basically it's a parabola (x^2),
  81. // shifted to the right a bit, and then rotated around the y axis (by
  82. // replacing x with sqrt(x^2 +z^2).)  The conditional expression is used
  83. // to clip off the outside.  (A simple cone function would have been easier,
  84. // faster, and probably indistinguishable.)
  85. // To follow the surface, I used the u and v coordinates of the bezier, 
  86. // using sawtooths to get the frequency of spikes I wanted across the bezier 
  87. // (The "2*new_v-1" business remaps the domain of my function, from -1 to 1, 
  88. // to the values of u and v, which range from 0 to 1.)
  89. //----------------------------------------------------------------------------
  90.  
  91. define new_u sawtooth(4*u)
  92. define new_v sawtooth(8*v)
  93.  
  94. define spine_fn ((2*new_v-1)^2 + (2*new_u-1)^2 < 0.25         
  95.    ? 4 * N * (sqrt((2*new_v-1)^2 + (2*new_u-1)^2) - 0.5)^2  
  96.    : 0)                                            
  97.  
  98. define rim_fn    0
  99. define body1_fn  spine_fn
  100. define body2_fn  spine_fn
  101. define lid1_fn   0
  102. define lid2_fn   spine_fn * 0.5
  103. define spout_fn  0
  104. define handle_fn 0
  105. define bottom_fn spine_fn
  106.  
  107. define u_res 8
  108. define v_res 8
  109.  
  110. include "mypot.inc"
  111.  
  112. teapot
  113.  
  114.  
  115.