quadratic interpolation in hardware renderingcg.iit.bme.hu/~szirmay/quat.pdfquadratic interpolation...

11
Quadratic Interpolation in Hardware Rendering Category: research Abstract Rendering systems often represent curved surfaces as a mesh of planar polygons that are shaded to add realism and to restore a smooth appearance. To increase the rendering speed, complex operations such as the solution of the ren- dering equation or texture transformation are executed just for a few knot points and the values at other points are in- terpolated. Usually linear transformation is used since it can be easily implemented in hardware. However, color distribution and texture transformation can be strongly non-linear for which linear interpolation may introduce se- vere artifacts. Thus this paper proposes quadratic interpo- lation to tackle this problem and demonstrates that it can be implemented in hardware. The software simulation and the VHDL description of the shading hardware are also presented. 1 Introduction Computer graphics aims at rendering complex virtual world models and presenting the image for the user. To obtain an image of a virtual world, surfaces visible in pix- els are determined, and the rendering equation or its sim- plified form is used to calculate the intensity of these sur- faces, defining the color values of the pixels. The render- ing equation, even in its simplified form, contains a lot of complex operations, including the computation of the vectors, their normalization and the evaluation of the out- put radiance, which makes the process rather resource de- manding. Real-time systems, however, allow just a few tens of nanoseconds for the computation of a single pixel, which results in a continuous driving force to develop faster graphics hardware [14, 20, 15, 8]. The speed of rendering could be significantly increased if it were possible to carry out the expensive computations just for a few points or pixels, and the rest could be inter- polated from these representative points by much simpler expressions. One way of obtaining this is the tessellation of the original surfaces to polygon meshes and using the vertices of the polygons as representative points. In this paper only triangle mesh models are considered. A simple interpolation scheme would compute the color at the ver- tices and linearly interpolate it inside the triangle (Gouraud shading [10]). However linear interpolation can introduce severe artifacts (left of figure 2). The core of the problem is that the color can be a strongly non-linear function of the pixel coordinates, especially if specular highlights oc- cur on the triangle, and this non-linear function can hardly be well approximated by a linear function (figure 1). Ambient Diffuse Specular Lightsource Eye Figure 1: Intensity of ambient, diffuse, and specular re- flections The artifacts of Gouraud shading can be eliminated by a non-linear interpolation called Phong shading [16] (right of figure 2). In Phong shading, vectors used by the render- ing equation are interpolated from the real vectors at the vertices of the approximating triangle. In simpler algo- rithms only the normal vectors are interpolated while the light and view vectors are constant. In more precise com- putations, the view and light vectors are also interpolated. The interpolated vectors are normalized and the rendering equation is evaluated at each pixel for diffuse and specular reflections and for each light source, which is rather time consuming. The main problem of Phong shading is that it requires complex operations on the pixel level, includ- ing interpolation and normalization of the normal, view- ing and the light vectors, calculation of their dot products, exponentiation if Phong reflection model is used, and mul- tiplications and additions. The hardware implementation is not feasible only if the number and type of lightsources are limited and the underlying formulae are simplified [2]. The superior rendering quality of Phong shading forced research to try to find a reasonable compromise between Gouraud and Phong algorithms, that keeps the image qual- ity but also allows for hardware implementation. In Tex- tronix terminals, for example, the method called pseudo- Phong shading was implemented. Pseudo-Phong shading recursively decomposes the triangles into small triangles setting the vectors at the vertices according to a linear formula, and uses Gouraud shading when the small tri- angles are rendered. If the sizes of the small triangles are comparable to the size of the pixels, then this corre- sponds to Phong shading. However, when they are close to the original triangle, this corresponds to Gouraud shad- ing. Unfortunately, the artifacts of Gouraud shading are visible even in highly tessellated surfaces (figure 11). An- other family of algorithms used highlight tests [22] to de-

Upload: others

Post on 02-Apr-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Quadratic Interpolation in Hardware Renderingcg.iit.bme.hu/~szirmay/quat.pdfQuadratic Interpolation in Hardware Rendering Category: research Abstract Rendering systems often represent

Quadratic Interpolation in Hardware RenderingCategory: research

Abstract

