Synthesis of Image Calculation of Visibility

32
COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2003 1 Synthesis of Image Calculation of Visibility Graphics Systems / Computer Graphics and Interfaces

description

Synthesis of Image Calculation of Visibility. Graphics Systems / Computer Graphics and Interfaces. Synthesis of Image. - PowerPoint PPT Presentation

Transcript of Synthesis of Image Calculation of Visibility

Page 1: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

1

Synthesis of ImageCalculation of Visibility

Graphics Systems /

Computer Graphics and Interfaces

Page 2: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

2

Synthesis of Image

The image synthesis (English rendering) Is to create images with a high degree of realism from the description of the objects it contains (geometry and interaction with light), light sources and positioning of the observer.

Page 3: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

3

Synthesis of Image

Index

1. Models Lighting

a)Model Elementary

b)Phong model

c) Improved model (attenuation with distance, atmospheric attenuation ...)

2. Improving image

Shading (shading, smooth shading)

Texture Mapping; "Bump Textures"

"Antialiasing"

3. Projection of Shadows

4. Calculation of Visibility (This chapter)

a)Algorithms in the image space

b)Algorithms in object space

c) Algorithm type Priorities List

5. Global illumination algorithms

Page 4: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

4

Synthesis of Image- Calculation of Visibility -

Objective: from a set of 3D objects, which lines or surfaces of the objects that are visible

both from the center of projection (perspective projection) or along the projection direction

(for parallel projection), so that show only lines or visible surfaces.

Two possible approaches:

1. For each pixel determining which image object visible (Image Area)is (Each pixel in the image){Determine the object closer to the observer, given the projection ray;

draw the pixel with the appropriate color;}

2. Compare objects between themselves in order to select the visible part of each (Subject Area)

is (Each subject of the "world"){Determine the parts of the object not obstructed by him or other

objects;Draw the visible parts in the appropriate color;

}

Page 5: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

5

Synthesis of Image- Calculation of Visibility -

Backface culling

Page 6: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

6

Photo Synthesis - Calculation of Visibility Alg space object

Algorithms in space subject to determination of visible lines:

The volume: Algorithm Roberts

To the edge: Algorithm Appel, Loutrel, Galimberti and Montanari

In these algorithms all edges are tested to produce a list of visible segments all edges.

By Volume: It is assumed that an edge may be hidden by volume of an object.

To the Edge: The test is performed edge against edge noting that the visibility of an edge enjoys consistency, which allows to determine the invisibility of an edge from the invisibility of other edge having with it a common vertex.

Consistency edge: Only one edge changes its profile where it crosses behind a visible edge.

Page 7: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

7

Synthesis of Image- Calculation of Visibility - Alg space object

By Volume - Algorithm Roberts (1963)

Requirement: Each edge must belong to one face of a polyhedron convex. Concave polyhedra must be broken into several convex in order to apply the algorithm.

1. Remove all rear faces of objects (Backface culling) and corresponding edges 2. Compare the remaining edges against each volume (Polyhedron) of the scene; 4 of this

test situations may occur:

- Edge completely hidden by volume.- Edge does not hide- A part of the edge is not hidden- Two parts of the edge are not hidden

Page 8: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

8

Synthesis of Image- Calculation of Visibility - Alg space object

At the edge - Algorithm Appel, Loutrel, Galimberti and Montanari (1967/9, 1970)Unlike alg. Roberts comes to the polygon level.

1. Determine the faces oriented to the observer (Backface culling).

2. Calculate "Quantitative Invisibility"A vertex for each object.

"Quantitative Invisibility"IQ one point: the number of polygons oriented observer who conceal that.

When passing behind an edge of a polygon, their IQ is incremented by 1, and when it is no longer obscured decremented to 1.

• When it reaches the end vertex of an edge, the value IQ this vertex is the initial value for the edges emanating from that vertex.

Contour line: Is defined as an edge shared by a polygon back-facing with another front-facing, or polygon front-facing isolated.

Contour lines: AB, CD, DF, KL

EC, EF, JK are not (because they are shared by polygons front-facing)

Page 9: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

9

Synthesis of Image- Calculation of Visibility - Alg space object

TheIQ changes when the edge passes behind a contour line.

In the figure the points indicate the intersections of the projection of the edge AB with the projections of contour lines.

