home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 1995 January / pcw-0195.iso / polyray / dat / texture / extlight.pi < prev    next >
Text File  |  1994-12-31  |  3KB  |  120 lines

  1. //
  2. // Implementing extended lights via special surfaces
  3. //
  4. // Polyray input file: Alexander Enzmann
  5.  
  6. //
  7. // Define the location and size of the extended light source
  8. //
  9. define light_position <-20, 12, 20>
  10. define light_color <1, 1, 1>
  11. define light_radius 3
  12.  
  13. // Put the light source in place
  14. light light_color, light_position
  15.  
  16. // Set up the camera
  17. viewpoint {
  18.    from <0, 5,-7>
  19.    at   <0, 0, 0>
  20.    up   <0, 1, 0>
  21.    angle 35
  22.    resolution 1024, 512
  23.    aspect 2
  24.    }
  25.  
  26. include "..\colors.inc"
  27. //
  28. // Here is where we build the jitter rays that are fired from a point
  29. // on a surface towards the extended light source.  The rays are built
  30. // from two vectors that are perpendicular to the direction of the ray
  31. // that extends from the point on the surface to the center of the
  32. // extended light source.  A random deflection of each ray is made that
  33. // has a magnitude equal to the radius of the light source.  The sum
  34. // of the visibilities is averaged to get the intensity within the shadow.
  35. //
  36. define light_vector (light_position - W)
  37. define light_distance |light_vector|
  38. define light_norm_vector light_vector / light_distance
  39. define light_vec1 light_vector * <0, 0, 1>
  40. define light_t (light_vec1 / |light_vec1|)
  41. define light_v light_t * light_norm_vector
  42. define light_u light_v * light_norm_vector
  43.  
  44. //
  45. // The scale of the jitter is based on the size of the light
  46. define jitter_scale1 light_radius * <0.7, 0.7, 0.7>
  47.  
  48. //
  49. // Each sample ray is directed towards the center of the light, and is
  50. // deflected by a random displacement.
  51. //
  52. define sampled_light_point
  53.    (light_position + brownian(light_u, jitter_scale1)
  54.            + brownian(light_v, jitter_scale1))
  55.  
  56. //
  57. // Different resolutions of shading are achieved by performing more
  58. // and more samples.
  59. //
  60. define sampled_shade4
  61.    (visible(W, sampled_light_point) +
  62.     visible(W, sampled_light_point) +
  63.     visible(W, sampled_light_point) +
  64.     visible(W, sampled_light_point)) / 4
  65.  
  66. define sampled_shade8
  67.    (sampled_shade4 + sampled_shade4) / 2
  68.                   
  69. define sampled_shade16
  70.    (sampled_shade8 + sampled_shade8) / 2
  71.  
  72. define sampled_shade32
  73.    (sampled_shade16 + sampled_shade16) / 2
  74.  
  75. define sampled_shade64
  76.    (sampled_shade32 + sampled_shade32) / 2
  77.  
  78. //
  79. // Define the sampled coloring for the floor
  80. //
  81. define soft_shadowed
  82. texture {
  83.    special surface {
  84.       color black
  85.       transmission white, sampled_shade64, 1
  86.       ambient  0
  87.       diffuse  0
  88.       specular 0
  89.       }
  90.    }
  91.  
  92. define floor_color
  93. texture {
  94.    layered
  95.       soft_shadowed,
  96.       texture { hexagon matte_red, matte_white, matte_blue scale <2, 2, 2> }
  97.    }
  98.  
  99. define diffuse_white
  100. texture {
  101.    special surface {
  102.       color white
  103.       ambient  0.2
  104.       diffuse  0.8
  105.       specular 0
  106.       }
  107.    }
  108.  
  109. object {
  110.    sphere <-2, 0, 3>, 1
  111.    mirror
  112.    // cone <-2, -1, 3>, 2, <-2, 1, 3>, 0
  113.    }
  114.  
  115. object {
  116.    disc <0, -1, 0>, <0, 1, 0>, 30
  117.    floor_color
  118.    shading_flags 62
  119.    }
  120.