Chap 4 Usage of a Renderer.


101 views
Uploaded on:
Category: Medical / Health
Description
Chap 4 Usage of a Renderer. Chap 8 of Heavenly attendant " s book (second ed.) Four noteworthy assignments Line-portion cutting 3D cutting Output change Sweep transformation of polygons Polygon cutting Cut-out of different primitives Shrouded surface evacuation. Four noteworthy assignments of a renderer. Displaying
Transcripts
Slide 1

Chap 4 Implementation of a Renderer Chap 8 of Angel ’ s book (second ed.) Four noteworthy assignments Line-fragment cutting 3D cut-out Scan transformation Scan change of polygons Polygon section Clipping of different primitives Hidden surface evacuation 1

Slide 2

Four noteworthy errands of a renderer Modeling Geometric handling Viewing pipeline Clipping Line portion Polygon Hidden surface evacuation Rasterization (check change) Shading and Display 2

Slide 3

Line-section cut-out Line-rectangle cutting Brute-power methodology (Find the line-edge convergence and clasp) Requires gliding point increase and division. Cohen-Sutherland cut-out Requires just gliding point subtractions and bit operations. 3

Slide 4

Cohen-Sutherland cutting - 1 Extend the window ’ s sides to interminability and separation space into 9 areas. Every locale is relegated a 4-bit paired outcode, b 0 b 1 b 2 b 3 , as takes after. 4

Slide 5

Cohen-Sutherland cutting - 2 Test for unimportantly acknowledged (two endpoints are inside the rectangle) Test for insignificantly dismisses (two endpoints are in the same half-space of a cut-out edge) If the line portion can be neither inconsequentially acknowledged or rejected, it is subdivided into two fragments at a clasp edge with the goal that one section can be insignificantly dismisses. 5

Slide 6

Cohen-Sutherland cutting - 3 For a line section with outcodes o 1 and o 2 (oblige 8 subtractions for each line portion) o 1 =o 2 =0 Entire line fragment is inside the window. Ex. Stomach muscle o1<>0, o2=0 or o1=0, o2<>0 One is inside and one is outside Subdivide the line fragment by edge or edges demonstrated by the nonzero outcode. Ex. Compact disc 6

Slide 7

Cohen-Sutherland cutting - 4 o 1 & o 2 <> 0 Both are outside of the same outside side of the window so disposed of. Ex. EF o 1 & o 2 = 0 Both are outside, however of distinctive edges of the window. We can not figure out whether the section is outside so oblige subdivision by registering line-edge crossing points and do the cut-out recursively. Ex. GH, IJ 7

Slide 8

Cohen-Sutherland cutting - 5 Subdividing the line portion Subdivide the fragment by an intersection edge. Which edge? Discover an endpoint that lies outside Test the outcode to discover the edge that is crossed in view of the request: through and through and afterward right to left, which can be found from the furthest left 1-bit in the outcode. 8

Slide 9

Cohen-Sutherland cutting - 6 Example 9

Slide 10

Cohen-Sutherland cutting - 7 10

Slide 11

Cohen-Sutherland cutting - 8 The Cohen-Sutherland cut-out works best when there are numerous line sections, yet few are really shown (less subdivisions). Can be effortlessly stretched out to 3D cutting. Drifting point number juggling obliged Requires just skimming point subtractions and Boolean operations for choice test. A solitary division is needed for convergence calculation. 11

Slide 12

Parametric line cutting Cyrus-Beck cutting - 1 For general arched polygons or polyhedra . More effective than Cohen-Sutherland cutting subsequent to tedious circles are maintained a strategic distance from. Abstain from gliding point divisions for choice test. Steps Compute crossing points of the line fragment with every section edge. Focus the cut portion taking into account a progression of straightforward correlations (use parameter values) 12

Slide 13

Parametric line cutting Cyrus-Beck cutting - 2 13

Slide 14

Parametric line cutting Cyrus-Beck cutting - 3 14

Slide 15

Parametric line cutting Cyrus-Beck cutting - 4 15

Slide 16

Parametric line cutting Cyrus-Beck cutting - 5 16

Slide 17

Parametric line cutting Cyrus-Beck cutting - 6 17

Slide 18

18

Slide 19

Liang-Barsky cutting Similar to Cyrus-Beck cutting, however particularly quick for upright 2D and 3D cut districts. Offers extra unimportant dismissal testing that can stay away from count of every one of the 4 parameter values for lines that don\'t cross the clasp rectangle. Abstain from figuring crossing points until they are required. Taking into account the request of edges converging the line, numerous lines can be dismisses before every one of the four convergences are known. 19

Slide 20

Polygon cutting - 1 Usefulness for clasp polygons against different polygons Clip polygon against windows for showcase Shadow era and HSR oblige cut-out of polygons against different polygons. Hostile to clipping so as to associate and compositing techniques Shadow era 20

Slide 21

Polygon cutting - 2 Brute-power methodology: in view of line cut-out Difficulties for cut-out inward polygons Polygon section may produce more than one polygons, which drives troubles in execution. Programming interface may either preclude the utilization of cancave polygons or gap a polygon into an arrangement of arched polygons. 21

Slide 22