In the end only the segments with value IQ equal to zero are visible.

Page 10: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

10

Synthesis of Image- Calculation of Visibility - Alg space object

Determination of visible faces: Atherton & Weiller (1977)

Algorithm oriented area like Warnock, but subdivides the screen area by the border of the polygons instead of rectangular areas.

Requirement: Requires the application of a sophisticated algorithm clipping polygons capable of effecting clipping a concave polygons with holes against any other.

Page 11: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

11

Photo Synthesis - Calculation of VisibilityAlg space object - Atherton & Weiller

Procedure:Sort polygons by coordinated Z1. The polygon nearest the observer is used to perform clipping the other,

resulting two lists containing the polygons (or part thereof) that are within and outside the region clipping.

2. The polygons farther inland than the current list are marked as invisible.3. In cases of mutual occlusion, as shown below, the internal list will contain

polygons that are hiding at present. These are used to perform the initial polygon clipping about (recursive call)

In these cases one stack is used so that the program does not call the algorithm with the same polygon that initially caused the recursive call again.

4. The polygon is drawn before returning. The exterior of this phase list containing only the outer part of the initial polygon returns as internal list. So to return the visible part of the initial polygon is drawn.

5. Back to 2, to process the list of outer polygons.

Page 12: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

12

Photo Synthesis - Calculation of VisibilityAlg space object - Atherton & Weiller

Note: the clipping is performed with a

copy of the original polygon to be a more

efficient operation. As a result, the

polygon is placed in its own internal list

since it coincides in part with the polygon

clipping.

In the figure the values indicate the Z coordinate of each vertex.

Page 13: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

13

Synthesis of Image- Calculation of Visibility - Alg space image

1. Oriented area: Algorithm Warnock (1969)2. Walked the Line: Line Scanning 3. Oriented pixel: Z-buffer, Ray Casting

Algorithm Warnock• The algorithm successively divides the projected image into rectangular

areas. • If easy to decide which polygons visible in the area, then these are shown;

otherwise, the area is divided into smaller areas to which the rating is applied recursively.

• The smaller areas are fewer polygons are overlapping in these areas and can more easily decide which polygon drawing.

The algorithm uses the concept of coherence area: A group of adjacent pixels is usually covered by the same visible surface.

Page 14: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

14

Photo Synthesis - Calculation of Visibility Alg image space: alg. Warnock

Procedure alg. Warnock:• Division of the area into 4 equal blocks. At each stage of division, the projection of

each polygon will have one of four situations for each field:

The four situations in which the decision is possible, with no more subdivision:

1. All polygons are outside the area Paint the area to the background color.

2. Only a polygon that intersects or is fully in the (case b., And c.). Filling the area with the background color of paint and then the part of the polygon which overlaps this area.

3. If a), ie only one polygon that covers the entire area, without any further projected that area. Paint the area to the color of the polygon.

Page 15: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

15

Photo Synthesis - Calculation of Visibility Alg image space: alg. Warnock

4. More than one polygon intersects, or is contained surrounds the area but the surrounding area and is ahead of all others. Paint the area with the color of the latter. Case a) in the figure below.

In case b) the area is subdivided, resulting in each case one of the 4 previous situations.

And if not checked any of the 4 situations?

The division is done recursively, not down below the pixel size. In this limiting case, it appears that the closest polygon and is painted with the corresponding color.

Page 16: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

16

Photo Synthesis - Calculation of Visibility Alg image space: alg. Warnock

An example of the application of the algorithm. The figures indicate that the situation found for each area. Area indicates that no number was not verified any of the conditions.

Page 17: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

17

Photo Synthesis - Calculation of VisibilityAlg space image: scan line

Algorithm Line Scanning

The image is created line by line, similar to filler 2D regions algorithm, called the list of active edges algorithm.

It uses the concept of consistency of scan line or vertical coherence: The set of visible objects for a certain scan line in an image, differs little from the whole of the previous line.

And coherence edge: Only one edge changes its profile where it crosses behind a visible when it enters one edge or face.

Data structures used: Table (new) Edges (ET), Table of Polygons (EN) List of Active and Edges (AEL).

Page 18: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

18

Photo Synthesis - Calculation of VisibilityAlg space image: scan line

(Note: descriptors with more information than given in the book, in red)

