Presentation is loading. Please wait.

Presentation is loading. Please wait.

Visibility culling – Clipping. The visibility problem What polygons are visible? There are few visible polygons. –Avoid redundant processing Three classes.

Similar presentations


Presentation on theme: "Visibility culling – Clipping. The visibility problem What polygons are visible? There are few visible polygons. –Avoid redundant processing Three classes."— Presentation transcript:

1 Visibility culling – Clipping

2 The visibility problem What polygons are visible? There are few visible polygons. –Avoid redundant processing Three classes of non visible objects –Outside the volume (view frustum culling) –Facing away (back-face culling) –Occluded (occlusion culling)

3 Visibility culling

4 View frustum culling

5 Visibility culling View frustum culling Occlusion culling

6 Visibility culling View frustum culling Back-face culling Occlusion culling

7 Clipping 2D clipping –Line / polygon clipping by the viewport –3D frustum culling –Occlusion culling –Lines are used for polygons

8 Convex Convex polygon – line between every two points belong to the polygon. The intersection of two convex regions – convex region (single). The intersection of convex and concave ? Clipping – intersection of a polygon with rectangle.

9 Clipping endpoints X min Y max Y min X max A B A x >= X min, A x <= X max A y >= Y min, A y <= Y max

10 Clipping lines Both points inside – trivially accepted Brute force: –Calculate the infinite line-edge intersection –Check if the intersection is on the edge/line

11 Cohen-Sutherland algorithm Trivial acceptance Trivial rejection Subdivision into two trivial parts Especially effective in two common cases: –Large viewports –Small viewports

12 Cohen-Sutherland algorithm Region coding Assign code to endpoints Simple calculation –Sign for bit value –Zero for acceptance –And for rejection –Or for acceptance 0 - in 1 - out 1 3 4 2 bit

13 Cohen-Sutherland example Line AB And(A,B) = 0, Or(A,B) ≠ 0 Test A with bottom edge Create AC (rejected) and CB Code(C) = 0 → Choose B Test B with the right/top edge A C D E B

14 Cohen-Sutherland

15 Cohen-Sutherland disadvantages “Random” edge choice Redundant edge-line cross calculations

16 Cyrus-Beck algorithm Put line in a parametric form P(t) = P 0 + (P 1 – P 0 )t Calculate 4 line-edge intersections – only 1D Check if there is intersection P0P0 P1P1 C1C1 C0C0

17 Cyrus-Beck algorithm Denote L(t) = P 0 +(P 1  P 0 )t, t  [0,1]. P i D is a point on the edge L i D with normal N i D. For every vector V colinear with L i D, V  N i D = 0. Specifically, for V=L(t)  P i D, 0 = N i D  (L(t)  P i D ) NiDNiD P0P0 P1P1 L(t)L(t) L(t1)PiDL(t1)PiD L(t3)PiDL(t3)PiD PiDPiD LiDLiD

18 Cyrus-Beck algorithm 0 = N i D  (L(t)  P i D ) = N i D  (P 0 + (P 1  P 0 )t  P i D ) = N i D  (P 0  P i D ) + N i D  ((P 1  P 0 )t) Solving for t, where  = (P 1  P 0 ): Works especially fast when rectangle is upright

19 Cyrus-Beck algorithm If  N i D  = 0, L and L i D are parallel The intersections of L and L i D are computed If t i  [0,1], there might be an intersection Based on the sign of  N i D , each point is classified as PE (potentially entering) or PL (potentially leaving) PE with the largest t and PL with the smallest t define the intersection P1P1 P1P1 PEPE PEPE PLPL PLPL PEPE PLPL P0P0 P1P1 P0P0 P1P1 PLPL PEPE

20 Cohen-Sutherland – polygons Create a list of vertices – {v 1, …, v n } Clip against a single infinite edge

21 Cohen-Sutherland – polygons s p InsideOutside s p InsideOutside s p InsideOutside s p InsideOutside 1 st Output i OutputNo Output i 2 nd Output Output

22 Hierarchical clipping Build hierarchical scene representation –The bounding box of root includes the children Test the root node –If it is outside, stop and discard everything –If it’s fully inside, render everything –Otherwise, test recursively every child

23 Example 1 2 5 4 3 6 1 2 5 4 3 6


Download ppt "Visibility culling – Clipping. The visibility problem What polygons are visible? There are few visible polygons. –Avoid redundant processing Three classes."

Similar presentations


Ads by Google