1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<html> 3 4<head> 5<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 6<META name="GENERATOR" content="Microsoft FrontPage 5.0"> 7<META http-equiv="Content-Style-Type" content="text/css"> 8<LINK rel="stylesheet" type="text/css" href="../../../CSS/revolution.css"> 9<title>tf-clip-bug</title> 10</head> 11 12<body> 13 14<h1 align="left">tf-clip-bug</h1> 15 16<h2>Description</h2> 17<p>This demo illustrates the clipping bug in the GX hardware. It allows one to vary different parameters in order to explore the various workarounds for this bug. It also allows one to explore Z-buffer resolution issues.</p> 18 19<h3>Clipping bug</h3> 20<p>The clipping bug affects rasterized colors. It is related to the fact that the GX hardware interpolates colors in screen space, as opposed to perspective-correct projected 3D space (although some people may say that the two issues are separate bugs). The bug comes into play when polygons which use rasterized color pass behind the eye point while still having a portion visible on screen. In this case, the calculated color at the near clipping plane will be incorrect. The clip calculation that is used reflects the type of interpolation that is done by the rasterization, as follows:</p> 21<BLOCKQUOTE> 22<pre>(v1*F*w1 + v2*(1-F)*w2) where v = new color value 23v = ----------------------- v1, v2 = vertex color values 24 (w1*F + w2*(1-F)) w1, w2 = vertex W values 25 F = interp. fraction</CODE></pre> 26</BLOCKQUOTE> 27<p>This calculation is correct as long as the W values are greater than zero (typically W = -Z, with the eye looking down the -Z axis). When one of the W values becomes negative (due to the vertex passing behind the eye), the interpolation turns into an extrapolation. Note that if the vertex color values are equal, there is not a problem.</p> 28 29<p>The bug tends to affect large wall, floor, or ceiling polygons that have a noticeable difference in their vertex color values. As the eye passes over these polygons, they will suddenly become darker or lighter (depending upon which vertex is being clipped) near the clipped side. A polygon that is not entirely grey may suddenly become colored.</p> 30 31<p>This demo draws two large wall polygons that use vertex colors. At the demo start, the user is positioned such that the bug is already taking place. By moving the substick, one can move back in order to see what the wall polygons should look like. One will notice that they have slight (and opposing) color differences. When one moves backwards between them, the colors shift around. This is the bug.</p> 32 33<h3>Work-arounds</h3> 34<p>There are various work-arounds for the problem:</p> 35<OL> 36 <LI> 37<P>Tessellate the large polygons to reduce the likelihood that they will remain visible as they pass behind the eye point. This work-around can be examined by holding down the R Button and pressing the X + Y Buttons. Note that changing the tessellation also affects the interpolation. The greater the degree of tessellation, the more perspective-correct the color interpolation will be.</P> 38 39 <LI> 40<P>Avoid using rasterized color. Use textures instead. For monochromatic or dichromatic lighting, use the light-based texgen to convert colors into texture coordinates. Then, use an unique texture map to get the color values out again. This work-around is not illustrated in this demo.</P> 41 42 <LI> 43<P>Reduce the field of view and/or bring the near plane closer to the eye. Either or both. These changes reduce the likelihood of seeing the clipped vertices. Bringing the near plane closer has adverse effects on Z precision, however, so this must be considered carefully. This work-around may be examined by adjusting these values. (See the Interactive Controls section below.) Problems with Z precision are illustrated by the green depth tags. Each tag is labeled with the Z coordinate of the tag (with the eye initially at Z=0). Behind each green tag is a similar red tag. If a red tag becomes visible, it is due to lack of Z-buffer resolution at that distance. The user can also adjust the framebuffer/Z-buffer mode by pressing the menu button.</P> 44 45</OL> 46 47<h2>Coverage</h2> 48<p>This program is designed to illustrate the clipping bug, not to test any specific GX functions.</p> 49 50<h2>Using the Demo</h2> 51<table border="1" cellspacing="0" width="100%"> 52 <tr> 53<td>Control Stick</td> 54<td>move camera position</td> 55 </tr> 56 <tr> 57<td>Sub-stick</td> 58<td>Move camera in Z</td> 59 </tr> 60 <tr> 61<td>A/B buttons</td> 62<td>Adjust near plane or FOV</td> 63 </tr> 64 <tr> 65<td>X/Y Buttons</td> 66<td>Adjust Z tag interplanar distance or wall tessellation</td> 67 </tr> 68 <tr> 69<td>Left trigger </td> 70<td>Hold to adjust FOV with A/B buttons</td> 71 </tr> 72 <tr> 73<td>Right trigger</td> 74<td>Hold to adjust tessellation with X/Y buttons</td> 75 </tr> 76 <tr> 77<td>START</td> 78<td>Toggle framebuffer/Z-buffer modes (16/24 bit)</td> 79 </tr> 80</table> 81 82<h2>Snapshot</h2> 83<p>TBD.</p> 84 85<h2>Required Data Files</h2> 86<p>None.</p> 87 88<H2>Revision History</H2> 89<P> 902006/03/01 Initial version.<br> 91</P> 92 93<hr><p>CONFIDENTIAL</p></body> 94</html>