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
13<H2>Syntax</H2>
14<dl><dd><pre class="construction">
15#include &lt;revolution/gx.h&gt;
16
17void 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 );
25</pre></dd></dl>
26
27<H2>Arguments</H2>
28<TABLE class="arguments" border="1" >
29  <TBODY>
30    <TR>
31<TH>lt_obj</TH>
32<TD>Pointer to a light object.</TD>
33    </TR>
34    <TR>
35<TH>a0</TH>
36<TD>Angular attenuation coefficient.</TD>
37    </TR>
38    <TR>
39<TH>a1</TH>
40<TD>Angular attenuation coefficient.</TD>
41    </TR>
42    <TR>
43<TH>a2</TH>
44<TD>Angular attenuation coefficient.</TD>
45    </TR>
46    <TR>
47<TH>k0</TH>
48<TD>Distance attenuation coefficient.</TD>
49    </TR>
50    <TR>
51<TH>k1</TH>
52<TD>Distance attenuation coefficient.</TD>
53    </TR>
54    <TR>
55<TH>k2</TH>
56<TD>Distance attenuation coefficient.</TD>
57    </TR>
58  </TBODY>
59</TABLE>
60
61<H2>Return Values</H2>
62<P>None.</P>
63
64<H2>Description</H2>
65<P>This function sets coefficients used in the lighting attenuation calculation for a given light object.&nbsp;The application must allocate the memory for the light object.&nbsp;The arguments <SPAN class="argument">a0</SPAN>, <SPAN class="argument">a1</SPAN>, and <SPAN class="argument">a2</SPAN> are used for angular (spotlight) attenuation.&nbsp;The coefficients <SPAN class="argument">k0</SPAN>, <SPAN class="argument">k1</SPAN>, and <SPAN class="argument">k2</SPAN> are used for distance attenuation.&nbsp;The attenuation function is:</P>
66<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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;k2</STRONG></EM> <EM>* d^2 +</EM> <EM><STRONG>k1</STRONG></EM> * <EM>d +</EM> <STRONG><EM>k0</EM></STRONG></CITE></P>
67<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. Likewise, <EM>d</EM> is the distance from the light position to the vertex when the channel attenuation function is <CODE>GX_AF_SPOT</CODE>.&nbsp;The light color will be multiplied by the <EM>atten</EM> coefficient when the attenuation function for the color channel referencing this light is set to <CODE>GX_AF_SPOT</CODE> (see the <A href="GXSetChanCtrl.html"><CODE>GXSetChanCtrl</CODE></A> function).</P>
68<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>
69<P>The <A href="GXInitLightSpot.html"><CODE>GXInitLightSpot</CODE></A> function is a convenient way to set the angle attenuation coefficients based on several spotlight types. The <A href="GXInitLightDistAttn.html"><CODE>GXInitLightDistAttn</CODE></A> function is a handy way to set the distance attenuation coefficients using one of several common attenuation functions.</P>
70<P>When the channel attenuation function is set to <CODE>GX_AF_SPEC</CODE>, the <EM>aattn</EM> and <EM>d</EM> arguments are equal to the dot product of the visual space vertex normal and the half-angle vector set by the <A href="GXInitSpecularDir.html"><CODE>GXInitSpecularDir</CODE></A> function.</P>
71<P>The <A href="GXInitLightShininess.html"><CODE>GXInitLightShininess</CODE></A> macro can be easily used to set attenuation parameters for specular lights.</P>
72<P>Be aware that this function does not load any hardware registers directly.&nbsp;To load a light object into a hardware light, use the <A href="GXLoadLightObjImm.html"><CODE>GXLoadLightObjImm</CODE></A> or <A href="GXLoadLightObjIndx.html"><CODE>GXLoadLightObjIndx</CODE></A> function.</P>
73
74<H2>See Also</H2>
75<P class="reference">
76<A href="GXInitLightAttnA.html">GXInitLightAttnA</A>,
77<A href="GXInitLightAttnK.html">GXInitLightAttnK</A>,
78<A href="GXInitLightSpot.html">GXInitLightSpot</A>,
79<A href="GXInitLightDistAttn.html">GXInitLightDistAttn</A>,
80<A href="GXInitLightShininess.html">GXInitLightShininess</A>,
81<A href="GXSetChanCtrl.html">GXSetChanCtrl</A>,
82<A href="GXLightObjInitFlow.html">GXLightObj Initialization Flow</A>
83</P>
84
85<H2>Revision History</H2>
86<P>
872006/03/01 Initial version.<br>
88</P>
89
90<hr><p>CONFIDENTIAL</p></body>
91</HTML>