Rendering systems often represent curved surfaces as amesh of planar polygons that are shaded to add realism andto restore a smooth appearance. To increase the renderingspeed, complex operations such as the solution of the ren-dering equation or texture transformation are executed justfor a few knot points and the values at other points are in-terpolated. Usually linear transformation is used since itcan be easily implemented in hardware. However, colordistribution and texture transformation can be stronglynon-linear for which linear interpolation may introduce se-vere artifacts. Thus this paper proposes quadratic interpo-lation to tackle this problem and demonstrates that it canbe implemented in hardware. The software simulation andthe VHDL description of the shading hardware are alsopresented.

1 Introduction

Computer graphics aims at rendering complex virtualworld models and presenting the image for the user. Toobtain an image of a virtual world, surfaces visible in pix-els are determined, and the rendering equation or its sim-plified form is used to calculate the intensity of these sur-faces, defining the color values of the pixels. The render-ing equation, even in its simplified form, contains a lotof complex operations, including the computation of thevectors, their normalization and the evaluation of the out-put radiance, which makes the process rather resource de-manding. Real-time systems, however, allow just a fewtens of nanoseconds for the computation of a single pixel,which results in a continuous driving force to developfaster graphics hardware [14, 20, 15, 8].

The speed of rendering could be significantly increasedif it were possible to carry out the expensive computationsjust for a few points or pixels, and the rest could be inter-polated from these representative points by much simplerexpressions. One way of obtaining this is the tessellationof the original surfaces to polygon meshes and using thevertices of the polygons as representative points. In thispaper only triangle mesh models are considered. A simpleinterpolation scheme would compute the color at the ver-tices and linearly interpolate it inside the triangle (Gouraudshading [10]). However linear interpolation can introducesevere artifacts (left of figure 2). The core of the problemis that the color can be a strongly non-linear function ofthe pixel coordinates, especially if specular highlights oc-cur on the triangle, and this non-linear function can hardlybe well approximated by a linear function (figure 1).

Ambient

Diffuse

Specular LightsourceEye

Figure 1: Intensity of ambient, diffuse, and specular re-flections

The artifacts of Gouraud shading can be eliminated bya non-linear interpolation called Phong shading [16] (rightof figure 2). In Phong shading, vectors used by the render-ing equation are interpolated from the real vectors at thevertices of the approximating triangle. In simpler algo-rithms only the normal vectors are interpolated while thelight and view vectors are constant. In more precise com-putations, the view and light vectors are also interpolated.The interpolated vectors are normalized and the renderingequation is evaluated at each pixel for diffuse and specularreflections and for each light source, which is rather timeconsuming. The main problem of Phong shading is thatit requires complex operations on the pixel level, includ-ing interpolation and normalization of the normal, view-ing and the light vectors, calculation of their dot products,exponentiation if Phong reflection model is used, and mul-tiplications and additions. The hardware implementationis not feasible only if the number and type of lightsourcesare limited and the underlying formulae are simplified [2].

The superior rendering quality of Phong shading forcedresearch to try to find a reasonable compromise betweenGouraud and Phong algorithms, that keeps the image qual-ity but also allows for hardware implementation. In Tex-tronix terminals, for example, the method called pseudo-Phong shading was implemented. Pseudo-Phong shadingrecursively decomposes the triangles into small trianglessetting the vectors at the vertices according to a linearformula, and uses Gouraud shading when the small tri-angles are rendered. If the sizes of the small trianglesare comparable to the size of the pixels, then this corre-sponds to Phong shading. However, when they are closeto the original triangle, this corresponds to Gouraud shad-ing. Unfortunately, the artifacts of Gouraud shading arevisible even in highly tessellated surfaces (figure 11). An-other family of algorithms used highlight tests [22] to de-

Page 2: Quadratic Interpolation in Hardware Renderingcg.iit.bme.hu/~szirmay/quat.pdfQuadratic Interpolation in Hardware Rendering Category: research Abstract Rendering systems often represent

Figure 2: Comparison of linear (Gouraud) interpolation (left) and non-linear interpolation by Phong shading (right).

