Computing the intensity of specularly reflected light
The intensity of specularly reflected light from an illuminated object is represented by an algebraic expression including multiplication, addition, and subtraction operations. The algebraic expression is used in an illumination model, where the illumination model describes the color and intensity of light reflected by the illuminated object. Light reflected by the illuminated object is composed of ambient, diffuse, and specular components. The specular terms used in the illumination model are equivalent in functional form to the diffuse terms, thereby accelerating the computation of color vector c defined by the illumination model. A modified algebraic expression representing specularly reflected light from an illuminated object is defined and used in the illumination model, thereby accelerating computation of color vector c.
Latest Patents:
This application is a continuation and claims the priority benefit of U.S. patent application Ser. No. 10/901,840 entitled “Method for Computing the Intensity of Specularly Reflected Light” filed Jul. 28, 2004 and now U.S. Pat. No. 7,______, which is a continuation and claims the priority benefit of U.S. patent application Ser. No. 09/935,123 entitled “Method for Computing the Intensity of Specularly Reflected Light” filed Aug. 21, 2001 and now U.S. Pat. No. 6,781,594. The disclosure of these commonly owned and assigned applications are incorporated herein by reference.
BACKGROUND OF THE INVENTION1. Field of the Invention
This invention relates generally to computer generated images and more particularly to a method for computing the intensity of specularly reflected light.
2. Description of the Background Art
The illumination of a computer-generated object by colored light sources and ambient light is described by an illumination model. The illumination model is a mathematical expression including ambient, diffuse, and specular illumination terms. The object is illuminated by the reflection of ambient light and the reflection of light source light from the surface of the object. Therefore, the illumination of the object is composed of ambient, diffuse, and specularly reflected light. Given ambient light and light sources positioned about the object, the illumination model defines the reflection properties of the object.
The illumination model is considered to be accurate if the illuminated object appears realistic to an observer. Typically, the illumination model is incorporated in a program executed by a rendering engine, a vector processing unit, or a central processing unit (CPU). The program must be capable of computing the illumination of the object when the light sources change position with respect to the object, or when the observer views the illuminated object from a different angle, or when the object is rotated. Furthermore, an efficient illumination model is needed for the program to compute the illumination in real-time, for example, if the object is rotating. Therefore, it is desired to incorporate terms in the illumination model that are computationally cost effective, while at the same time generating an image of the illuminated object that is aesthetically pleasing to the observer.
Ambient light is generalized lighting not attributable to direct light rays from a specific light source. In the physical world, for example, ambient light is generated in a room by multiple reflections of overhead florescent light by the walls and objects in the room, providing an omni-directional distribution of light. The illumination of the object by ambient light is a function of the color of the ambient light and the reflection properties of the object.
The illumination of the object by diffuse and specular light depends upon the colors of the light sources, positions of the light sources, the reflection properties of the object, the orientation of the object, and the position of the observer. Source light is reflected diffusely from a point on the object's surface when the surface is rough, scattering light in all directions. Typically, the surface is considered rough when the scale length of the surface roughness is approximately the same or greater than the wavelength of the source light.
If the scale length of the surface roughness is much less than the wavelength of the source light, then the surface is considered smooth, and light is specularly reflected. Specularly reflected light is not scattered omni-directionally about a point on the object's surface, but instead is reflected in a preferred direction.
Typically, objects reflect light diffusely and specularly, and in order to generate a realistic illumination of the computer-generated object that closely resembles the real physical object, both diffuse and specular reflections need to be considered.
Reflection of light from a perfectly smooth surface obeys Snell's law. Snell's law states that the angle of incidence θi 245 is equal to the angle of reflection θr 250. If surface 220 is a perfectly smooth surface, light from source 210 directed along the unit vector −1 260 at an angle of incidence θi 245 is reflected at point P 225 along unit vector r 230 at an angle of reflection θr 250, where θi=θr. Consequently, if surface 220 is a perfectly smooth surface, then light directed along −1 260 from source 210 and specularly reflected at point P 225 would not be detected by observer 240, since specularly reflected light is directed only along unit vector r 230. However, a surface is never perfectly smooth, and light directed along −I 260 from source 210 and specularly reflected at point P 225 has a distribution about unit vector r 230, where unit vector r 230 points in the preferred direction of specularly reflected light. The preferred direction is specified by equating the angle of incidence θi 245 with the angle of reflection θr 250. In other words, specular reflection intensity as measured by observer 240 is a function of angle θrv 255, having a maximum reflection intensity when θrv=0 and decreasing as θrv 255 increases. That is, observer 240 viewing point P 225 of the surface 220 detects a maximum in the specular reflection intensity when unit vector v 235 is co-linear with unit vector r 230, but as observer 240 changes position and angle θrv 235 increases, observer 240 detects decreasing specular reflection intensities.
A first prior art method for computing the intensity of specularly reflected light is to represent the specular intensity as f(r,v,n)∝(r·v)n, where 1≦n≦∞ and n is a parameter that describes the shininess of the object. Since r and v are unit vectors, the dot product r·v=cos θrv, and therefore, f(r,v,n)∝ cosn θrv.
A second prior art method computes the intensity of specularly reflected light in an alternate manner. For example,
The first and second prior art methods for computing the intensity of specularly reflected light are computationally expensive compared to the calculation of the diffuse and ambient terms that make up the remainder of the illumination model. Specular intensity as defined by the prior art is proportional to cosn θ, where θ≡θrv or θ≡θnh. The exponential specular intensity function cosn θ can be evaluated for integer n, using n−1 repeated multiplications, but this is impractical since a typical value of n can easily exceed 100. If the exponent n is equal to a power of two, for example n=2m, then the specular intensity may be calculated by m successive squarings. However, the evaluation of specular intensity is still cost prohibitive. If n is not an integer, then the exponential and logarithm functions can be used, by evaluating cosn θ as e(nln(cos θ)), but exponentiation is at least an order of magnitude slower than the operations required to compute the ambient and diffuse illumination terms.
A third prior art method of computing specular intensity is to replace the exponential specular intensity function with an alternate formula that invokes a similar visual impression of an illuminated object, however without exponentiation. Specular intensity is modeled by an algebraic function h(t,n)=t/ (n−nt+t), where either t=cos θrv or t=cos θnh, and n is a parameter that describes the shininess of the object. The algebraic function h(t,n) does not include exponents, but does include multiplication, addition, subtraction, and division operators. These algebraic operations are usually less costly than exponentiation. However, while the computation time has been reduced, in many computer architectures division is still the slowest of these operations.
It would be useful to implement a cost effective method of calculating specular intensity that puts the computation of the specular term on a more even footing with the computation of the ambient and diffuse terms, while providing a model of specular reflection that is aesthetically pleasing to the observer.
SUMMARY OF THE INVENTIONIn accordance with the present invention, an algebraic method is disclosed to compute the intensity of specularly reflected light from an object illuminated by a plurality of light sources. The plurality of light sources include point light sources and extended light sources. The algebraic expression Si(n,hi,n)=1−n+max{n·(nhi), n−l} represents the intensity of light reflected from a point on the object as measured by an observer, the object illuminated by an ith light source. The algebraic expression includes multiplication, addition, and subtraction operators. The algebraic expression approximates the results of prior art models of specular reflection intensity, but at lower computational costs.
The algebraic expression for specular intensity is substituted into an illumination model, where the illumination model includes ambient, diffuse, and specular illumination terms. The illumination model is incorporated into a software program, where the program computes a color vector c representing the color and intensity of light reflected by an object illuminated by a plurality of light sources. The reflected light is composed of ambient, diffuse, and specular components. The specular terms in the illumination model are equivalent in functional form to the diffuse terms, thereby providing an efficient and inexpensive means of computing the specular component of the color vector c. That is, a vector-based hardware system that computes and sums the ambient and diffuse terms can be used to compute and sum the ambient, diffuse, and specular terms at very little additional cost.
A modified algebraic expression SMi,k(n,hi,n)=(1−n/k+max{n·(n/khi), n/k−1})k represents the intensity of light reflected from a point on the object, where the object is illuminated by the ith light source, and 2≦k≦n. The first (k−l) derivatives of the modified algebraic expression SMi,k(n,hi,n) are continuous, and therefore by increasing the value of k, the modified algebraic expression more closely approximates the prior art specular intensity functions, but at a lower computational cost.
BRIEF DESCRIPTION OF THE DRAWINGS
CPU 312, VPU 313, GPU 314, and IOP 316 communicate via a system bus 344. CPU 312 communicates with main memory 310 via a dedicated bus 342. VPU 313 and GPU 314 may also communicate via a dedicated bus 340.
CPU 312 executes programs stored in OS ROM 328 and main memory 310. Main memory 310 may contain pre-stored programs and may also contain programs transferred via IOP 316 from a CD-ROM or DVD-ROM (not shown) using optical disc control unit 334. IOP 316 controls data exchanges between CPU 312, VPU 313, GPU 314 and other devices of system 300, such as controller interface 320.
Main memory 310 includes, but is not limited to, a program having game instructions including an illumination model. The program is preferably loaded from a CD-ROM via optical disc control unit 334 into main memory 310. CPU 312, in conjunction with VPU 313, GPU 314, and SPU 332, executes game instructions and generates rendering instructions using inputs received via controller interface 320 from a user. The user may also instruct CPU 312 to store certain game information on memory card 322. Other devices may be connected to system 300 via USB interface 324 and IEEE 1394 interface 326.
VPU 313 executes instructions from CPU 312 to generate color vectors associated with an illuminated object by using the illumination model. SPU 332 executes instructions from CPU 312 to produce sound signals that are output on an audio device (not shown). GPU 314 executes rendering instructions from CPU 312 and VPU 313 to produce images for display on a display device (not shown). That is, GPU 314, using the color vectors generated by VPU 313 and rendering instructions from CPU 312, renders the illuminated object in an image.
The illumination model includes ambient, diffuse, and specular illumination terms. The specular terms are defined by substituting a specular intensity function into the illumination model. In the present invention, specular intensity is modeled by the function S, where S(n,h,n)=1−n+max{n·(nh), n−1} and the function max{n·(nh), n−1} selects the maximum of n·(nh) and n−1. The unit vector n 275 and the unit vector h 290 are described in conjunction with
In contrast to the prior art specular intensity functions, specular intensity function S does not include exponentiation nor does function S include a division. Therefore, computing function S is less costly than computing the prior art specular intensity functions. In addition, the graph of function S is similar to the prior art specular intensity functions, thereby providing a reasonable model for specular reflection.
For example,
Note that as the shininess parameter n increases, the width of each function decreases, where the width of each function can be measured at a specular intensity value of 0.5, for example. The relation between the width of the specular intensity function and the shininess parameter n is explained further below in conjunction with
Therefore, specular intensity function S according to the present invention properly models the shininess of an object as embodied in the shininess parameter n.
As will be discussed further below in conjunction with
Diffuse intensity is modeled by the function Di=max{n·1i, 0} of the prior art, where Di is the diffuse intensity of point P 625 illuminated by the ith light source 610, and detected by observer 635. Given specular intensity Si, diffuse intensity Di, and ambient light, an illumination model for a resulting color vector c is defined. The color vector c is a vector in (R,G,B)-space and is used to describe the resulting color and light intensity of an illuminated object viewed by an observer, due to specular, diffuse, and ambient light reflection.
Given M light sources, the equation for color vector c 705 of the present invention is written as
Sici, where kd, ks are diffuse and specular reflection coefficient vectors, respectively, ca is the color of the ambient light, and ci is the color of the ith light source 610. Vectors ca and ci are vectors in (R,G,B)-space. space. The summation symbol is used to sum the index I over all M light sources, and the symbol {circle around (×)} operates on two vectors to give the component-wise product of the two vectors.
Substituting the diffuse intensity Di and the specular intensity Si into the equation for color vector c, and rearranging terms, the equation can be written as
The vector a includes an ambient color vector. The sum over index i for j=1 is a summation over all the diffuse color vectors generated by the M light sources, and the sum over index i for j=2 is a summation over all the specular color vectors generated by the M light sources. For example, uli=li, mli=0, and cli=kd ci are the diffuse terms that generate the diffuse color vector for the ith light source, and u2i=nhi, m2i=n−1, and c2i=ks ci are the specular terms that generate the specular color vector for the ith light source.
Each term in the summation over i and j in the expression for the color vector c has the same form. In other words, the specular illumination term max(n·u2i, m2i) for the ith light source has the same functional form as the diffuse illumination term max(n·uli, mli), and therefore, using vector-based computer hardware, such as VPU 313 of
In addition, if for each light source i 610, the light source direction vector li 605, the observer vector v 630, the shininess index n, the color of the light ci, and the diffuse and specular reflection coefficients kd, ks, respectively, are constant over surface 620 of object 670, which is a valid assumption for certain circumstances such as when light source i 610 and observer 635 are placed far from object 670, then variables uli, mli, cli, u2i, m2i, and c2i only need to be calculated once for each light source i 610. Consequently, the additional cost introduced by the calculation of the specular and diffuse terms in comparison to the calculation of only the diffuse terms is very negligible, since the calculation of the specular and diffuse reflected light from every point on surface 620 of object 670 only involves a parallel computation of the vector dot products and a summation of 2M diffuse and specular terms given M light sources The calculation does not involve a computation of variables uli, mli, cli, u2i, m2i, and cli at every point on surface 620 of object 670 for each light source i 610. In other words, for a given light source i 610, the unit vector n 615 is the only component of the color equation that is variable over surface 620 of object 670, and hence the calculation of the specular terms are “almost free” in comparison to the calculation of the diffuse terms alone.
As illustrated in
Referring to
The invention has been explained above with reference to preferred embodiments. Other embodiments will be apparent to those skilled in the art in light of this disclosure. The present invention may readily be implemented using configurations other than those described in the preferred embodiments above. For example, the program including the illumination model, according to the invention, may be executed in part or in whole by the CPU, the VPU, the GPU, or a rendering engine (not shown). Additionally, the present invention may effectively be used in conjunction with systems other than the one described above as the preferred embodiment. Therefore, these and other variations upon the preferred embodiments are intended to be covered by the present invention, which is limited only by the appended claims.
Claims
1. A method for computing the intensity of specularly reflected light, comprising:
- representing the intensity of light reflected specularly from an object illuminated by a plurality of light sources by an algebraic expression;
- incorporating the algebraic expression into an illumination model for the illumination of the object, the model having specular illumination terms; and
- expressing the specular illumination terms of the illumination model in the same functional form as other terms of the illumination model.
2. The method of claim 1, wherein the algebraic expression does not include division or exponentiation operators.
3. The method of claim 1, wherein the plurality of light sources includes extended light sources and point light sources.
4. The method of claim 1, wherein the algebraic expression is Si(n,hi,n)=1−n+max{n·(nhi), n−1}, which describes the intensity of light reflected from a point on the object as measured by an observer, the object illuminated by light from an ith light source, where n is a unit vector normal to the object at the point of reflection, hi is a unit vector bisecting an angle subtended by a unit vector pointing towards the ith light source from the point of reflection and a unit vector pointing towards the observer from the point of reflection, and n is a parameter that describes the shininess of the object.
5. The method of claim 4, wherein the illumination model describes the color and intensity of light reflected from the object illuminated by the ith light source, the reflected light including specular, diffuse, and ambient components.
6. The method of claim 5, wherein the other terms of the illumination model include diffuse illumination terms and ambient terms.
7. The method of claim 6, wherein the specular illumination terms of the illumination model are expressed in the same functional form as the diffuse illumination terms of the illumination model.
8. The method of claim 1, wherein the algebraic expression is Smi,k(n,hi,n)=(1−n/k+max{n·(n/k hi), n/k−l})k, which describes the intensity of light reflected from a point on the object as measured by an observer, the object illuminated by light from an ith light source, where n is a unit vector normal to the object at the point of reflection, hi is a unit vector bisecting an angle subtended by a unit vector pointing towards the ith light source from the point of reflection and a unit vector pointing towards the observer from the point of reflection, n is a parameter that describes the shininess of the object, and k is a parameter that determines which derivatives of the algebraic expression are continuous.
9. The method of claim 8, wherein 2≦k≦n.
10. A machine-readable medium comprising instructions for causing the execution of a method for computing the intensity of specularly reflected light, the method comprising:
- representing the intensity of light reflected specularly from an object illuminated by a plurality of light sources by an algebraic expression;
- incorporating the algebraic expression into an illumination model for the illumination of the object, the model having specular illumination terms; and
- expressing the specular illumination terms of the illumination model in the same functional form as other terms of the illumination model.
11. The machine-readable medium of claim 10, wherein the algebraic expression does not include division or exponentiation operators.
12. The machine-readable medium of claim 10, wherein the plurality of light sources includes extended light sources and point light sources.
13. The machine-readable medium of claim 10, wherein the algebraic expression is Si(n,hi,n)=1−n+max{n·(nh1), n−1}, which describes the intensity of light reflected from a point on the object as measured by an observer, the object illuminated by light from an ith light source, where n is a unit vector normal to the object at the point of reflection, hi is a unit vector bisecting an angle subtended by a unit vector pointing towards the ith light source from the point of reflection and a unit vector pointing towards the observer from the point of reflection, and n is a parameter that describes the shininess of the object.
14. The machine-readable medium of claim 13, wherein the illumination model describes the color and intensity of light reflected from the object illuminated by the ith light source, the reflected light including specular, diffuse, and ambient components.
15. The machine-readable medium of claim 14, wherein the other terms of the illumination model include diffuse illumination terms and ambient terms.
16. The machine-readable medium of claim 15, wherein the specular illumination terms of the illumination model are expressed in the same functional form as the diffuse illumination terms of the illumination model.
17. The machine-readable medium of claim 10, wherein the algebraic expression is SMi,k(n,hi,n)=(l−n/k+max{n·(n/k hi), n/k−l})k, which describes the intensity of light reflected from a point on the object as measured by an observer, the object illuminated by light from an ith light source, where n is a unit vector normal to the object at the point of reflection, hi is a unit vector bisecting an angle subtended by a unit vector pointing towards the ith light source from the point of reflection and a unit vector pointing towards the observer from the point of reflection, n is a parameter that describes the shininess of the object, and k is a parameter that determines which derivatives of the algebraic expression are continuous.
18. The machine-readable medium of claim 17, wherein 2≦k≦n.
19. A system for computing the illumination of an object by a plurality of light sources, comprising:
- a memory configured to store game instructions and an illumination model;
- a processor configured to execute game instructions and generate rendering instructions;
- a vector processor configured to calculate color vectors using the illumination model, the illumination model having specular illumination terms and diffuse illumination terms expressed in the same functional form; and
- a graphics processor configured to render the illuminated object in an image using the color vectors according to the rendering instructions.
20. The system of claim 19, wherein for each light source i, an algebraic expression representing the intensity of light reflected specularly from a point on the object and detected by an observer is substituted into the illumination model yielding a specular illumination term for the light source i.
21. The system of claim 20, wherein the algebraic expression does not contain division or exponentiation operators.
22. The system of claim 20, wherein the algebraic expression for light source i is Si(n,hi,n)=l−n+max{n·(nhi), n−l}, where n is a unit vector normal to the object at the point of reflection, hi is a unit vector bisecting an angle subtended by a unit vector pointing towards light source i from the point of reflection and a unit vector pointing towards the observer from the point of reflection, and n is a parameter that describes the shininess of the object.
23. The system of claim 22, wherein the vector processor evaluates vector dot products for the diffuse and specular illumination terms in parallel.
24. The system of claim 20, wherein the algebraic expression for light source i is SMi,k(n,hi,n)=(l−n/k+max{n·(n/k hi), n/k−l})k, where k is a parameter that determines which derivatives of the algebraic expression are continuous, n is a unit vector normal to the object at the point of reflection, hi is a unit vector bisecting an angle subtended by a unit vector pointing towards light source i from the point of reflection and a unit vector pointing towards the observer from the point of reflection, and n is a parameter that describes the shininess of the object.
25. The system of claim 24, wherein 2≦k≦n.
26. The system of claim 25, wherein the vector processor evaluates vector dot products for the diffuse and specular illumination terms in parallel.
27. A method for computing the illumination of an object by a plurality of light sources, comprising:
- storing game instructions and an illumination model in a memory;
- executing game instructions and generating rendering instructions;
- representing color vectors with the illumination model, the illumination model having specular illumination terms and diffuse illumination terms expressed in the same functional form;
- calculating the color vectors by evaluating vector dot products for the specular and diffuse illumination terms in parallel; and
- rendering the object in an image using the color vectors according to the rendering instructions.
Type: Application
Filed: May 26, 2006
Publication Date: Sep 28, 2006
Applicant:
Inventor: Michael Day (Santa Monica, CA)
Application Number: 11/442,226
International Classification: G09G 5/02 (20060101);