The ShadowVol and ShadowVol2 Demos

[Previous] [Next]

The ShadowVol sample on the companion CD in the \mssdk\Samples\Multimedia\D3dim\Src\ShadowVol directory contains a project that shows how to create and use stencil buffers to implement shadow volumes. The code illustrates how to use shadow volumes to cast the shadow of an arbitrarily shaped object onto another arbitrarily shaped object. The ShadowVol2 sample, which the Microsoft DirectX 7 SDK setup program on the companion CD installs in the \mssdk\Samples\Multimedia\D3dim\Src\ShadowVol2 directory on your hard disk, provides some additional capabilities for producing shadows with stencils.

The sample application provides these features in its Shadow Modes menu:

  • Draw Shadows Allows you to turn on and off shadow rendering.
  • Show Shadow Volumes Draws the shadow volumes used to compute the shadows rather than drawing the shadows themselves.
  • Draw Shadow Volume Caps When you turn this item off, some "extra" shadows might become visible where the far caps of the cylindrical shadow volumes happen to be visible.
  • 1-Bit Stencil Buffer Mode Tells the code to use a different algorithm that uses only 1 bit of stencil buffer, which won't allow overlapping shadows. If the device supports only 1-bit stencils, you'll be forced to use this mode.
  • Z-Order Shadow Vols in 1-Bit Stencil Buffer Mode The shadow volumes must be rendered front to back, which means that if you don't check this option, rendering might be incorrect.

Figure 12-1, Figure 12-2, and Figure 12-3 show three views of the scene generated by the ShadowVol2 sample application. You can see the shadows in Figures 12-1 and 12-3; Figure 12-2 illustrates the shadow volumes.

Figure 12-1 Shadow cast

Figure 12-2 Shadow volumes

Figure 12-3 Another view of the rendered shadows



Inside Direct3D
Inside Direct3D (Dv-Mps Inside)
ISBN: 0735606137
EAN: 2147483647
Year: 1999
Pages: 131

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net