termine whether or not a specular highlight intersects thetriangle. If there is no intersection, then Gouraud shad-ing is used, otherwise the triangle is rendered with Phongshading. Duff [7] extended the incremental approach ofGouraud shading to Phong shading supposing only diffusereflection. He obtained the reflected radiance of a singlelight source as a direct function of the pixel coordinatesand evaluated this function using forward differences. Hisincremental formulae separately calculated the dot prod-uct of the normal and the light vector, and the length ofthe normal vector, thus a division and a square-root oper-ation were still needed for the evaluation of a single pixel.Based on this, Bishop proposed a simplification using Tay-lor’s approximation for both the diffuse and the Phong-Blinn reflection in [3]. The determination of the deriva-tives of the reflected radiance is quite complicated and re-quires expensive computation, and this computation mustbe repeated separately for diffuse and specular reflectionsand for each light source. Besides, according to the na-ture of Taylor’s series, the approximation is good aroundthe point where the derivatives were computed. Neighbor-ing triangles may have different color variation on theiredges, which leads to Mach banding over the edges of thetriangles. Claussen [5] compared different simplificationstrategies of the Phong illumination formulae and vectorinterpolation. Spherical interpolation elegantly traces backthe interpolation to the interpolation of a single angle in-side a scan-line [13]. However, finding the parametersof a scan-line is also rather complicated and the methodrequires the evaluation of the rendering equation at eachpixel and for each light source. The computational cost isalso proportional to the number of light sources. Reflec-tion shading [21, 12] tackles the problem of vector nor-

malization by finding a vector that is halfway between theinterpolated unnormalized vector and a given normalizedvector, and then the halfway vector is interpolated and thegiven vector is reflected on the halfway vector each time.Finally, Phong shading can also be replaced by texturing[4] in special cases.

Texture transform

Diffuselighting

Specularreflection

Texturememory

~~ Σ l * cos θ l

kd

Σ

u

v

X Y

Specular

DiffuseColor

1 lN,V,L . . . L vectorinterpolator

*

k s , n

l

Figure 3: Conventional rendering with Phong shading andtexture mapping without interpolation

Another non-linear problem arises in image order tex-ture mapping. For triangles, the screen coordinates andthe texture coordinates are connected by a homogeneouslinear transformation [19] thus for a pixelX;Y the corre-sponding texel coordinatesu;v can be obtained as

u=auX+buY+cu

duX+euY+ fu; v=

avX+bvY+cv

dvX+evY+ fv;

whereau; : : : fv depend on the positions of the triangle inthe texture and image spaces. Note that this operation alsocontains divisions that are quite intensive computationallyand makes the mapping non-linear. Implementing divi-

2

Page 3: Quadratic Interpolation in Hardware Renderingcg.iit.bme.hu/~szirmay/quat.pdfQuadratic Interpolation in Hardware Rendering Category: research Abstract Rendering systems often represent

Texture transformat the vertices

Diffuse lighting at the vertices

Specular reflectionat the vertices

Linear textureinterpolator

Linear diffuse lighting interpolator

Specular reflectioninterpolator

Texturememory

∼∼ Σ l * cos θ l

kd

Σ

u

v

X Y

Specular

DiffuseColor

*

l

Figure 4: Linear interpolation, i.e. Gouraud shading andlinear texture mapping

sion in hardware is difficult and can be the bottleneck oftexture mapping [1]. Approximating this function by a lin-ear transformation, on the other hand, makes the perspec-tive distortion incorrect [9, 17] (figure 12). Demirer [6]proposed a Chebishev polynomial approximation to avoiddivision.

Summarizing, the main problem of the original shad-ing pipeline used by Phong shading (figure 3) is that itinvolves complex operations such as lighting calculationsand texture transformations, which makes its direct hard-ware realization impossible. Traditionally, this problem isattacked by linear interpolation as shown in figure 4, butthe linear interpolation of the strongly non-linear functionsdegrades the image quality [18].

In this paper we propose a new interpolation scheme(figure 5) that uses appropriately selected quadratic func-tions which can be implemented in hardware and can beinitialized without the computational burden of the Tay-lor’s series approach. Unlike previous techniques the newmethod can simultaneously handle arbitrary number oflight sources and arbitrary BRDF models.

Texturetransform at 6 points

Diffuse lighting at3 or 6 points

Specularreflection at 6 points

Quadratic texture coordinate interpolator

Linear or quadraticdiffuse lighting interpolator

Quadratic specular reflection interpolator

Texturememory

∼∼ Σ l * cos θ l

kd

Σ

u

v

X Y

Specular

DiffuseColor

*

l

Figure 5: Quadratic rendering

2 Quadratic interpolation

