1 / 31

Game Programming (Indoors Rendering)

Game Programming (Indoors Rendering). 2005. Spring. General Analysis. How any good 3D pipeline clipping view frustum 밖의 물체를 제외시키는 것 back face culling 시선과 반대 방향의 면을 제외시키는 것 occluding 다른 물체에 의해 가려지는 것을 미리 제외시키는것 indoors rendering 에서 중요 computing level of detail 멀리 있는 물체는 간단히 하는 것

will
Download Presentation

Game Programming (Indoors Rendering)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Game Programming(Indoors Rendering) 2005. Spring

  2. General Analysis • How any good 3D pipeline • clipping • view frustum밖의 물체를 제외시키는 것 • back face culling • 시선과 반대 방향의 면을 제외시키는 것 • occluding • 다른 물체에 의해 가려지는 것을 미리 제외시키는것 • indoors rendering에서 중요 • computing level of detail • 멀리 있는 물체는 간단히 하는 것 • outdoors rendering에서 중요

  3. Occluder-Based Algorithms • Occlusion Testing • O(n^2) problem  O(n) problem : n: number of triangles • Frame-coherence from the current viewpoint… select a set of potential occluders (close, large triangles) for each triangle in the scene if it is closer than the viewing distance test for occlusion with any of the occluders if passes the test  paint it end if end if End for If orientation or position changed more than X recompute solution store new position store new orientation end if

  4. Binary Space Partition Algorithms • BSP (Ex) Doom, Quake) • A binary tree data structure that allow us to classify geometric data spatially • Viewpoint independent triangle ordering (advantage) • BSP Construction • Begin with the complete set. • Select the triangle that best divides the set in half. • Compute the support plane of the said triangle. • Store the selected triangle and its support plane in the current node. • Divide the remaining triangles depending on which side of the selected plane each one stays. • If any of the two sublists is not empty, create a new node and go to step 2.

  5. BSP: Examples Game level, top-down view Split using 8 as a base. The Front: 1.2, 2, 3, 4, 5.2 The Back: 1.1, 6, 7, 9, 5.1

  6. BSP: Examples BSP tree with front subtree processed

  7. BSP: Examples Full BSP tree

  8. BSP: Implementation • Choosing the ideal splitting plane • Closest to center of the set • Barycenter: (SV[i])/ number_of_vertices • The triangle whose support plane generates less vertex splits • Decide what to do when a triangle is divided into two halves by splitting plane • Generate three new triangles • One on one side of the supported plane • Two on the opposite side

  9. int triangle::split(plane pl, triangle *tris1, int &num1, triangle *tris2, int &num2) { // -1, 0 or 1 depending on which side we are in int v1= pl.testpoint(p1); int v2= pl.testpoint(p2); int v3= pl.testpoint(p3); int val=v1+v2+v3; switch (val) { case 3: // triangle completely in positive side (1,1,1) tris1[0]=(*this); num1=1; num2=0; return 1; case -3: // triangle completely in negative side (-1,-1,-1) tris2[0]=(*this); num1=0; num2=1; return 1; case -2: // triangle with one vtx on the plane and the others on negative side (0,-1,-1) // no need to divide it tris2[0]=(*this); num1=0; num2=1; return 1; case 2: // triangle with one vtx on the plane and the others on positive side (0,1,1) // no need to divide it tris1[0]=(*this); num1=1; num2=0; return 1; Complete triangle split routine

  10. Complete triangle split routine case 0: // triangle in plane (0,0,0) or triangle with one vertex in plane and other two in opposite sides (1,0,-1). The latter requires a divide. point pivot, positive, negative; if (v1==0) { pivot=p1; if (v2>0) { positive=p2; negative=p3; } else { positive=p3; negative=p2; } } if (v2==0) { pivot=p2; if (v1>0) { positive=p1; negative=p3; } else { positive=p3; negative=p1; } } if (v3==0) { pivot=p3; if (v1>0) { positive=p1; negative=p2; } else { positive=p2; negative=p1; } } // here positive, pivot and negative are ready point i; pl.testline(positive, negative, i); tris1[0].create(positive, i , pivot); num1=1; tris2[0].create(negative, pivot, i ); num2=1; return 2; } else { // triangle is inside plane… assign to positive node tris1[0]=(*this) num1=1; num2=0; return 1; }

  11. Complete triangle split routine case -1: // can be: two vtx on plane and one on negative side (0,0,-1) // one vertex on positive and two vtx on negative (1,-1,-1). Latter requires a divide if (v1*v2*v3==0) { // one of them was zero: we’re on the first case tris2[0]=(*this); num1=0; num2=1; return 1; } if (v1==1) { positive=p1; negative1=p2; negative2=p3; } if (v2==1) { positive=p2; negative1=p1; negative2=p3; } if (v3==1) { positive=p3; negative1=p1; negative2=p2; } point v1=negative1-positive; point v2=negative2-positive; point i1, i2; pl.testline(negative1, positive, i1); pl.testline(negative2, positive, i2); tris1[0].create(positive, i1 , i2); num1=1; tris2[0].create(negative2, i2, i1 ); tris2[0].create(negative2, i1, negative1 ); num2=2; return 3; case 1: // can be: two vtx on plane and one on positive side (0,0,1) // two vertices0 on positive and one vertex on negative (1,1,-1). Latter requires a divide …….

  12. Binary Space Partition Algorithms • The definition of the BSP • Creating the BSP class bsp; class bsp { bsp *leftnode; bsp *rightnode; plane supportplane; triangle tri; public: void create(list<triangle>); }; Select best support plane For each triangle in the input set split it arrange the resulting triangles in a front and back list If front list is not empty call create with this front list If back list is not empty call create with this back list

  13. View-Dependent Sorting begin with a viewpoint, and at the root node of the tree test if we are "in front" or "behind" the plane if we are in front: scan the back node paint the triangle which divides the set scan the front node else scan the front node paint the triangle which divides the set scan the back node

  14. View-Dependent Sorting • Back-to-Front vs. Front-to-Back Algorithms • “accept pixel” path is much longer than the “reject pixel” path • Test if the pixel's Z-value affects the Z-buffer • If it doesn't, reject the pixel and move on to the next • If it does, • Compute texture mapping • Compute interpolated colors • Compute lighting • Mix these to generate a single pixel color • Paint the pixel • Update the Z-buffer

  15. Hierarchical Clipping • Hierarchical Clipping • BSPs can be easily be extended to accelerate clipping computations • Hierarchical Bounding volume • begin with a viewpoint, and at the root node of the tree • if the current node's bounding box is visible • test if we are "in front" or "behind" the plane • if we are in front: • scan the back • paint the triangle which divides the set • scan the front node • else • scan the front node • paint the triangle which divides the set • scan the back node • end if • end if

  16. Occlusion Detection • Occlusion Detection • BSPs can also be used to compute occlusion detection • Leafy-BSPs • A regular BSP where all the geometry has been propagated to the leaves • The core of Quake rendering pipeline

  17. Occlusion Detection • Cell-to-cell visibility • PVS (Potentially Visible Set) • A matrix of bits • Ex) If position X, Y has value of true, then room X sees room Y • Store a summary of all the visibility processing

  18. Portal Rendering • Portal Rendering • world hierarchy is not automatically computed, and visibility is computed in real time, not preprocess. • Ex) Unreal Engine • The game world is divided into cells or rooms connected by doors or portals • Cell  node, portal  edge

  19. Portal Rendering • Cell & Portal structure • Each room • hold its geometrical data and a tight bounding volume • Portals • Portal polygon can be concave or convex • Some use four-sided portal only

  20. Portal Rendering • Painting algorithms • Resolve visibility queries at runtime • Portal frustum • How to use portals as clipping volumes

  21. Optical Effects with Portals • Optical Effects with Portals Type • Regular, Reflective, Translucent class portal { point *vertices; int numbertices; int type; roomid room1, room2; }; Mirrors on Portals

  22. Hierarchical Occlusion Maps • Occluders versus occludees: Blue parts: occluders Red parts: occludees

  23. View X Point Y Z Hierarchical Occlusion Maps • Depth versus overlap: Depth + Overlap = Occlusion

  24. Rendered Image Occlusion Map Hierarchical Occlusion Maps • Representation of projection for overlap test: occlusion map • Corresponds to a screen subdivision • Records average opacity per partition • Generate by rendering occluders • Record pixel opacities (i.e., coverage)

  25. Occlusion Map Pyramid 64 x 64 32 x 32 16 x 16

  26. Occlusion Map Pyramid

  27. Hierarchical Occlusion Maps • The overall algorithm • Preprocessing • Preselect a good database of occluders • At runtime • Select the N closest occluders from the database • Build the HOM based on these objects • Test visible nodes against the HOM • If they lie in a black zone, we need to paint them • If they are in a white zone, perform the Z-test with DEB(Depth Estimation Buffer) and decide whether we should discard them or not • If they are in grey areas, require further refining in the HOM

  28. Hybrid Approaches • Very detailed and dense indoors environments?? • Portal-Octree Hybrid (= A nested portal-octree system) • Combine • Portal visibility for the rooms • Hierarchical culling using an octree for the room contents • The octree must not really hold the object data, but instances to it  reducing the memory footprint

  29. Quadtree-BSP Hybrid • Large area need to be explored, especially if very precise collision detection needs to be used • Divide the game world into Quad tree • Stopping a certain number of triangles or a predefined size • Ex) below 500 triangles or 10 meters in size • Each leaf node • Store the geometry in a BSP tree data structure • Quad-tree converge faster than BSPs do • A quadtree divides the input data by four in each level, whereas BSPs only devide in half

  30. Hardware-Assisted Occlusion Tests • Hardware-Assisted Occlusion Tests • Improve by sending data front-to-back for each object activate occlusion query send bounding box deactivate occlusion query if pixels were modified by the test render object end if end for

  31. Hardware-Assisted Occlusion Tests • The pseudocode Paint (node *n) Sort the four subnodes using their distance to the viewer for each subnode (in distance order) if subnode is not empty if subnode is not clipped activate occlusion query paint bounding box if pixels were modified paint object end if end if end if end for

More Related