<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" 
               "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd" [
  <!ENTITY mathml "http://www.w3.org/1998/Math/MathML">
]>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<link rel="stylesheet" type="text/css" href="../../../comsci/css/s011.css"/>
<link rel='SHORTCUT ICON' href='../../../comsci/images/FrameHome.ico' />
<style type="text/css">
</style>
<title> The Lighting Equation </title>
</head>

<body>


<div class="message_right">
  <a href="http://validator.w3.org/check/referer">
    <img src="http://www.w3.org/Icons/valid-xhtml11" alt="Valid
	XHTML 1.1!" height="31" width="88" />
  </a>

  <a href="http://jigsaw.w3.org/css-validator/">
    <img style="width:88px;height:31px"
       src="http://jigsaw.w3.org/css-validator/images/vcss" 
       alt="Valid CSS!" />
  </a>
  <br/>
  Created 2004-06-19 &nbsp;  Modified 
<!--UPDATE_DATE_MODIFIED-->
<!--UPDATE_DATE_BEGIN-->
2007-01-01
<br/>
<a href="mailto:chelton.evans@yahoo.com">Chelton Evans</a>
<!--UPDATE_DATE_END-->
</div>


<h1> 
<a href="geom.html"> <img alt="proj" src="../../../comsci/images/compgeom.png" /></a>
 The Lighting Equation
<a href="../../../../index.html">
<img alt="home" src="../../../comsci/images/Frame.gif" /> </a>
</h1>


<div class="float20">

<p>
<a href="#lightequ"> Lighting Equation </a> <br/>
<a href="#general"> General Formula Discussion </a> <br/>
<a href="#pointin3d"> What is a Point in 3D Space </a> <br/>
<a href="#ambient"> Ambient Component </a> <br/>
<a href="#diffuse"> Diffuse Component </a> <br/>
<a href="#specular"> Specular Component </a> <br/>


</p>

</div>

<div>
<img src="diagg01301.png" alt="diagg01301.png" />
</div>



<div class="float40">

<a id="lightequ"> </a>
<h2> Lighting Equation </h2>

<p class="equ">
<math xmlns="&mathml;">
  <mi>I</mi>
  <msub>
    <mi></mi>
    <mrow><mi>&lambda;</mi></mrow>
  </msub>
  <mo>=</mo>
  <mi>I</mi>
  <msub>
    <mi></mi>
    <mrow><mi>a&lambda;</mi></mrow>
  </msub>
  <mi>k</mi>
  <msub>
    <mi></mi>
    <mrow><mi>a</mi></mrow>
  </msub>
  <mi>O</mi>
  <msub>
    <mi></mi>
    <mrow><mi>d&lambda;</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>f</mi>
  <msub>
    <mi></mi>
    <mrow><mi>att</mi></mrow>
  </msub>
  <mi>I</mi>
  <msub>
    <mi></mi>
    <mrow><mi>p&lambda;</mi></mrow>
  </msub>
  <mo>[</mo>
  <mi>k</mi>
  <msub>
    <mi></mi>
    <mrow><mi>d</mi></mrow>
  </msub>
  <mi>O</mi>
  <msub>
    <mi></mi>
    <mrow><mi>d&lambda;</mi></mrow>
  </msub>
  <mi>N</mi>
  <mi>L</mi>
  <mo>+</mo>
  <mi>k</mi>
  <msub>
    <mi></mi>
    <mrow><mi>s</mi></mrow>
  </msub>
  <mi>O</mi>
  <msub>
    <mi></mi>
    <mrow><mi>s&lambda;</mi></mrow>
  </msub>
  <mo>(</mo>
  <mi>R</mi>
  <mi>V</mi>
  <mo>)</mo>
  <msup>
    <mi></mi>
    <mrow><mi>n</mi></mrow>
  </msup>
  <mo>]</mo>
</math>



</p>

<p class="equ">
<math xmlns="&mathml;">
  <mi>I</mi>
</math>
 &nbsp; - &nbsp; is the <b>Intensity</b> <br/>
<math xmlns="&mathml;">
  <mi>a</mi>
</math>
 &nbsp; - &nbsp; is the <b>ambient</b> component. eg 
<math xmlns="&mathml;">
  <mi>I</mi>
  <msub>
    <mi></mi>
    <mrow><mi>a&lambda;</mi></mrow>
  </msub>
</math>
 is the ambient intensity.
<br/>

<math xmlns="&mathml;">
  <mi>f</mi>
  <msub>
    <mi></mi>
    <mrow><mi>att</mi></mrow>
  </msub>
</math>
 &nbsp; - &nbsp; is the light-source attenuation factor. 
Light drops off with increased distance from the light source.
<br/>


<math xmlns="&mathml;">
  <mi>&lambda;</mi>
</math>
 &nbsp; - &nbsp; is the <b> color component</b>. ie red, green or blue. <br/>
<math xmlns="&mathml;">
  <mi>k</mi>
</math>

 &nbsp; - &nbsp; is the <b>reflection coefficient</b>, the amount of light
 reflected from the surface. <br/>
<math xmlns="&mathml;">
  <mi>p</mi>
</math>
 &nbsp; - &nbsp; is the <b>light source point</b>. <br/>