Our approach is in between linear interpolation and bruteforce methods not using interpolation at all. The functionof interest, as for example the rendering equation or thetexture transformation, is evaluated in a few representativepoints and the interpolation is done in image space as inGouraud shading. However, the interpolation is not lin-ear, but rather quadratic. Since a quadratic form has sixdegrees of freedom, the function will be evaluated at sixrepresentative points on the triangle and it is interpolatedfrom the values at these representative points. Let us ap-proximate functionI inside the triangle by the followingtwo-variate quadratic form:

I(X;Y) = T5X2+T4XY+T3Y

2+T2X+T1Y+T0: (1)

To find the unknown parametersT0; : : : ;T5, the functionvalues are substituted into this scheme at six points, andthe six variate linear equation is solved for the parame-ters. The selection of these representative points shouldtake into account different criteria. The error should beroughly uniform inside the triangle but should be less onthe edges and on the vertices in order to avoid Mach band-ing. On the other hand, the resulting linear equation shouldbe easy to solve in order to save computation time. Anappropriate selection meeting both requirements uses thethree vertices:

I(X1;Y1) = I1; I(X2;Y2) = I2; I(X3;Y3) = I3;

and other three points on the edges half way between thetwo vertices, as follows:

I(X1+X2

2;Y1+Y2

2) = I12;

I(X1+X3

2;Y1+Y3

2) = I13;

I(X2+X3

2;Y2+Y3

2) = I23:

Translating the triangle to have its bottom vertex at thecoordinate origin yields:

I1 = T0;

I2 = T5X22 +T4X2Y2+T3Y

22 +T2X2+T1Y2+T0;

I12 = T5X2

2

4+T4

X2Y2

4+T3

Y22

4+T2

X2

2+T1

Y2

2+T0;

I3 = T5X23 +T4X3Y3+T3Y

23 +T2X3+T1Y3+T0;

I13 = T5X2

3

4+T4

X3Y3

4+T3

Y23

4+T2

X3

2+T1

Y3

2+T0;

I23 = T5(X2+X3)

2

4+T4

X2+X3

2�Y2+Y3

2+

+ T3(Y2+Y3)

2

4+T2

X2+X3

2+T1

Y2+Y3

2+T0:

3

Page 4: Quadratic Interpolation in Hardware Renderingcg.iit.bme.hu/~szirmay/quat.pdfQuadratic Interpolation in Hardware Rendering Category: research Abstract Rendering systems often represent

This system of linear equations can be solved in a straight-forward way resulting in:

T0 = I1;

T1 =C3X2�C2X3

X2Y3�Y2X3;

T2 =C2Y3�C3Y2

X2Y3�Y2X3;

T3 =2C12�T5X2

2 �T4X2Y2

Y22

;

T4 =(4C13Y2�C23Y3)D23� (4C12Y3�C23Y2)D32

E32D23�E32D32;

T5 =(4C12Y3�C23Y2)E32� (4C13Y2�C23Y3)E23

E32D23�E32D32;

where

C2 = 4I12�3I1� I2;

C12 = I1+ I2�2I12;

C3 = 4I13�3I1� I3;

C13 = I1+ I3�2I13;

C23 = 4I1�4I12�4I13+4I23;

D23 = 2X22Y3�2X2Y2X3;

D32 = 2Y2X23 �2X2X3Y3;

E23 = X2Y2Y3�Y22 X3;

E32 = Y2X3Y3�X2Y23 :

The calculation ofT0; : : : ;T5 parameters requires 25 ad-ditions, 51 multiplications, and 5 divisions. Having de-termined theT0; : : : ;T5 values, if I(X;Y) is needed, thenX andY are substituted into equation (1). This quadraticform will be evaluated by simple additions according tothe incremental concept.

3 Error control

The method proposed in the previous section approxi-mates a non-linear function by a quadratic formula. Thisfunction is either the radiance or the texture address in ourcase. If the triangles are too big and the radiance or thetexture address change quickly due to a highlight or to theexpansion of the texture transformation, then this approx-imation can still be inaccurate. In order to avoid this prob-lem, the accuracy of the approximation is estimated, andif it exceeds a certain threshold, then the triangle is adap-tively subdivided into 4 triangles by halving the edges.

