A Parallel Algorithm for Polygon Rasterizaon

13
A Parallel Algorithm for Polygon Rasteriza4on Zhongchuan Zhang 10/29/2009

Transcript of A Parallel Algorithm for Polygon Rasterizaon

AParallelAlgorithmforPolygonRasteriza4on�

ZhongchuanZhang10/29/2009�

Introduc4on�

•  Fastrenderingof3DZ‐bufferedlinearlyinterpolatedpolygons– 3Dtransforma4on,projec4onandlightcalcula4onofthever4ces

•  ThispaperdealswithoneaspectofthelaKerproblem:thecomputa4onoftheboundariesofapolygon

Introduc4on�

•  Waystocomputetheedgesofpolygons– Computeedgesbyalineinterpola4onalgorithm•  Notsoconvenientforframebuffers

– Useaparallelmul4pliertreetosimultaneouslycomputealinearedgefunc4on•  Highlyparallel•  Requirededicatedlogicforeachpixel

– Usealinearfunc4ontodefinepolygonedgesandcanuseconven4onalDRAMandVRAMtechnology

Theedgefunc4on �•  Defini4onE(x,y)=(x‐X)dY‐(y‐Y)dXE(x,y)>0,if(x,y)istothe“right”sideE(x,y)>0,if(x,y)isexactlyonthelineE(x,y)>0,if(x,y)istothe“le`”side

•  Linear,canbecomputedincrementallyinthesamewayascolorandZvalues•  Convenientforrasteriza4onE(x+1,y)=E(x,y)+dYE(x,y+1)=E(x,y)‐dX

Theedgefunc4on �

•  Itcanbecomputedparallelforallpixelsintheframebuffer

•  Definepolygonsusingbooleancombina4onsofedges

•  Usedasa“stencil”thatallowsapixeltobemodifiedonlyifitisinteriortothepolygon�

Incrementalclassifica4onofpointsaroundaconvexpolygon�

•  Ver4ces(Xi,Yi)0<i<=N,(X0,Y0)=(XN,YN)•  Ini4aledgefuncitonatstar4ngpoint(Xs,Ys)dXi=Xi‐X[i‐1]dYi=Yi‐Y[i‐1]Ei(Xs,Ys)=(Xs‐Xi)dYi‐(Ys‐Yi)dXi

•  MakeincrementEi(x+1,y)=Ei(x,y)+dYiEi(x‐1,y)=Ei(x,y)‐dYiEi(x,y+1)=Ei(x,y)‐dXiEi(x,y‐1)=Ei(x,y)+dXi•  InteriortothepolygonEi>=0foralli:0<i<N(usinga4ebreakrule)

Traversingthepolygon�

Traversingtheboundingbox�

Amoreefficienttraversalalgorithm �

Traversalalgorithmmayhavetosearchforedge�

Proceedingoutwardfromcenterline�

Clipping �•  Viewle`andrightclippingasaddi4onalpolygonedges

•  Usetopclipboundarytocontrolthestar4ngpoint•  UseboKomclipboundarytocontrolthelastscanline �

Sub‐pixelaccuracyofver4ces�•  Ver4cesareinfloa4ngpointformata`er3Dtransforma4onandprojec4on

•  RoundingtheXandYfloa4ngpointordinatescanleavegaps

•  Performtheinterpolatorsetupcomputa4oninfloatpointandconverttofixedpointattheend

dXi=Xi‐X[i‐1]dYi=Yi‐Y[i‐1]Ei(Xs,Ys)=(Xs‐Xi)dYi‐(Ys‐Yi)dXidXi’=FIX(dXi)dYi’=FIX(dYi)Ei’=FIX(Ei)

Parallelimplementa4on�

•  Theedgefunc4onislinear,soE(x+L,y)=E(x)+Ldy

L‐distancefromagivepoint(x,y)

•  Allowsagroupofinterpolatorstosimultaneouslycomputetheedgefunc4onofanadjacentblock(Lpixelswide)inasinglecycle

Futureworkandextensions�

•  Computehigherorderedgefunc4onandcomputecomplexshapes

•  Performtheinterpola4onoftheedgefunc4oninafloatpointlikemanner

•  Usetheedgefunc4ontoan4‐aliasedges•  Havethelookuptableproduceacrudesub‐pixelresolu4onbitmapforeachedge �

Conclusion �

•  Canbecomputedinparallelandusedwithcommonrefreshbufferwordorganiza4on

•  CanbecomputedwithhardwaresimilartothatrequiredtointerpolatecolorandZvaluesfor3Dsolids

•  Maintainsthesub‐pixelaccuracyofver4ces