1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"[]>
2<html xml:lang="en-US" lang="en-US">
3  <head>
4    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5    <meta http-equiv="Content-Style-Type" content="text/css" />
6    <link rel="stylesheet" href="../../../css/document.css" type="text/css" />
7    <title>Graphix Library (gfx) Sample Demos</title>
8  </head>
9  <body>
10    <h1>ShadowMapDemo</h1>
11      <div class="section"><img src="images/ShadowMapDemo.png" border="0" width="400" height="240" /></div>
12      <h2>Overview</h2>
13      <p>
14        Demo for creating a depth map that saves distances from lights and then applying shadows using this information.
15      </p>
16      <h2>How to Use</h2>
17      <p>
18        <ul>
19          <li>Demo-specific operations</li>
20          <ul>
21            <li>None.</li>
22          </ul>
23          <li>Common Operations</li>
24          <ul>
25            <li>Slide pad: Rotate the camera</li>
26            <li>Slide pad + A Button: Move the camera back and forth</li>
27            <li>Slide pad + B Button: Move the camera in parallel</li>
28            <li>Slide pad + Y Button: Move the camera up and down</li>
29            <li>X Button: Reset the camera position</li>
30            <li>START Button: Restart the demo.</li>
31          </ul>
32        </ul>
33      </p>
34      <h2>Description</h2>
35      <p>
36        Demo for creating a depth map that saves distances from lights and then applying shadows using this information.<BR> Unlike <a href="ProjectionShadowDemo.html">ProjectionShadowDemo<a href="ProjectionShadowDemo.html">, shadows can be cast on oneself. <BR>This section describes points that differ from ProjectionShadowDemo.
37      </p>
38      <h3>Using shadow map textures</h3>
39      <p>
40      	With ProjectionShadow, <span>nw::gfx::ResImageTexture</span> is used as the offscreen buffer, whereas <span>nw::gfx::res::ResShadowtexture</span> is used with ShadowMap. This shadow map texture can set PerspectiveShadow and ShadowZBias at time of creation.<BR> Set these values according to the DMPGL specification manual.<BR> In the case of an ortho camera, PerspectiveShadow is usually false, because r value division is not performed.
41	  </p>
42      <h3 class="separator">Setting wScale for the shadow camera</h3>
43      <p>
44      	When using a perspective or frustum camera for drawing shadows, set wScale to 1.0/Far.<BR> This is due to the fact that the depth buffer range written into the shadow buffer is between 0 and 1.
45      </p>
46      <h3 class="separator">Setting the shadow mode of a shadow material</h3>
47      <p>
48      	Set FRAGMENT_OPERATION_MODE_SHADOW for shadow materials using <a href="../../../nw/gfx/res/ResFragmentOperation/SetFragmentOperationMode.html">SetFragmentOperationMode</a> to enable writing to the shadow texture.
49      </p>
50      <h3 class="separator">Always set the diffuse color of a shadow material to black</h3>
51      <p>
52      	Always set the diffuse color of a shadow material to black (0.0f, 0.0f, 0.0f, 0.0f).<BR> Set the shadow color using combiner settings. Examples are given below.<BR> Combiner 0 output = (inverse of the shadow texture color * constant color)<BR>Combiner 1 output = (Combiner 0 output * texture 1 or other texture)
53	  </p>
54	  <h3 class="separator">Set the shadow texture for materials that cast shadows</h3>
55	  <p>
56      	Although essentially the same as ProjectionShadow, you must switch the MappingMethod of the TextureCoordinator when using ShadowMap. Set <a href="../../../nw/gfx/res/ResTextureCoordinator/SetMappingMethod.html">SetMappingMethod</a> to nw::gfx::ResTextureCoordinator::MAPPINGMETHOD_SHADOW to change the texture matrix calculation method.
57      </p>
58  <hr><p>CONFIDENTIAL</p></body>
59</html>
60