Recall that the knot points of the interpolation are thevertices and the middle points of the edges. Thus a reason-able point where the error can be measured is the center ofthe triangle. This leads to the following highlight test al-gorithm. Having computed theT0; : : : ;T5 parameters, thefunction value is estimated at the center of the triangle us-ing equation (1), and the result is compared with the realvalue ofI(X;Y). In case of big difference, adaptive sub-division takes place. Note that the overhead of one more

Test point

Difference of thetest pairs is small

Difference of the test pairs is big

X1,Y1

X2,Y2

X3,Y3

X1+X2

X2+X32 2

2 2

2 2

X1+X3

, Y2+Y3

Y1+Y2,

Y1+Y3,

Figure 6: Highlight test and adaptive subdivision

function evaluation is affordable and during subdivisionthe already computed function values can be reused.

4 Hardware implementation ofthe quadratic interpolation

This section reviews the implementation strategies of sim-ple functions on scan-lines that are used to fill horizontalsided image space triangles. If the image space triangleis not formed as horizontal sided triangle, then it shouldbe divided into two parts, a lower and an upper. In thissection we will consider only the lower horizontal sidedtriangle. Image space triangle and horizontal sided trian-gle are shown in figure 7.

Image space triangle

x

y

Single scan-line

Single pixel

X1,Y1

X2,Y2

X3,Y3

Horizontal sided triangle (lower part)

y

xX1,Y1

X2,Y2

Horizontal sided triangle (upper part)

Figure 7: Image space and horizontal sided triangles

If we implemented equation (1) directly, the hardwareshould compute floating point multiplications and addi-tions for each value, which are rather demanding. To elim-inate the multiplications, the incremental concept is used,which traces back the evaluation of the functionI(X;Y)to the computation of an increment from the previous val-ues, for instance, fromI(X� 1;Y). The increments canthen be evaluated by simple additions. A triangle fillingalgorithm should generate the sequence of(X;Y) integervalues called pixels that are inside a horizontal sided trian-gle. The algorithm generates the pixels scan-line by scan-line. In a single scan-line theY coordinate is constant. Tosimplify equation (1), we use the incremental concept for

4

Page 5: Quadratic Interpolation in Hardware Renderingcg.iit.bme.hu/~szirmay/quat.pdfQuadratic Interpolation in Hardware Rendering Category: research Abstract Rendering systems often represent

the scan-lines and for their start edges. First, the quadraticfunction is reduced to a linear one for the scan-lines:

I(X+1;Y) = I(X;Y)+∆I(X;Y)

where∆I(X;Y) = 2T5X+T4Y+T5+T2: (2)

Then we apply the incremental concept once more forthe linear function∆I(X;Y) to obtain the incrementalvalue inside the scan-line:

∆I(X+1;Y) = ∆I(X;Y)+2T5:

When we step onto the next scan-line,Y is incremented,and the startXstart and the endXend coordinates should bedetermined by the following equations:

Xstart(Y) =Y�Y1

Y2�Y1� (X2�X1)+X1;

Xend(Y) =Y�Y1

Y3�Y1� (X3�X1)+X1:

SinceXstart(Y) andXend(Y) are linear functions, they canbe simplified by applying the incremental concept:

Xstart(Y+1) = Xstart(Y)+Astart;

Xend(Y+1) = Xend(Y)+Aend;

where

Astart =X2�X1

Y2�Y1; Aend=

X3�X1

Y3�Y1:

Now let us discuss the computation on the start edge.When the algorithm steps onto the next scan-line, bothI(X;Y) and∆I(X;Y) should be recomputed with the dataof the new scan-line. The incremental concept can also beused for these computations, which traces back these up-dates to two additions. The first application of the incre-mental concept reduces the computation of the quadraticfunctionI(X;Y) to a linear one:

I(X+Astart;Y+1) = I(X;Y)+∆Istart(X;Y)

where

∆Istart(X;Y) = T5A2start+(2T5X+T4Y+T4+T2)Astart

+ T4X+2T3Y+T3+T1:

Applying the incremental concept once more for the linearfunction∆Istart(X;Y), we obtain a constant addition:

∆Istart(X+Astart;Y+1) =

∆Istart(X;Y)+2(T5A2start+T4Astart+T3):

To obtain the incremental value∆I(X;Y) at the start edge,we should apply the incremental concept only once sinceit is already a linear function (equation (2)):

∆I(X+Astart;Y+1) = ∆I(X;Y)+2T5Astart+T4:

