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>GXInitLightAttnK</TITLE>
9</HEAD>
10<BODY>
11<H1 align="left">GXInitLightAttnK</H1>
12
13<H2>Syntax</H2>
14<dl><dd><pre class="construction">
15#include &lt;revolution/gx.h&gt;
16
17void GXInitLightAttnK(
18    <A href="../Structures/GXLightObj.html">GXLightObj</A>* lt_obj,
19    f32         k0,
20    f32         k1,
21    f32         k2 );
22</pre></dd></dl>
23
24<H2>Arguments</H2>
25<TABLE class="arguments" border="1" >
26  <TBODY>
27    <TR>
28<TH>lt_obj</TH>
29<TD>Pointer to a light object.</TD>
30    </TR>
31    <TR>
32<TH>k0</TH>
33<TD>Distance attenuation coefficient.</TD>
34    </TR>
35    <TR>
36<TH>k1</TH>
37<TD>Distance attenuation coefficient.</TD>
38    </TR>
39    <TR>
40<TH>k2</TH>
41<TD>Distance attenuation coefficient.</TD>
42    </TR>
43  </TBODY>
44</TABLE>
45
46<H2>Return Values</H2>
47<P>None.</P>
48
49<H2>Description</H2>
50<P>This function sets coefficients used in the lighting attenuation calculation in a given light object.&nbsp;The application must allocate memory for the light object.&nbsp;The <SPAN class="argument">k0</SPAN>, <SPAN class="argument">k1</SPAN> and <SPAN class="argument">k2</SPAN> coefficients are used for distance attenuation.&nbsp;The attenuation function is:</P>
51<P><CITE><EM>atten = <U>clamp0(<STRONG> a2</STRONG> * cos(theta)^2 +</U></EM><U> <EM><STRONG>a1</STRONG></EM> * <EM>cos(theta) +</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;&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>
52<P>Here <EM>cos(theta)</EM> is the cosine of the angle between the normal vector of the light and the vector from the light's position to the vertex. <EM>d</EM> is the distance from the light position to the vertex. The <SPAN class="argument">a0</SPAN>, <SPAN class="argument">a1</SPAN> and <SPAN class="argument">a2</SPAN> coefficients can be set using the <A href="GXInitLightAttnA.html"><CODE>GXInitLightAttnA</CODE></A> function. You can set both the <SPAN class="argument">a0</SPAN>, <SPAN class="argument">a1</SPAN>, <SPAN class="argument">a2</SPAN> and <SPAN class="argument">k0</SPAN>, <SPAN class="argument">k1</SPAN>, <SPAN class="argument">k2</SPAN> coefficients with the <A href="GXInitLightAttn.html"><CODE>GXInitLightAttn</CODE></A> function. The light color will be multiplied by the <EM>atten</EM> factor 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>
53<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>
54<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>
55<P>The <A href="GXInitLightSpot.html"><CODE>GXInitLightSpot</CODE></A> function can conveniently be used to set the angle attenuation coefficients based on several spotlight types. The <A href="GXInitLightDistAttn.html"><CODE>GXInitLightDistAttn</CODE></A> function can be used to set the distance attenuation coefficients using one of several common attenuation functions.</P>
56
57<H2>See Also</H2>
58<P class="reference">
59<A href="GXInitLightAttn.html">GXInitLightAttn</A>,
60<A href="GXInitLightAttnA.html">GXInitLightAttnA</A>,
61<A href="GXGetLightAttnK.html">GXGetLightAttnK</A>,
62<A href="GXSetChanCtrl.html">GXSetChanCtrl</A>,
63<A href="GXLightObjInitFlow.html">GXLightObj Initialization Flow</A>
64</P>
65
66<H2>Revision History</H2>
67<P>
682006/03/01 Initial version.<br>
69</P>
70
71<hr><p>CONFIDENTIAL</p></body>
72</HTML>