Sutherland-Hodgeman cutting - 1 Clips a general polygon against any raised polygon. A partition and-vanquish technique, which decay the issue into a progression of straightforward and indistinguishable issues, that, when consolidated take care of the general issue. The straightforward issue is to clasp a polygon against a solitary edge-line. Pipelines the scissors Decomposes into a pipeline, each of which manages cutting the polygon against an edge-line. 22

Slide 23

Sutherland-Hodgeman cutting - 2 Clipping a line fragment against top-edge line Consider this operation as a discovery whose information and yield are sets of vertices, with y max as a parameter known not scissors. On the off chance that there is a crossing point, say (x 3 ,y 3 ), then it is returned. 23

Slide 24

Sutherland-Hodgeman cutting - 3 We cut against the top, base, right, and left lines autonomously, and Arrange in the pipeline. 24

Slide 25

Sutherland-Hodgeman cutting - 4 Example: 25

Slide 26

Clipping in three measurements - 1 Clip a line against a right parallelepiped volume. The cut-out calculations we have acquainted can be reached out with such a 3D cutting. For Cohen-Sutherland calculation, space is subdivided into 27 locales and a 6-bit code is alloted to every area. 26

Slide 27

Clipping in three measurements - 2 Cohen-Sutherland ’ s expansion 27

Slide 28

Scan transformation Rasterization of primitives Frame cushion of n x m pixels with (0,0) relating to the lower-left corner. Check transformation of line fragments Pixels are squares, while vertices are genuine numbers in screen arranges. Filter change calculations for line sections DDA Bresenham ’ s calculation Midpoint calculation 28

Slide 29

DDA calculation - 1 Given a line portion (x 1 ,y 1 ) and (x 2 ,y 2 ) with slant m=(y 2 - y 1 )/(x 2 - x 1 ). Accept 0 <= m <= 1 for(x=x 1 , x <= x 2 , x++) { y+=m; write(x, round(y), line_color); } For m > 1, x and y are swapped utilizing symmetry. 29

Slide 30

DDA calculation - 2 Using symmetry High-and low-incline lines 30

Slide 31

Bresenham ’ s calculation - 1 DDA obliges coasting point expansion and adjusting for every pixel. Bresnham ’ s calculation: Avoids all coasting point count Is presently the standard calculation in equipment and programming rasterizer. (Need antialiasing) Given a line portion (x 1 ,y 1 ) and (x 2 ,y 2 ) with incline m=(y 2 - y 1 )/(x 2 - x 1 ). Line: y=mx+h Assume 0 <= m <= 1 31

Slide 32

Bresenham ’ s calculation - 2 Suppose a pixel is set at (i,j), what is the following? In light of the slant, it is NE=(i+1,j+1) or E=(i+1,j) ? Focus by a choice variable d i = a-b d i > 0, we pick E d i < 0, we pick NE d i = 0, wear ’ t care NE j+1 j E j-1 i i+1 32

Slide 33

Bresenham ’ s calculation - 3 How would we figure d? Need skimming point number if y=mx+h is utilized. Utilization settled point operation as opposed to coasting point. Supplant coasting point operation with altered point operation. Apply incremental calculation d i is a whole number, which obliges a considerable lot of settled point number-crunching. Consider 33

Slide 34

Bresenham ’ s calculation - 4 j+1 j+2 j j+1 j i i+1 i+2 i i+1 i+2 34

Slide 35

Bresenham ’ s calculation - 5 Incremental count, which requires just an expansion and a sign test. j+1 j+2 j j+1 j i i+1 i+2 i i+1 i+2 35

Slide 36

Scan change of polygons Polygon fill Useful for filling a polygon. Numerous feasible strategies accessible, yet technique is required to fit with the pipeline and can bolster shading. Straightforward polygons Convex: alright by OpenGL and others Concave: need to focus inside/outside point. Nonflat: work with its projection Non-straightforward polygons (self-meeting) Need to figure out whether a given point is inside or outside the polygon. 36

Slide 37

Polygon fill Polygon rasterizer: Input: polygon Output: Frame support with the right pixel set. Polygon filling Flood fill Scan-line fill Odd-even fill 37

Slide 38

Polygon fill Flood fill Steps Rasterize edges into casing support utilizing Bresenham ’ s calculation. Locate a seed pixel inside the polygon. Visit neighbors recursively and shading on the off chance that it is not edge pixels. 38

Slide 39

Polygon fill Scan-line fill Generate pixels as they are shown. On every sweep line Do odd-even test to focus inside compasses. For every pixel, do HSR and shading. Need information structures to keep away from general pursuit 39

Slide 40

Polygon fill Scan-line fill : OpenGL case OpenGL insurances right rendering just for arched polygons. Application API needs to guarantee all polygons are arched or give tessellation programming. A decent tessellation ought to Output triangles of good perspective proportion. Produce in triangle strip and fans structure. A tessellator accessible in GLU library. 40

Slide 41

Polygon fill Scan-line fill : Scan change with Z-cradle - 1 Z-support can incorporates line check transformation, HSR, and shading. Double representation of a polygon (after projection and point of view division) Normalized gadget facilitates (3D) Screen arranges (2D) (the aftereffect of orthogonal projection) Z-support uses sweep line approach For an output line on screen directions Move along sweep line a pixel at once For the

Recommended
View more...