Let us group these formulae in the following algorithm:

Xstart = X1, Xend = X1

ComputeIstart(X;Y), ∆Istart(X;Y), ∆I(Xstart;Y) at X1;Y1

for Y = Y1 to Y2 doI(X;Y) = Istart(X;Y)∆I(X;Y) = ∆I(Xstart;Y)for X = Xstart to Xend do

write ( X, Y, I(X;Y) )I(X;Y) += ∆I(X;Y)∆I(X;Y) += 2T5

endfor∆I(Xstart;Y) += 2T5Astart+T4

Istart(X;Y) += ∆Istart(X;Y)∆Istart(X;Y) += 2(T5A2

start+T4Astart+T3)

Xstart += Astart, Xend += Aend

endfor

Note that functionI and the parameters are not integers,and if we ignored the fractional part, the incremental for-mula would accumulate the error to an unacceptable level.The realization of floating point arithmetic is not at all sim-ple. Non-integers, fortunately, can also be represented infixed point form where the lowbI bits of the code wordrepresent the fractional part. The number of bits in thefractional part has to be set to avoid incorrectI calculationsdue to the cumulative error inI . In order to obtainI(X;Y)for someX;Y pixel,MY �max(Y2�Y1) iteration steps areexecuted on the start edge andMX �max(X3�X2) stepson the horizontal span. A single iteration step involves thecalculation of increments∆I or ∆Istart as an addition witha constant, then the increase ofI or Istart by the currentincrement values. The maximum error introduced by anaddition with a constant is 2�bI , thus aftermsteps, the cu-mulative error of the increment is less thanm�2�bI . Con-sequently, the cumulative error in valuesI andIstart afterM steps is less than

M

∑m=1

m�2�bI =M(M�1) �2�(bI+1):

Incorrect calculations ofI is avoided if the cumulative er-ror is less one. Since a single value requires at mostMY

steps on the start edge andMX steps on the span, we ob-tain:

(MX(MX�1)+MY(MY�1)) �2�(bI+1)< 1=)

bI > log(MX(MX�1)+MY(MY�1))�1:

If the display has 1280� 1024 resolution, this results inthe requirement of 22 fractional bits.

The hardware implementation is shown in figure 8. Theregisters usually have two data inputsL andS. L is theinput to the register when theload signal is active, andSis the input to the register for each clock. The clock signalof the subsystem responsible for the internal pixels of thescan-lines is the system clock. However, the clock signalcontrolling the elements that compute the interpolation atthe start edge is the output of the comparator detecting theend of the scan-line.

5

Page 6: Quadratic Interpolation in Hardware Renderingcg.iit.bme.hu/~szirmay/quat.pdfQuadratic Interpolation in Hardware Rendering Category: research Abstract Rendering systems often represent

2T

I(X,Y)

I start

∆ I (X,Y)

Σ

Σ

Σ

Σ

Register

Register

start2

start

counter

X

CLK

XX

comp.

>

<

comp.

counter

Y1

STOP

Y

<

Y2

>

>

>

>

<

start

end

Register

X

X

Y

Y

2(T A5 4 3

T TA+ + )

5

(X,Y)

start

Register

Register

Σ

>

2T5

A start +T4

∆ I ,Y)

I(X,Y)

