Graphics adapter capable of supporting lighting models from multiple application programming interfaces within a graphics system6389485Abstract A graphics adapter capable of supporting lighting models from multiple Application Programming, Interfaces (APIs) within a graphics system is disclosed. The graphics adapter includes a dot product machine and a control means. The dot product machine can perform geometry computations regardless of the API format in which the graphics data is expressed. The control means is utilized to multiplex between a set of graphics data having a first API format and a set of graphics data having a second API format in order to determine the inputs of the dot product machine. As a result, lighting models from multiple APIs can be supported by a single graphics adapter. Claims What is claimed is: Description BACKGROUND OF THE INVENTION
+ component-wise addition of red, green, and blue channels;
.times. component-wise multiplication of red, green, and blue
channels;
.multidot. dot product operation clamped at zero;
Matl.sub.emis emissive color of material;
Matl.sub.amb ambient color of material;
Matl.sub.diff diffuse color of material;
Matl.sub.spec specular color of material;
Model.sub.amb ambient model color or ambient color of scene;
L.sub.amb (i) ambient intensity of light source number i;
L.sub.diff (i) diffuse intensity of light source number i;
L.sub.spec (i) specular intensity of light source number i;
N surface normal vector at vertex (normalized);
L (i) vector pointing from vertex to light source i (normalized);
H (i) half vector corresponding to light source i (normalized) where
the non-normalized H (i) = L (i) + (0, 0, 1) for a
viewer at (0, 0, .infin.);
se specular exponent;
att.sub.i attenuation factor;
spot.sub.i spotlight effect;
f.sub.i equals 1.0 when N .multidot. L > 0 and
equals 0.0 otherwise.
On the other hand, the general form of PHIGS lighting equation is as follows: ##EQU2## where
+ component-wise addition of red, green, and blue channels;
.times. component-wise multiplication of red, green, and blue channels;
.multidot. dot product operation clamped at zero;
a.sub.c ambient reflection coefficient of the surface;
d.sub.c diffuse reflection coefficient of the surface;
s.sub.c specular reflection coefficient of the surface;
D.sub.s diffuse color component of the surface;
S.sub.s specular color component of the surface;
L.sub.amb (i) ambient intensity of light source number i;
L.sub.diff (i) diffuse intensity of light source number i;
L.sub.spec (i) specular intensity of light source number i;
N surface normal vector at vertex (normalized);
L (i) vector pointing from vertex to light source i (normalized);
E vector pointing from vertex to viewer (normalized);
R (i) reflection vector corresponding to light source i (normalized)
where the angle of reflection between N and R = the angle
of incidence between L and N;
se specular exponent;
att.sub.i attenuation factor;
spot.sub.i spotlight effect;
f.sub.i equals 1.0 when N .multidot. L > 0 and equals 0.0 otherwise.
For an infinite viewpoint and directional light sources, OpenGL lighting equation (1) becomes: ##EQU3## and PHIGS lighting equation (2) becomes: ##EQU4## Despite the apparent differences between OpenGL lighting equation (3) and PHIGS lighting equation (4), these two lighting equations can be made to look comparable to each other such that a single hardware structure, such as a dot product machine, can be utilized within a graphics adapter for color computations, regardless of which Application Programming Interface (API) is being utilized. This is accomplished by first having PHIGS host software send values of zero for parameters Matl.sub.emis, and Model.sub.amb. Also, the (a.sub.c.times.D.sub.s), (d.sub.c.times.D.sub.s), and (S.sub.c.times.S.sub.s) products in PHIGS lighting equation (4) can be pre-computed by the PHIGS host software and the results sent to the graphics adapter as Matl.sub.amb, Matl.sub.diff and Matl.sub.spec, respectively. Accordingly, PHIGS equation (4) becomes: ##EQU5## At this point, PHIGS lighting equation (5) has an almost identical structure as OpenGL lighting equation (3). One difference is that PHIGS lighting equation (5) requires an evaluation of a dot product E.multidot.R while OpenGL lighting equation (3) requires an evaluation of a dot product N.multidot.H. Referring now to the drawings and specifically to FIG. 1, there is illustrated a vector diagram of several relevant light vectors on a surface of an object. The reflection vector, R, is not readily available because it is not provided by the graphics software application. Thus, a dot product E.multidot.R can be manipulated as follows. From vector addition, R+L=[.vertline.R.vertline.Cos .theta.+.vertline.L.vertline.COS .theta.]N Because both vectors R and L are normalized (i.e., .vertline.R.vertline.=.vertline.L.vertline.=1), thus R+L=[Cos .theta.+Cos .theta.]N R=2 Cos .theta.N-L Because N.multidot.L=.vertline.N.vertline..vertline.L.vertline. Cos .theta.,and .vertline.N.vertline.=.vertline.L.vertline.=1, thus Cos .theta.=N.multidot.L R=2(N.multidot.L)N-L and Hence, E.multidot.R=E.multidot.[2(N.multidot.L)N-L] E.multidot.R=2(N.multidot.L)(N.multidot.E)-(E.multidot.L) (6) Now the calculation of dot product E.multidot.R is only dependent upon vectors N, L, and E, which are readily available. Accordingly, equation (6) can be rewritten as: E.multidot.R=(N.multidot.L)(N.multidot.E)+(N.multidot.L)(N.multidot.E)+(-E. multidot.L) (7) For an infinite viewpoint, vector E is a constant across all vertices, and for infinite light sources, vector L is a constant across all vertices. Therefore dot product E.multidot.L is a constant for each light source, and dot product E.multidot.L can be pre-computed by the host graphics software and sent to the graphics adapter as a constant K=-(E.multidot.L). Accordingly, equation (7) becomes: E.multidot.R=(N.multidot.L)(N.multidot.E)+(N.multidot.L)(N.multidot.E)+K (8) Finally, equation (8) can be rewritten in the form of: E.multidot.R=(N.multidot.L)(N.multidot.E)+(N.multidot.L)(N.multidot.E)+K(1. 0) (9) The dot products in OpenGL lighting equation (3) may be computed in two cycles, having N.multidot.L computed in the first cycle, N.multidot.H computed in the second cycle. With equation (9), the dot products in PHIGS lighting equation (5) may be computed in three cycles, having N.multidot.L computed in the first cycle, N.multidot.E computed in the second cycle, and equation (9) computed in the third cycle. In the third cycle, quantities (N.multidot.L), (N.multidot.E), K, and 1.0 are sent to respective inputs of a dot product machine within a single graphics adapter, as will be illustrated infra. With reference now to FIG. 2, there is illustrated a block diagram of a graphics system in which a preferred embodiment of the present invention may be incorporated. As shown, a 3-D graphics system 20 includes an input device 21, a processor 22, a graphics adapter 23, and a display 24. Input device 21 may be a keyboard, a memory, a peripheral storage device, or a communications port. Input device 21 communicates data with processor 22. Processor 22 may be implemented with a graphics processor or a math co-processor as is well known in the art. Coupled to processor 22, graphics adapter 23 provides the display of 3-D graphics scenes via display 24. Referring now to FIG. 3, there is illustrated a functional block diagram of graphics adapter 23, in accordance with a preferred embodiment of the present invention. Graphics adapter 23 may include a Bus Interface unit 31, a Lighting unit 32, a Setup/area unit 33, a Blit/Data steering unit 34, a Pixel operations unit 35, a Stack unit 36, a Setup/Partials unit 37, a Render unit 38, an Interpolator unit 39, a Blit/Scissor unit 61, a Texture unit 62, a Blending unit 63, a Special Operations unit 64, a Frame Buffer Interface unit 65, and a Graphics frame buffer 66, that sequentially receive and process graphics data. Except for Lighting unit 32, each of the above-mentioned functional units possesses a structure and performs a function that is known to those skilled in the relevant art. With reference now to FIG. 4, there is illustrated a block diagram of a dot product machine within lighting unit 32 for supporting lighting models from multiple APIs, in accordance with a preferred embodiment of the present invention. As shown, dot product machine 40 includes multiplexors 41-46, multipliers 47-49, an adder 50, and latches 51, 52. Each of multiplexors 41-46 has three inputs. In FIG. 4, each circled input number shown on each of multiplexors 41-46 denotes a respective cycle input. For example, circled input number 1 on multiplexors 41, 43, and 45 represents the fact that vector N will be latched in at multiplexors 41, 43, and 45 in cycle 1. The format of a set of incoming graphics data (i.e. OpenGL format or PHIGS format) can be provided to dot product machine 40 via control 53. For example, a logical "1" in control 53 signifies the set of incoming graphics data is in the OpenGL format while a logical "0" in control 53 signifies the set of incoming graphics data is in the PHIGS format. As mentioned previously, dot products N.multidot.L and N.multidot.H within OpenGL lighting equation (3) may be computed in two cycles. Vectors N and L are initially sent to the cycle 1 inputs of multiplexors 41, 43, 45 and multiplexors 42, 44, 46, respectively. In the first cycle, dot product N.multidot.L is computed by multiplying vectors N and L within multipliers 47-49 and adding the products from multipliers 47-49 within adder 50. In the meantime, vectors N and H are sent to the cycle 2 inputs of multiplexors 41, 43, 45 and multiplexors 42, 44, 46, respectively. Thus, in the second cycle, dot product N.multidot.H can be computed by multiplying vectors N and H within multipliers 47-49 and adding the products from multipliers 47-49 within adder 50. The results of dot products N.multidot.L and N.multidot.H can be obtained from adder 50 after cycle 1 and cycle 2, respectively. Notice that the cycle 3 inputs of multiplexors 42, 44, and 46 are not utilized for calculating OpenGL lighting equation (3). With dot product machine 40, dot product E.multidot.R within PHIGS lighting equation (5) may be computed in three cycles. This is accomplished by computing dot product N.multidot.L in the first cycle, computing dot product N.multidot.E in the second cycle, and computing dot product E.multidot.R (as outlined in equation (9)) in the third cycle. Vectors N and L are initially sent to the cycle 1 inputs of multiplexors 41, 43, 45 and multiplexors 42, 44, 46, respectively. In the first cycle, dot product N.multidot.L is computed by multiplying vectors N and L within multipliers 47-49 and adding the products from multipliers 47-49 within adder 50. In the meantime, vectors N and E are sent to the cycle 2 inputs of multiplexors 41, 43, 45 and multiplexors 42, 44, 46, respectively. Thus, in the second cycle, dot product N.multidot.E can be computed by multiplying vectors N and E within multipliers 47-49 and adding the products from multipliers 47-49 within adder 50. In the meantime, results of dot product N.multidot.E from cycle 2 are sent to the inputs of multiplexors 41 and 43 and constant K is sent to the input of multiplexor 45, while results of dot product N.multidot.L from cycle 1 are sent to the inputs of multiplexors 42 and 44 and constant 1.0 is sent to the input of multiplexor 46. The result of dot product N.multidot.L is available at this point from latch 52 while the result of dot product N.multidot.E is available at this point from latch 51. Thus, in the third cycle, dot product E.multidot.R is computed by multiplying the dot product results according to equation (9) within multipliers 47-49 and adding the products from multipliers 47-49 within adder 50. The results of dot product E.multidot.R can be obtained from adder 50 after cycle 3. Hence, a single dot product machine 40 can be utilized to perform color computations, regardless of the API format in which the graphics data is being utilized. As has been described, the present invention provides a graphics adapter for supporting lighting models from multiple APIs within a graphics system. With the present invention, the computation of the OpenGL and PHIGS lighting equations can be integrated into a single graphics adapter. The ability to compute lighting for graphics data having two API formats within a single dot product machine reduces the hardware resources normally required. Although OpenGL and PHIGS lighting equations are utilized to illustrate a preferred embodiment of the present invention, it is understood by those skilled in the art that the principle as disclosed may also to applicable to other APIs. While the invention has been particularly shown and described with reference to a preferred embodiment, it will be understood by those skilled in the art that various changes in form and detail may be made therein without departing from the spirit and scope of the invention.
|
Same subclass Same class Consider this |
||||||||||