<math xmlns="&mathml;">
  <mi>O</mi>
</math>
 &nbsp; - &nbsp; can be thought of as an operator accessing a color vector 
 for a color value.
 eg &nbsp; 

<math xmlns="&mathml;">
  <mi>O</mi>
  <msub>
    <mi></mi>
    <mrow><mi>d&lambda;</mi></mrow>
  </msub>
</math> 
 &nbsp; accesses the diffuse color vector with
 component
<math xmlns="&mathml;">
  <mi>&lambda;</mi>
</math>
.
<br/>

<math xmlns="&mathml;">
  <mi>d</mi>
</math>
 &nbsp; - &nbsp; is the <b>diffuse</b> color material property. In general
 our every day experience of color. <br/>

<math xmlns="&mathml;">
  <mi>s</mi>
</math>
 &nbsp; - &nbsp; is the <b>specular</b> reflection. <br/>

</p>


<p class="equ">
Let all the vectors be normalized and multiplication between 
 vectors is the dot product. <br/>
<math xmlns="&mathml;">
  <mi>L</mi>
</math>
 &nbsp; - &nbsp; is the <b>Light Source</b> vector. <br/>

<math xmlns="&mathml;">
  <mi>N</mi>
</math>
 &nbsp; - &nbsp; is the Normal of the geometry at .

</p>

</div>





<div class="spacer" />


<div class="float25">

<a id="pointin3d"> </a>
<h2> What is a point in 3D Space? </h2>

<p>
I've been thinking about this question over the last 6 months
 and find it very interesting.  For start forget the literal
 view of a point as being the absolute reality. In 3D space the
 simplest representation of a surface is a triangle so when
 viewing the light equation it is being applied to a triangle
 before hitting the screen.
</p>

<p>
The triangle can be mapped back to a point by interpolating. 
 eg consider an arbitrary point on the triangle. That point
 could have the average color of the three points.
 Similarly it could have the average normal of the three points.
</p>

<p>
The way that the lighting equations is written suggests how a point
 is to be interpreted. The given lighting equation is doing color
 and normal interpolation. The current graphics hardware does color 
 interpolation
 but not normal interpolation easily.
</p>

</div>

<div class="float25">

<p>
Now that the point is found in 3D space it is projected to 2D space 
 (the screen).
Pixels are another type of point and for viewing it was found better
 to do the calculation from the pixels point of view.
For each pixel go back and find the point in 3D space which it came from.
</p>

<p>
The consequences are vast - the maths is different in different directions,
 the hardware would need to be different to pipeline operations 
 and so is the quality of the image produced.
</p>

<p>
Back to the point in 3D space for a discussion on the normal vector at a point.
  The normal is perpendicular(at right angles) to the surface. In maths
 this describes the change of the surface, so even when the geometry is 
 not continuous having light reflected with the correct normal produces 
 realistic results. 
</p>

</div>

<div class="spacer" />

<div class="float25">
<a id="ambient"> </a>
<h2> Ambient Component </h2>

<p class="equ">
<math xmlns="&mathml;">
  <mi>I</mi>
  <msub>
    <mi></mi>
    <mrow><mi>a&lambda;</mi></mrow>
  </msub>
  <mi>k</mi>
  <msub>
    <mi></mi>
    <mrow><mi>a</mi></mrow>
  </msub>
  <mi>O</mi>
  <msub>
    <mi></mi>
    <mrow><mi>d&lambda;</mi></mrow>
  </msub>
</math>
</p>

<p> Ambient light is an approximation for light from all directions. 
 The background light. Contrast this with radiosity rendering which instead of
 assuming constant calculates the light reflected from surfaces. </p>

<a id="diffuse"> </a>
<h2> Diffuse Component </h2>
<p class="equ">
<math xmlns="&mathml;">
  <mi>k</mi>
  <msub>
    <mi></mi>
    <mrow><mi>d</mi></mrow>
  </msub>
  <mi>O</mi>
  <msub>
    <mi></mi>
    <mrow><mi>d&lambda;</mi></mrow>
  </msub>
  <mi>N</mi>
  <mi>L</mi>
</math>
</p>


</div>

<div class="float25">
<a id="specular"> </a>
<h2> Specular Component </h2>


<p class="equ">
<math xmlns="&mathml;">
  <mi>k</mi>
  <msub>
    <mi></mi>
    <mrow><mi>s</mi></mrow>
  </msub>
  <mi>O</mi>
  <msub>
    <mi></mi>
    <mrow><mi>s&lambda;</mi></mrow>
  </msub>
  <mo>(</mo>
  <mi>R</mi>
  <mi>V</mi>
  <mo>)</mo>
  <msup>
    <mi></mi>
    <mrow><mi>n</mi></mrow>
  </msup>
</math>
</p>



</div>

<div class="float25">
<a id="general"> </a>
<h2> General Formula Discussion </h2>

<p>
The lighting equation says how much light falls on a point.
 What is a point in 3D space? The equation is a linear sum
 (there are other ways to sum) and if the sum is greater than
 the maximum its set to the maximum. If the dot products
 result in a negative value the result is ignored and set to zero
 (summing of zero in a sum is ignoring).

</p>

</div>



</body>
</html>


