1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<HTML> 3<HEAD> 4<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 5<META name="GENERATOR" content="Microsoft FrontPage 5.0"> 6<META http-equiv="Content-Style-Type" content="text/css"> 7<LINK rel="stylesheet" type="text/css" href="../../../CSS/revolution.css"> 8<TITLE>tg-spheremap</TITLE> 9</HEAD> 10<BODY> 11<H1 align="left">tg-spheremap</H1> 12 13<H2>Description</H2> 14<P><code>tg-spheremap</code> illustrates a method for converting a cube map into a sphere map. Sphere maps can be used for reflection mapping. Generating sphere maps is efficient but must be re-rendered when the viewpoint changes. Of course, if the environment itself changes, you will also need to regenerate the map.</P> 15<P>This demo creates a sphere map by projecting each face of the cube map onto a sphere. In this case, the normal vectors of the sphere are actually reflection vectors. The reflection vectors are projected into texture coordinates that warp the texture of the cube map onto the surface of the sphere. A 3D model (torus) is also displayed with the sphere map as an example of reflection mapping.</P> 16<P>This demo has controls that help visualize the steps that are required to generate the sphere map, which include clipping the +q coordinate of the projected texture and generating a composite alpha for each individual map. Two sets of prerendered cube maps are provided: One that has labels for left, right, top, bottom, back, and front, and another that is taken from the <em>courtyard</em> database.</P> 17<H2>Coverage</H2> 18<TABLE border="1" cellpadding="3" cellspacing="0.1" width="640"> 19 <TBODY> 20 <TR> 21<TD width="30%" bgcolor="#C0C0C0"><EM><STRONG>Function</STRONG></EM></TD> 22<TD width="25%" bgcolor="#C0C0C0"><EM><STRONG>Parameters</STRONG></EM></TD> 23<TD width="45%" bgcolor="#C0C0C0"><EM><STRONG>Description</STRONG></EM></TD> 24 </TR> 25 <TR> 26<TD width="30%" rowspan="3"><A href="../../../gx/Transform/GXLoadTexMtxImm.html"><FONT face="Courier New">GXLoadTexMtxImm</FONT></A></TD> 27<TD width="25%">Matrices</TD> 28<TD width="45%">Appropriate projection matrix.</TD> 29 </TR> 30 <TR> 31<TD width="25%">Matrix destination</TD> 32<TD width="45%"><FONT face="Courier New">GX_TEXMTX0</FONT></TD> 33 </TR> 34 <TR> 35<TD width="25%">Types</TD> 36<TD width="45%"><FONT face="Courier New">GX_MTX3x4</FONT></TD> 37 </TR> 38 <TR> 39<TD width="30%" rowspan="4"><A href="../../../gx/TexCoordGen/GXSetTexCoordGen.html"><FONT face="Courier New">GXSetTexCoordGen</FONT></A></TD> 40<TD width="25%">Destination coordinates.</TD> 41<TD width="45%"><FONT face="Courier New">GX_TEXCOORD0</FONT></TD> 42 </TR> 43 <TR> 44<TD width="25%">Generation type.</TD> 45<TD width="45%"><FONT face="Courier New">GX_TG_MTX3x4</FONT></TD> 46 </TR> 47 <TR> 48<TD width="25%">Generation source.</TD> 49<TD width="45%"><FONT face="Courier New">GX_TG_POS</FONT></TD> 50 </TR> 51 <TR> 52<TD width="25%">Matrix source</TD> 53<TD width="45%"><FONT face="Courier New">GX_TEXMTX0</FONT></TD> 54 </TR> 55 </TBODY> 56</TABLE> 57<H2>Operation Method</H2> 58<P>START exits the test. The <STRONG>Control Stick</STRONG> rotates the reflection-mapped torus. The <strong>A Button</strong> selects the cube map texture. The <strong>B Button</strong> displays individual cube faces. The <strong>Y Button</strong> displays all the cube faces in the sphere map. The <strong>Z Button</strong> selects the alpha/color channel to display.</P> 59<H2>Snapshot</H2> 60<P>Test cube map that visualizes how the cube is projected onto the sphere map.</P> 61<P> 62<IMG src="./images/tg-spheremap-0.jpg" alt="tg-spheremap-0.jpg (33065 bytes)" width="640" height="448"></P> 63<P>Environment map example taken from the courtyard database.</P> 64<P> 65<IMG src="./images/tg-spheremap-1.jpg" alt="tg-spheremap-1.jpg (24219 bytes)" width="640" height="448"></P> 66<H2>Required Data Files</H2> 67<P><CODE>$REVOLUTION_SDK_ROOT/dvddata/gxTests/tg-cube.tpl<BR> $REVOLUTION_SDK_ROOT/dvddata/gxTests/tg-cube1.tpl</CODE></P> 68<H2>Revision History</H2> 69<P>2006/03/01 Initial version.</P> 70<hr> 71<P>CONFIDENTIAL</p> 72</BODY> 73</HTML>