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>Graphics Library (gfx) Sample Demos</title>
8  </head>
9  <body>
10    <h1><CODE>ProjectionShadowDemo</CODE></h1>
11      <div class="section"><img src="images/ProjectionShadowDemo.png" border="0" width="400" height="240" /></div>
12      <h2>Overview</h2>
13      <p>
14        Demo for applying shadows by projecting rendered results as a texture from the direction of the light.
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>Circle Pad: Rotate the camera</li>
26            <li>Circle Pad + A Button: Move the camera back and forth</li>
27            <li>Circle Pad + B Button: Translate the camera</li>
28            <li>Circle 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        Rendering is performed in two passes to achieve projected texture shadows.<BR> In this demo, shadow settings are inserted by a callback using <a href="../../../nw/gfx/RenderCommand/Overview.html">RenderCommand</a>. This is set using the layer ID so that rendering is performed in the following order.<BR> StartShadowRenderCommand → Render first pass → EndShadowRenderCommand → StartRenderCommand → Render second pass → EndRenderCommand
37      </p>
38      <p>
39        On the first pass, rendering is performed from the light direction toward the texture.<BR> Beforehand, SHADOW_CASTER defined in the demo is set for objects that cast shadows in UserParameter.<BR> On the first pass, a function object is set for SubmitView and only SHADOW_CASTER is added to the RenderQueue. Before rendering in the first pass, material settings for shadows are made using StartShadoRenderCommand.
40      </p>
41      <p class="info">
42        StartShadowRenderCommand makes the following settings.
43      </p>
44      <h3>Switching to the offscreen buffer</h3>
45      <p>Switches to an offscreen buffer already created for rendering to textures.</p>
46      <h3>Switching to materials for shadows</h3>
47      <p>
48      	Materials for shadows include the following settings.<BR> - A shader that outputs vertex and color only<br />- A combiner that uses vertex shader output<br />- Invalidates the depth text<br />- Sets the shadow color (the diffuse color)
49      </p>
50      <h3>Setting the shadow camera as the rendering camera</h3>
51      <p>First, create a shadow camera pointed in the light direction.</p>
52      <h3>Switching to a rendering mode that does not use material settings</h3>
53      <p>
54      	Set using <a href="../../../nw/gfx/RenderContext/SetRenderMode.html">SetRenderMode</a> so that material settings by the model are ignored.<br /> This carries out rendering using the shadow settings set initially.
55      </p>
56      <p class="info">After models for which SHADOW_CASTER has been set, cancel shadow settings by calling EndShadowRenderCommand.</p>
57      <p>
58      	・Restore the regular render mode using <a href="../../../nw/gfx/RenderContext/SetRenderMode.html">SetRenderMode</a>.<br /> ・Reset the state of RenderContext using <a href="../../../nw/gfx/RenderContext/ResetState.html">ResetState</a>.<BR>Re-configure the active camera for SceneEnvironment because once the state is reset, active camera settings become invalid.
59      </p>
60      <p>
61      	On the second pass, textures created in the first pass are applied to models that cast shadows and then rendered.<BR> Shadow textures are set for models that cast shadows in the order given below.
62      </p>
63	  <h3>A dummy texture is attached to texture 0 when the model is created</h3>
64     <p>
65     	In SampleData\Graphics\Intermediate\shadow_sample\male.cmdl, dummy.ctex has been attached to texture 0.<br /> Projection mapping is applied to the dummy texture at this time.
66      </p>
67      <h3>Swap the dummy texture and shadow texture at setup time</h3>
68      <p>
69      	Use <span>SetTexture</span> to dynamically switch to the created shadow texture.
70      </p>
71  <hr><p>CONFIDENTIAL</p></body>
72</html>
73