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>GXInitLightAttn</TITLE> 9</HEAD> 10<BODY> 11<H1 align="left">GXInitLightAttn</H1> 12<H2>C Specification</H2> 13<DL> 14 <DD> 15 <PRE><CODE>#include <revolution/gx.h></CODE></PRE> 16 <DD> 17 <PRE><CODE>void GXInitLightAttn( 18 <A href="../Structures/GXLightObj.html">GXLightObj</A>* lt_obj, 19 f32 a0, 20 f32 a1, 21 f32 a2, 22 f32 k0, 23 f32 k1, 24 f32 k2 );</CODE></PRE> 25</DL> 26<H2>Arguments</H2> 27<TABLE border="1" cellpadding="3" cellspacing="0.1"> 28 <TBODY> 29 <TR> 30<TD width="120" bgcolor="#ffffe8"><EM><STRONG><CODE>lt_obj</FONT></STRONG></EM></TD> 31<TD width="520">pointer to a light object</TD> 32 </TR> 33 <TR> 34<TD width="120" bgcolor="#ffffe8"><EM><STRONG><CODE>a0</FONT></STRONG></EM></TD> 35<TD width="520">angular attenuation coefficient</TD> 36 </TR> 37 <TR> 38<TD width="120" bgcolor="#ffffe8"><EM><STRONG><CODE>a1</FONT></STRONG></EM></TD> 39<TD width="520">angular attenuation coefficient</TD> 40 </TR> 41 <TR> 42<TD width="120" bgcolor="#ffffe8"><EM><STRONG><CODE>a2</FONT></STRONG></EM></TD> 43<TD width="520">angular attenuation coefficient</TD> 44 </TR> 45 <TR> 46<TD width="120" bgcolor="#ffffe8"><EM><STRONG><CODE>k0</FONT></STRONG></EM></TD> 47<TD width="520">distance attenuation coefficient</TD> 48 </TR> 49 <TR> 50<TD width="120" bgcolor="#ffffe8"><EM><STRONG><CODE>k1</FONT></STRONG></EM></TD> 51<TD width="520">distance attenuation coefficient</TD> 52 </TR> 53 <TR> 54<TD width="120" bgcolor="#ffffe8"><EM><STRONG><CODE>k2</FONT></STRONG></EM></TD> 55<TD width="520">distance attenuation coefficient</TD> 56 </TR> 57 </TBODY> 58</TABLE> 59<H2>Return Values</H2> 60<P>None.</P> 61<H2>Description</H2> 62<P>This function sets coefficients used in the lighting attenuation calculation for a given light object. The application must allocate the memory for the light object. The arguments <code>a0</code>, <code>a1</code> and <code>a2</code> are used for angular (spotlight) attenuation. The coefficients <code>k0</code>, <code>k1</code> and <code>k2</code> are used for distance attenuation. The attenuation function is:</P> 63<P><CITE><EM>atten = <U>clamp0(<STRONG> a2</STRONG> * aattn^2 +</U></EM><U> <EM><STRONG>a1</STRONG></EM> * <EM>aattn +</EM> <EM><STRONG>a0</STRONG></EM> )</U><BR> <EM><STRONG> k2</STRONG></EM> <EM>* d^2 +</EM> <EM><STRONG>k1</STRONG></EM> * <EM>d +</EM> <STRONG><EM>k0</EM></STRONG></CITE></P> 64<P>where <em>aattn</em> is the cosine of the angle between the light direction and the vector from the light position to the vertex, and <em>d</em> is the distance from the light position to the vertex when the channel attenuation function is <code>GX_AF_SPOT</code>. The light color will be multiplied by the <CODE>atten</CODE> coefficient when the attenuation function for the color channel referencing this light is set to <code>GX_AF_SPOT</code> (see <a href="GXSetChanCtrl.html"><code>GXSetChanCtrl</code></a>).</P> 65<P>All coefficients are represented with a 20-bit floating point format (1-bit sign, 8-bit exponent, and 11-bit significand) in the hardware, as for other arguments associated with vertex lighting. Be aware of possible rounding errors as a result.</P> 66<P>The function <a href="GXInitLightSpot.html"><code>GXInitLightSpot</code></a> is a convenient way to set the angle attenuation coefficients based on several spotlight types. The function <a href="GXInitLightDistAttn.html"><code>GXInitLightDistAtten</code></a> is a handy way to set the distance attenuation coefficients using one of the several common attenuation functions.</P> 67<P>When the channel attenuation function is set to <code>GX_AF_SPEC</code>, the <CODE>aattn</CODE> and <CODE>d</CODE> arguments are equal to the dot product of the visual space vertex normal and the half-angle vector set by <a href="GXInitSpecularDir.html"><code>GXInitSpecularDir</code></a>.</P> 68<P>The macro <a href="GXInitLightShininess.html"><code>GXInitLightShininess</code></a> can be easily used to set attenuation parameters for specular lights.</P> 69<P>Be aware that this function does not load any hardware registers directly. To load a light object into a hardware light, use <a href="GXLoadLightObjImm.html"><code>GXLoadLightObjImm</code></a> or <a href="GXLoadLightObjIndx.html"><code>GXLoadLightObjIndx</code></a>.</P> 70<H2>See Also</H2> 71<P><CODE><A href="GXInitLightAttnA.html">GXInitLightAttnA</A><BR> <A href="GXInitLightAttnK.html">GXInitLightAttnK</A><BR> <A href="GXInitLightSpot.html">GXInitLightSpot</A><BR> <A href="GXInitLightDistAttn.html">GXInitLightDistAttn</A><BR> <A href="GXInitLightShininess.html">GXInitLightShininess</A><BR> <A href="GXSetChanCtrl.html">GXSetChanCtrl</A></CODE></P> 72<P><A href="GXLightObjInitFlow.html"><CODE>GXLightObj</CODE> Initialization Flow</A></P> 73<H2>Revision History</H2> 74<P>2006/03/01 Initial version.</P> 75<hr> 76<P>CONFIDENTIAL</p> 77</BODY> 78</HTML>