(X start

L S

S L

load

load

Figure 8: Hardware implementation of two-variate quadratic functions

Figure 9: Timing diagram of the hardware generated by the VHDL simulator

6

Page 7: Quadratic Interpolation in Hardware Renderingcg.iit.bme.hu/~szirmay/quat.pdfQuadratic Interpolation in Hardware Rendering Category: research Abstract Rendering systems often represent

5 Simulation results

The proposed algorithm has been implemented first in Mi-crosoft Visual C++ and tested as a software. In figures10 and 11, spheres tessellated on different levels are com-pared. Gouraud shading evaluates the rendering equationfor every vertex, quadratic shading for every vertex andedge centers and Phong shading for each pixel. The dif-ference of the algorithms is significant when the tessella-tion is not very high. The measured times of drawing ofthe coarsely tessellated spheres are as follows: Gouraudshading 230 msec, quadratic shading 250 msec, and Phongshading 450 msec. Note that Gouraud shading performspoorly on coarsely tessellated surfaces, but the visual qual-ity of quadratic shading and Phong shading is similar. Onthe other hand, concerning the speed and the suitabilityfor hardware implementation, quadratic shading is closeto Gouraud shading. Figure 13 shows a more complexscene with normal tessellation level. Looking at these im-ages we can conclude that quadratic shading is visuallysuperior to Gouraud shading and indistinguishable fromclassical Phong shading.

In order to compare the quality of linear and quadraticapproximation of texture transformation a tiger and a tur-tle texture were assigned to a rectangle divided into twotriangles (figure 12). Note that linear transformation dis-torts the textures in an unacceptable way, while quadraticapproximation handles the perspective shrinking properly.

Having tested the software implementation, the hard-ware realization was specified in VHDL and simulated inModelTech environment. The timing diagram of the algo-rithm is shown by figure 9. The delay times are accordingto XILINX XCV300-6 FPGA. In this figure we can followthe operation of the hardware. The hardware can generateone pixel per one clock cycle. The length of the clock cy-cle — which is also the pixel drawing time — depends onFPGA devices and on the screen memory access time. Forthe mentioned device it can be less than 50 nsec. While thehardware draws the actual triangle, the software can com-pute the initial values for the next triangle, so initializationand triangle drawing are executed parallely.

6 Conclusions

This paper proposed a new rendering strategy where thecolor and the texture coordinates are evaluated by the ren-dering equation at six representative points, three on thevertices and the other three halfway between the vertices,then they are interpolated inside the triangle according toa quadratic scheme. The algorithm has also been trans-formed to a hardware design that has been simulated inVHDL demonstrating that 50 nsec pixel drawing time canbe obtained. Even if the screen has about 1000�1000 res-olution, the complete image can be redrawn 16 times persecond which provides the illusion of continuous motion.

Figure 10: Rendering coarsely tessellated spheres (168 tri-angles) of specular exponentsn= 5 (top) andn= 50 (bot-tom) with Gouraud shading (left), quadratic shading (mid-dle) and Phong shading (right)

Figure 11: Rendering highly tessellated spheres (690 tri-angles) of specular exponentsn= 5 (top) andn= 50 (bot-tom) with Gouraud shading (left), quadratic shading (mid-dle) and Phong shading (right)

7

Page 8: Quadratic Interpolation in Hardware Renderingcg.iit.bme.hu/~szirmay/quat.pdfQuadratic Interpolation in Hardware Rendering Category: research Abstract Rendering systems often represent

Figure 12: Texture mapping with linear (left), quadratic (right) texture transformation

Figure 13: The mesh of a chicken (left) and its image rendered by classical Phong shading (middle) and by quadraticshading (right)

8

Page 9: Quadratic Interpolation in Hardware Renderingcg.iit.bme.hu/~szirmay/quat.pdfQuadratic Interpolation in Hardware Rendering Category: research Abstract Rendering systems often represent

Figure 14: Coarsly tessellated textured and specular tiger with Gouraud (left) Phong (middle) and quadratic (right) shading

Figure 15: A pawn with Gouraud, Phong and Quadratic shading

Figure 16: An apple with Gouraud, Phong and Quadratic shading

9

Page 10: Quadratic Interpolation in Hardware Renderingcg.iit.bme.hu/~szirmay/quat.pdfQuadratic Interpolation in Hardware Rendering Category: research Abstract Rendering systems often represent

References

[1] H. Ackermann. Single chip hardware support forrasterization and texture mapping.Computers andGraphics, 20(4):503–514, 1996.

[2] K. Bennebroek, I. Ernst, H. R¨usseler, and O. Wit-ting. Design principles of hardware-based Phongshading and bump-mapping.Computers and Graph-ics, 21(2):143–149, 1997.

[3] G. Bishop and D.M. Weimar. Fast Phong shading.Computer Graphics, 20(4):103–106, 1986.

[4] D. Blythe, B. Grantham, M Kilgard, T. McReynolds,S. Nelson, C. Fowler, S. Hui, and P. Womack.Advanced graphics programming techniques usingOpenGL: Course notes. Technical report, SIG-GRAPH’99, 1999.

[5] U. Claussen. On reducing the Phong shadingmethod.Computer & Graphics, pages 73–81, 1990.

[6] D. Demirer and R. Grimsdale. Approximation tech-niques for high performance texture mapping.Com-puters and Graphics, 20(4):483–490, 1996.

[7] T. Duff. Smoothly shaded rendering of polyhedralobjects on raster displays. InComputer Graphics(SIGGRAPH ’79 Proceedings), 1979.

[8] M. Eldridge, H. Igehy, and P. Hanrahan.Pomegranate: A fully scalable graphics archi-tecture. InSIGGRAPH’00, 2000.

[9] M. Gangnet, P. Perny, and P. Coueignoux. Perspec-tive mapping of planar textures. InEUROGRAPH-ICS ’82, pages 57–71, 1982.

[10] H. Gouraud. Computer display of curved surfaces.ACM Transactions on Computers, C-20(6):623–629,1971.

[11] P. Haeberli and M. Segal. Texture mapping asa fundamental drawing primitive. Technical re-port, Silicon Graphics, Inc., 1993. http://www-europe.sgi.com/grafica/texmap/.

[12] A. Hast, T. Barrera, and E. Bengtsson. Improvedshading performance by avoiding vector normaliza-tion. In Winter School of Computer Graphics ’01,pages 1–8, 2001. Short paper.

[13] A. M. Kuijk and E. H. Blake. Faster Phong shadingvia angular interpolation.Computer Graphics Fo-rum, pages 315–324, 1989.

[14] S. Molnar, J. Eyles, and J. Poulton. PixelFlow: High-speed rendering using image composition. InSIG-GRAPH’92, pages 231–240, 1992.

[15] J. Montrym, D. Baum, D. Digman, and C. Migdal.InfiniteReality: A real-time graphics system. InSIG-GRAPH’97, pages 293–302, 1997.

[16] B. T. Phong. Illumination for computer generatedimages.Communications of the ACM, 18:311–317,1975.

[17] M. Samek, C. Slean, and H. Weghorst. Texture map-ping and distortion in digital graphics.Visual Com-puter, 3:313–320, 1986.

[18] M. Segal, K. Akeley, C. Frazier, and J. Leech. TheOpenGL graphics system: A specification (version1.2.1). Technical report, Silicon Graphics, Inc.,1999.

[19] L. Szirmay-Kalos (editor).Theory of Three Dimen-sional Computer Graphics. Akademia Kiado, Bu-dapest, 1995. http://www.iit.bme.hu/˜szirmay.

[20] J. Torborg and J. Kajiya. Talisman: Commodity real-time 3D graphics for the PC. InSIGGRAPH’96,pages 353–364, 1996.

[21] D. Voorhies and J. Foran. Reflection vector shadinghardware. InComputer Graphics (SIGGRAPH ’94Proceedings), pages 163–166, 1994.

[22] A. Watt. Fundamentals of Three-dimensional Com-puter Graphics. Addision-Wesley, 1989.

10

Page 11: Quadratic Interpolation in Hardware Renderingcg.iit.bme.hu/~szirmay/quat.pdfQuadratic Interpolation in Hardware Rendering Category: research Abstract Rendering systems often represent

Quadratic Interpolation in Hardware Rendering

Ali Mohamed Abbas, L´aszlo Szirmay-Kalos, G´abor Szijarto, Tamas Horvath and Tibor F´orisDepartment of Control Engineering and Information Technology, Technical University of Budapest

Budapest, P´azmany P. s. 1/D, H-1117, [email protected]

Category: research

Format: print

Contact: Laszlo Szirmay-KalosDepartment of Control Engineering and Information Technology,Technical University of BudapestBudapest, P´azmany P. s. 1/D, H-1117, HUNGARY

phone: (361) 463–2030fax: (361) 463–2204email: [email protected]

Estimated # of pages: 8

Keywords: Phong shading, texture mapping, interpolation, computer graphics hardware

Rendering systems often represent curved surfaces as a mesh of planar polygons that areshaded to add realism and to restore a smooth appearance. To increase the rendering speed,complex operations such as the solution of the rendering equation or texture transformationare executed just for a few knot points and the values at other points are interpolated. Usu-ally linear transformation is used since it can be easily implemented in hardware. However,color distribution and texture transformation can be strongly non-linear for which linear in-terpolation may introduce severe artifacts. Thus this paper proposes quadratic interpolationto tackle this problem and demonstrates that it can be implemented in hardware. The soft-ware simulation and the VHDL description of the shading hardware are also presented.