Graphics Reference
In-Depth Information
radial falloff. In the real world, the total power observed at distance r from a uni-
form spherical emitter whose radius is much smaller than r is proportional to 1
r 2 .
We can generalize this by computing a value M that involves an inverse quadratic:
/
Φ
( a 0 r 0 m 2 + a 1 r 1 m 1 + a 2 r 2 m 0 ) 4
M =
.
(14.44)
π
If we define a and r by
a =( a 0 m 2 , a 1 m 1 , a 2 m 0 ) , and
(14.45)
r =( r 0 , r 1 , r 2 ) ,
(14.46)
then we can rewrite the formula for M as
Φ
M =
.
(14.47)
a
·
r 4
π
This strange expression lets us represent a point emitter that experiences non-
physical falloff to approximate a local area source or distant point source ...or
simply to satisfy an artistic vision. In this context, a directional source can be
parameterized by the attenuation constant
a =( 1, 0, 0 ) . This source will produce
equal intensity at all points in the scene, and that intensity is comparable to what
a local source with power Φ one meter from a surface would produce.
The resulting interface (Listing 14.15) follows the spirit of the OpenGL fixed-
function lighting model, albeit with slightly varying units and border cases. We do
not recommend this model for physically based rendering.
Listing 14.15: A simple unified model for spot, directional,
and omni light sources.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class PointLight : public Light {
private :
/ ** For local lights, this is the total power of the light source.
For directional lights, this is the power of an equivalent
local source 1ˆm from the surface. * /
Power3
Phi;
Vector3
axis;
/ ** Center of the light in homogeneous coordinates. * /
Vector4
C;
Vector3
aVec;
float
spotHalfAngle;
...
};
Listing 14.16: PointLight methods for direct illumination.
1
2
3
4
Vector4 PointLight::randomPoint() const {
return C;
}
 
Search WWH ::




Custom Search