Table Edges (ET): keeps track of all edges whose projection in the view plane is not horizontal. The table entries are ordered by increasing smallest value of Y form, and initially contain:

1.Coordinates (X, Z) With a lower vertex of Y 2.Y coordinate of the other end of the edge (or edge height Y1-Y0)3. Increments x / Y= ∂ X / ∂ Y, Z / Y = ∂ Z / ∂ Y, Used to update the X and Z in the transition

to the next scan line4. Identification(S) polygon(S) it belongs to the edge (pointer)

Table Polygon (PT): information of all the polygons for each containing:1.Coefficients of the plane equation (at least Z / X = ∂ Z / ∂ X)2.Color information3.Coordinate Z, Recalculating each pixel4.Flag in-out, Started False, Is used to control whether processing is inside or outside the polygon

Active Edge List (AEL): controls which active edges in the current scan line. Reduces the time to find the edges to be processed at the current scan line.

Page 19: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

19

Photo Synthesis - Calculation of VisibilityAlg space image: scan line

To expedite the processing is necessary to maintain a list of polygons that are with flag in-out equal to TRUE.

the

b

cc

+1

c +2

the

b

c, c +1

c +2

When checking the overlapping polygons, as in

line c, More than one polygon has a flag in-out

the true. Using equation of each polygon plane is

determined by the coordinate Z of each to know

which one is closest to the observer. The problem

is thus reduced to two dimensions: X and Z

Page 20: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

20

Photo Synthesis - Calculation of VisibilityAlg space image: scan line

• Incremental update of an edge to change a scan line:

1,

.

.

yvisto

y

zz

y

zyzz

y

xx

y

xyxx

edgepoly zz • Initialization of the depth of a polygon when in-out changes to

TRUE:

• Update Zpoly after Δx pixels:

x

zxzz .

Page 21: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

21

Photo Synthesis - Calculation of VisibilityAlg space image: Z-Buffer

Z-Buffer Algorithm

One of the simplest algorithms implemented either in hardware or in software. Does not require any pre-processing or sorting performs compared subject-object.

Requirements: A frame buffer to the final image and a second buffer to save the Z value corresponding to each pixel, called the Z-Buffer.

Procedure:

1. Fill with zeroes Z-Buffer and frame buffer with the background color (background). The higher value of Z Z-Buffer will correspond to the frontal plane of clipping.

2. Browsing each polygon (Scan-convert), in any order.

3. If the point (x, y) of the current polygon processing, is closer to the observer than the current point of the Z-Buffer, then this replaces the previous point.

Page 22: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

22

Photo Synthesis - Calculation of VisibilityAlg space image: Z-Buffer

Z-Buffer Algorithm

/ * Initialize buffers * /is(y = 0; y <YMAX; y + +)

is(X = 0, X <XMAX and x + +)BufferIm {(x, y) = background_color;

bufferZ (x, y) = 0;}

is (Each polygon) { is (Each pixel in the projection of the polygon)

{/ * Calculate for Z (x, y) in the polygon * /PolygonZ pz = (x, y);if (Pz> bufferZ (x, y))BufferZ {(x, y) = pz;

bufferIm (x, y) = cor_poligono ();}

}}

Page 23: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

23

Photo Synthesis - Calculation of VisibilityAlg space image: Z-Buffer

Optimization in processing:

The value z point (X + 1, Y) in the polygon can be obtained from the value z in (X, y) if we

consider that the polygon is flat.

For z we must solve the equation Ax + By + Cz + D = 0 in order to z:

C

ByAxDz

On (X, y) the equation has the value z1 then in (X + 1, Y) the value of z can be calculated:

x

zz

x

zxzz

.1. 11

C

Azz 1

Page 24: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

24

Photo Synthesis - Calculation of VisibilityAlg space image: Ray-casting

Ray-casting algorithmThe visible surface at each pixel of the image is determined by tracing a ray of light from the imaginary center of projection (observer), passing through the center of the pixel to the 3D scene. The color at each pixel is defined by the intersection with the closest object.

Set Design and Center window the view planeis(Each line of the image)

is(Each pixel Line){Set the radius from the center of projection passes the pixel

is (Each object in the scene){ if ((Intersected object) and (closer than the previous record))

register intercept the object and reference}assigning to the pixel color closest interception

}

