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>ShadowMapDemo</CODE></h1> 11 12 <div class="section"><img src="images/ShadowMapDemo.png" border="0" width="400" height="240" /></div> 13 14 <h2>Overview</h2> 15 <p> 16 Demo for creating a depth map that saves distances from a light and then shading using this information. 17 </p> 18 19 <h2>How to Use</h2> 20 <p> 21 <ul> 22 <li>Demo-specific operations</li> 23 <ul> 24 <li>None.</li> 25 </ul> 26 <li>Common Operations</li> 27 <ul> 28 <li>Circle Pad: Rotate the camera</li> 29 <li>Circle Pad + A Button: Move the camera back and forth</li> 30 <li>Circle Pad + B Button: Translate the camera</li> 31 <li>Circle Pad + Y Button: Move the camera up and down</li> 32 <li>X Button: Reset the camera position</li> 33 <li>START Button: Restart the demo</li> 34 </ul> 35 </ul> 36 </p> 37 38 <h2>Description</h2> 39 <p> 40 Demo for creating a depth map that saves the distances from a light and then shading using this information.<br /> Unlike <a href="ProjectionShadowDemo.html"><CODE>ProjectionShadowDemo</CODE></a>, self-shadowing can be excluded. <BR>This section describes points that differ from ProjectionShadowDemo. 41 </p> 42 <h3>Using shadow map textures</h3> 43 <p> 44 With <CODE>ProjectionShadow</CODE>, <CODE>ResImageTexture</CODE> is used as the offscreen buffer, whereas with <CODE>ShadowMap</CODE>, <CODE>ResShadowTexture</CODE> is used as the offscreen buffer. 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. 45 </p> 46 <h3 class="separator">Setting wScale for the shadow camera</h3> 47 <p> 48 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. 49 </p> 50 <h3 class="separator">Setting the shadow mode of a shadow material</h3> 51 <p> 52 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. 53 </p> 54 <h3 class="separator">Always set the diffuse color of a shadow material to black</h3> 55 <p> 56 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) 57 </p> 58 <h3 class="separator">Set the shadow texture for materials that cast shadows</h3> 59 <p> 60 Although <CODE>ShadowMap</CODE> is essentially the same as <CODE>ProjectionShadow</CODE>, you must switch the <CODE>MappingMethod</CODE> of the <CODE>TextureCoordinator</CODE> when using <CODE>ShadowMap</CODE>. Set <a href="../../../nw/gfx/res/ResTextureCoordinator/SetMappingMethod.html"><CODE>SetMappingMethod</CODE></a> to <CODE>nw::gfx::ResTextureCoordinator::MAPPINGMETHOD_SHADOW</CODE> to change the texture matrix calculation method. 61 </p> 62 <hr><p>CONFIDENTIAL</p></body> 63</html> 64 65