Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com.

Similar presentations


Presentation on theme: "Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com."— Presentation transcript:

1 Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com

2 Fall 2006 revised2 Culling Techniques

3 Fall 2006 revised3 Outline Introduction View Frustum Plane Equation Frustum Plane Extraction Frustum/Point/Sphere Inclusion Tests

4 Fall 2006 revised4 Definition (View Frustum) the volume of space that includes everything visible from a given viewpoint defined by six planes arranged in the shape of a pyramid with the top chopped off If a point is inside this volume then it's in the frustum and it's visible, and vice versa Visible here mean potentially visible. It might be behind another point that obscures it, but it's still in the frustum. … the scope of occlusion culling

5 Fall 2006 revised5 View Frustum (cont)

6 Fall 2006 revised6 Definition (Plane) Divide the space into two halves; extends to infinity any given point is (in front of | behind | on) the plane. In R 3, a plane is defined by four numbers: A plane equation: Ax + By + Cz +D = 0

7 Fall 2006 revised7 Plane Equation

8 Fall 2006 revised8 Normalized Plane Equation

9 Fall 2006 revised9 Frustum Culling Idea: If object is not in frustum, do not send it through pipeline (it is not visible) Wrap the object in a bounding volume; test the bounding volume against frustum (in world coordinate system)  Sphere, bounding boxes, … Tasks: Frustum plane extraction Inclusion tests for different bounding volumes

10 Fall 2006 revised10 Frustum Plane Extraction The rendering pipeline: P M s u t In frustum culling, s is usually a point on BV, in world coordinate

11 Fall 2006 revised11 Rendering Pipeline (cont) P M s u t In OpenGL,clip volume is [-1,1] 3 c : product of PM

12 Fall 2006 revised12 Frustum Plane Extraction (Left) uxux uyuy 1 Left

13 Fall 2006 revised13 Left Plane (cont) The left plane in clip coordinate: The corresponding equation in world coordinate: uxux uyuy 1 Left

14 Fall 2006 revised14 Frustum Plane Extraction (Right) uxux uyuy 1 Right

15 Fall 2006 revised15 Right Plane (cont) The right plane in clip coordinate: The corresponding equation in world coordinate: uxux uyuy 1 Right

16 Fall 2006 revised16 Summary

17 Fall 2006 revised17 PointInFrustum Test A point in frustum  in all 6 halfspaces The valid sides of all halfspaces are > 0

18 Fall 2006 revised18 SphereInFrustum Test p p PointInOffsetFrustum Test Minkowski sum of sphere and frustum

19 Fall 2006 revised19 Minkowski Sum Coordinate dependent!

20 Fall 2006 revised20 Signed Distance to Left Plane Plane equations are further normalized to facilitate distance computation uxux uyuy 1 Left d<0

21 Fall 2006 revised21 Remarks Use bounding spheres Can be conservative if the object is slender Use hierarchical bounding volume where appropriate (see next page) BoxInFrustum: complicated and expensive AABB: already so OBB: more so

22 Fall 2006 revised22 How can bounding volume hierarchies help? View-frustum culling Ray-tracing Collision detection

23 Fall 2006 revised23 View-frustum culling Ray-tracing Collision detection How can bounding volume hierarchies help?

24 Fall 2006 revised24 How can bounding volume hierarchies help? View-frustum culling Ray-tracing Collision detection

25 Fall 2006 revised25 How can bounding volume hierarchies help? View-frustum culling Ray-tracing Collision detection

26 Fall 2006 revised26 Example (Culling Off: FPS 15.5)

27 Fall 2006 revised27 Example (Culling On: FPS 31.0)

28 Fall 2006 revised28 Epilogue Portal rendering World coordinates?! Plane representation in R 3

29 Fall 2006 revised29 Indoor Scenes Similar to building walkthrough Occlusions in scene are common (culling important) Geometric database can be huge; preprocessing is required to facilitate smooth viewing

30 Fall 2006 revised30 Preprocessing for Indoor Scenes Potential visible set (PVS) only load the rooms that are visible from the current room

31 Fall 2006 revised31 M R K L Ki B C E 1 2 3 4 5 6 7 8 M R B C L K E 1 6 2 3 4 5 7 8 Portal Rendering

32 Fall 2006 revised32 Portal Rendering only render the other rooms in PVS if the “ portal surfaces ” are in sight

33 Fall 2006 revised33 Earlier, we said … P M s u t But aren ’ t s local coordinates?

34 Fall 2006 revised34 Recall Pipeline … Model Transform Viewing Transform Modelview Matrix world coordinates

35 Fall 2006 revised35 Frustum Culling Scenario the scene is (mostly) static and specified in their world coordinate (the modeling transform is identity) the viewer navigates around them, changing the viewing transform only

36 Fall 2006 revised36 Therefore … Model Transform Viewing Transform Modelview Matrix world coordinates I s tu t = PMs M : viewing transform s : world coordinate

37 Fall 2006 revised37 Verification LR X Z x–z+1  0–x–z+1  0

38 Fall 2006 revised38 Supplement: Representing a Plane in R 3 x: pivot variable

39 Fall 2006 revised39 Plane in R 3 (cont) p n x

40 Fall 2006 revised40 Summary Algebraic equation Parametric equation Vector equation Depending on the application, select the most suitable equation In/out test Projection …

41 Fall 2006 revised41 Screen-Space Bounding Box (SSBB) Compute and display the screen-space bounding box of an AABB (axis-aligned bounding box) Convert world coordinates to clip coordinates, perspective-divide to get normalized device coordinate (and then window coordinates) Useful in GPU-assisted collision detection applications

42 Fall 2006 revised42 Display Viewing Frustum Useful for projective texturing (showing where the projector is) Useful for illustrating frustum culling Given [-1,1] 3 clip coordinates, determine their corresponding world coordinates to render


Download ppt "Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com."

Similar presentations


Ads by Google