Page 25: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

25

Photo Synthesis - Calculation of Visibility Alg type priority list

Type algorithms Priorities List

• Alg Newel Newel & Sancha

• Binary Space-Partitioning Trees

Objective: Determining the order of visibility for objects (polygons), ensuring that the

image will be created correctly if the objects are drawn by a certain order:

1. Paint the furthest faces the observer first

2. As other, closer, are being painted, downplaying earlier.

(Algorithm "Painter")

Page 26: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

26

Photo Synthesis - Calculation of Visibility Alg type priority list -Alg Newel Newel & Sancha

Alg Newel Newel & Sancha (Depth-sort algorithm)

Procedure: paint the polygons in order of decreasing distance to the observer. For this 3 steps are performed:

1. Sort the polygons in order of increasing z (The farthest to closest)

2. Resolve any ambiguity in the ordering, especially if there are overlapping polygons on coordinate z. It may be necessary splitting polygons.

3. Paint the polygons in order of farthest to nearest.

Page 27: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

27

Photo Synthesis - Calculation of Visibility Alg priority list type - -Alg Newel Newel & Sancha

Kind of ambiguities that can arise in the ordering of polygons:

Preprocessing:

Sort polygons by coordinated Z farthest vertex

Processing:

For the last polygon Pthe list, check if there is any polygon Qwhose greatest Z is further away than the lowest Z of PAnd that is being obstructed by P. If not, then Pcan be drawn.

Are made to 5 tests for each polygon Qunder the above conditions. If one is found then Pcan be drawn before Q.

a) b) c)

Page 28: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

28

Photo Synthesis - Calculation of Visibility Alg priority list type - Binary Space-Partitioning Trees

Binary Space-Partitioning Trees

Effective for calculating visibility in static scenes where there variation of the viewpoint.

Principle of operation: if we can define a plane that separates two sets of polygons (cluster1 andcluster2)Then we can say that the cluster1, which is the same side of the observer, can block, but not be obstructed by cluster2 the other side of the plane. If the latter is drawn first, we obtain an accurate representation of the scene.

Each cluster can also be divided recursively, until we get to the polygon level.

Algorithm to construct the binary tree:1. Choose one of the polygons to the root of the binary tree.2. The root is used to divide the space into 2: one of the spaces containing the polygons

that are ahead of him in relation to normal; the other part contains them behind.3. Recursively divide each of the subspaces obtained in the previous iteration.

Page 29: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

29

Photo Synthesis - Calculation of Visibility Alg priority list type - Binary Space-Partitioning Trees

Example tree to create a set of polygons.

a) b)

c) d)

d) Tree obtained if the first polygon is the 5

Page 30: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

30

Photo Synthesis - Calculation of Visibility Alg priority list type - Binary Space-Partitioning Trees

Pseudo-code for the list of correct polygons, given the observation point:

void BSP_displayTree (BSP_tree * tree)if (Tree! = Null) {

if (Viewer is in front of tree-> root) {/ * Display back child, root, and front child * /BSP_displayTree (tree-> backChild);displayTree (tree-> root);BSP_displayTree (tree-> frontChild);

} else {/ * Display front child, root, and back child * /BSP_displayTree (tree-> frontChild);displayTree (tree-> root); / * If back-face culling

off * /BSP_displayTree (tree-> backChild);

}}

}

Note: If the backface culling is active, the polygons that are not facing the observer are not drawn.

Page 31: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

31

Photo Synthesis - Calculation of Visibility Alg priority list type - Binary Space-Partitioning Trees

Result of the query tree for two different points of observation:

a) b)

Page 32: Synthesis of Image Calculation of Visibility

COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

COMPUTER GRAPHICS AND INTERFACES /GRAPHICS SYSTEMS JGB / AAS 2003

32

Photo Synthesis - Calculation of Visibility Alg priority list type - Binary Space-Partitioning Trees

Note: this algorithm can assist in the operation of clipping. Any polygon whose plane does

not intersect the viewing volume (VV), has a subtree that is totally out of VV, and

therefore not investigated.

Choose the node root each sub-tree: the algorithm works whatever polygon However, the

best is the one which leads to a smaller number of divisions of the remaining polygons.

Heuristics: Randomly test some polygons (eg 6) and choose to root to give the lowest

number of divisions.