CSCE 552 Spring 2009 3D Models By Jijun Tang. Triangles Fundamental primitive of pipelines  Everything else constructed from them  (except lines and.

Slides:



Advertisements
Similar presentations
Optimized Stencil Shadow Volumes
Advertisements

Computer graphics & visualization Collisions. computer graphics & visualization Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization.
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
CSE 381 – Advanced Game Programming Scene Management
Korea Univ. Graphics Lab. 3D Game Engine Design Chapter 12. Spatial Sorting Chung Ji Hye
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
Right of Passage.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
1 Dr. Scott Schaefer Hidden Surfaces. 2/62 Hidden Surfaces.
CGDD 4003 THE MASSIVE FIELD OF COMPUTER GRAPHICS.
Tomas Mőller © 2000 Speeding up your game The scene graph Culling techniques Level-of-detail rendering (LODs) Collision detection Resources and pointers.
Introduction General Data Structures - Arrays, Linked Lists - Stacks & Queues - Hash Tables & Binary Search Trees - Graphs Spatial Data Structures -Why.
Chapter 5.1 Graphics. 2 Overview Fundamentals High-Level Organization Rendering Primitives Textures Lighting The Hardware Rendering Pipeline Conclusions.
Hidden Surface Elimination Wen-Chieh (Steve) Lin Institute of Multimedia Engineering I-Chen Lin’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals.
CSCE 590E Spring 2007 Graphics I By Jijun Tang. Announcements Second presentation will be held on April 16 th and 18 th  April 16 th : Space Banditos,
Graphics Presented by Shuang Li. 2 Overview  Fundamentals  High-Level Organization  Rendering Primitives  Textures  Lighting  The Hardware Rendering.
1 Advanced Scene Management System. 2 A tree-based or graph-based representation is good for 3D data management A tree-based or graph-based representation.
CSCE 590E Spring 2007 Graphics II By Jijun Tang.
Ray Space Factorization for From-Region Visibility Authors: Tommer Leyvand, Olga Sorkine, Daniel Cohen-Or Presenter: Alexandre Mattos.
10/11/2001CS 638, Fall 2001 Today Kd-trees BSP Trees.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Beyond Meshes Spring 2012.
Hidden Surface Removal
Week 1 - Friday.  What did we talk about last time?  C#  SharpDX.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
10/29/02 (c) 2002 University of Wisconsin, CS559 Today Hidden Surface Removal Exact Visibility.
Spatial Data Structures Jason Goffeney, 4/26/2006 from Real Time Rendering.
10/09/2001CS 638, Fall 2001 Today Spatial Data Structures –Why care? –Octrees/Quadtrees –Kd-trees.
CSE 381 – Advanced Game Programming Basic 3D Graphics
The Visibility Problem In many environments, most of the primitives (triangles) are not visible most of the time –Architectural walkthroughs, Urban environments.
CSCE 552 Fall D Models By Jijun Tang. Triangles Fundamental primitive of pipelines  Everything else constructed from them  (except lines and point.
Real-Time Rendering SPEEDING UP RENDERING Lecture 04 Marina Gavrilova.
1 Advanced Scene Management. 2 This is a game-type-oriented issue Bounding Volume Hierarchies (BVHs) Binary space partition trees (BSP Trees) “Quake”
Chapter 5.1 (3D) Graphics. 2 Overview Fundamentals High-Level Organization Rendering Primitives Textures Lighting The Hardware Rendering Pipeline Conclusions.
2 COEN Computer Graphics I Evening’s Goals n Discuss application bottleneck determination n Discuss various optimizations for making programs execute.
CSCE 552 Fall 2012 Animations By Jijun Tang. Animation terms  frame – an image that is displayed on the screen, usually as part of a sequence.  pose.
1Computer Graphics Implementation II Lecture 16 John Shearer Culture Lab – space 2
Implementation II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Chapter 5.1 Graphics. 2 Overview Fundamentals High-Level Organization Rendering Primitives Textures Lighting The Hardware Rendering Pipeline Conclusions.
Implementation II.
David Luebke11/26/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
Computer Graphics Zhen Jiang West Chester University.
Emerging Technologies for Games Deferred Rendering CO3303 Week 22.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 7. Speed-up Techniques Presented by SooKyun Kim.
Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.
Right of Passage.
Maths & Technologies for Games Spatial Partitioning 2
Computer Graphics I, Fall 2010 Implementation II.
Maths & Technologies for Games Spatial Partitioning 1 CO3303 Week 8-9.
Honours Graphics 2008 Session 5. Today’s focus Rasterization Visibility determination Coarse / fine visibility determination.
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
Graphics, Modeling, and Textures Computer Game Design and Development.
1 Advanced Scene Management. 2 This is a game-type-oriented issue Bounding Volume Hierarchies (BVHs) Binary space partition trees (BSP Trees) “Quake”
Scene Manager Creates and places movable objects like lights and cameras so as to access them efficiently, e.g. for rendering. Loads and assembles world.
Computer Graphics Implementation II
Bounding Volume Hierarchies and Spatial Partitioning
CSCE 552 Spring 2011 Graphics By Jijun Tang.
Bounding Volume Hierarchies and Spatial Partitioning
CSCE 552 Spring 2010 Animation By Jijun Tang.
Hidden Surfaces Dr. Scott Schaefer.
CSCE 441: Computer Graphics Hidden Surface Removal
Graphics, Modeling, and Textures
Implementation II Ed Angel Professor Emeritus of Computer Science
Lecture 13 Clipping & Scan Conversion
CS679 - Fall Copyright Univ. of Wisconsin
Introduction to Computer Graphics with WebGL
Collision Detection.
Implementation II Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

CSCE 552 Spring D Models By Jijun Tang

Triangles Fundamental primitive of pipelines  Everything else constructed from them  (except lines and point sprites) Three points define a plane Triangle plane is mapped with data  Textures  Colors “Rasterized” to find pixels to draw

Mesh

Vertices A vertex is a point in space Plus other attribute data  Colors  Surface normal  Texture coordinates  Whatever data shader programs need Triangles use three vertices  Vertices shared between adjacent triangles

Textures Array of texels  Same as pixel, but for a texture  Nominally R,G,B,A but can mean anything 1D, 2D, 3D and “cube map” arrays  2D is by far the most common  Basically just a 2D image bitmap  Often square and power-of-2 in size Cube map - six 2D arrays makes hollow cube  Approximates a hollow sphere of texels  For environmental

Cube Map

Texture Example

High-Level Organization Gameplay and Rendering Render Objects Render Instances Meshes Skeletons Volume Partitioning

Gameplay and Rendering Rendering speed varies according to scene  Some scenes more complex than others  Typically frames per second Gameplay is constant speed  Camera view should not change game  In multiplayer, each person has a different view, but there is only one shared game  1 update per second (RTS) to thousands (FPS) Keep the two as separate as possible!

Render Objects Description of renderable object type Mesh data (triangles, vertices) Material data (shaders, textures, etc) Skeleton (+rig) for animation Shared by multiple instances

Render Instances A single entity in a world References a render object  Decides what the object looks like Position and orientation Lighting state Animation state

Meshes Triangles Vertices Single material “Atomic unit of rendering”  Not quite atomic, depending on hardware Single object may have multiple meshes  Each with different shaders, textures, etc  Level-Of-Distance (LOD)

LOD Objects have different mesh for different distance from the player The mesh should be simpler if object is faraway Many games have LOD, for example, Microsoft Train Simulator

Volume Partitioning Cannot draw entire world every frame  Lots of objects – far too slow Need to decide quickly what is visible Partition world into areas Decide which areas are visible Draw things in each visible area Many ways of partitioning the world

Volume Partitioning - Portals Nodes joined by portals  Usually a polygon, but can be any shape See if any portal of node is visible If so, draw geometry in node See if portals to other nodes are visible  Check only against visible portal shape  Common to use screen bounding boxes Recurse to other nodes

Volume Partitioning – Portals Visible Invisible Not tested Eye View frustum Node Portal Test first two portals ??

Volume Partitioning – Portals Visible Invisible Not tested Eye Node Portal Both visible

Volume Partitioning – Portals Visible Invisible Not tested Eye Node Portal Mark node visible, test all portals going from node ??

Volume Partitioning – Portals Visible Invisible Not tested Eye Node Portal One portal visible, one invisible

Volume Partitioning – Portals Visible Invisible Not tested Eye Node Portal Mark node as visible, other node not visited at all. Check all portals in visible node ?? ?

Volume Partitioning – Portals Visible Invisible Not tested Eye Node Portal One visible, two invisible

Volume Partitioning – Portals Visible Invisible Not tested Eye Node Portal Mark node as visible, check new node’s portals ?

Volume Partitioning – Portals Visible Invisible Not tested Eye Node Portal One portal invisible. No more visible nodes or portals to check. Render scene.

Real Example

Volume Partitioning – Portals Portals are simple and fast Low memory footprint Automatic generation is difficult, and generally need to be placed by hand Hard to find which node a point is in, and must constantly track movement of objects through portals Best at indoor scenes, outside generates too many portals to be efficient

Volume Partitioning – BSP Binary space partition tree Tree of nodes Each node has plane that splits it in two child nodes, one on each side of plane Some leaves marked as “solid” Others filled with renderable geometry

BSP

Volume Partitioning – BSP Finding which node a point is in is fast  Start at top node  Test which side of the plane the point is on  Move to that child node  Stop when leaf node hit Visibility determination is similar to portals  Portals implied from BSP planes Automated BSP generation is common Generates far more nodes than portals  Higher memory requirements

Volume Partitioning: Quadtree Quadtree (2D) and octree (3D)  Quadtrees described here  Extension to 3D octree is obvious Each node is square  Usually power-of-two in size Has four child nodes or leaves Each is a quarter of size of parent

Quadtree

Octree

Volume Partitioning: Quadtree Fast to find which node a point is in Mostly used for simple frustum culling Not very good at indoor visibility  Quadtree edges usually not aligned with real geometry Very low memory requirements Good at dynamic moving objects  Insertion and removal is very fast

Volume Partitioning - PVS Potentially visible set Based on any existing node system For each node, stores list of which nodes are potentially visible Use list for node that camera is currently in  Ignore any nodes not on that list – not visible Static lists  Precalculated at level authoring time  Ignores current frustum  Cannot deal with moving occluders

PVS Room A Room B Room C Room D Room E Viewpoint PVS = B, A, D

Volume Partitioning - PVS Very fast  No recursion, no calculations Still need frustum culling Difficult to calculate  Intersection of volumes and portals  Lots of tests – very slow Most useful when combined with other partitioning schemes

Volume Partitioning Different methods for different things Quadtree/octree for outdoor views  Does frustum culling well  Hard to cull much more for outdoor views Portals or BSP for indoor scenes BSP or quadtree for collision detection  Portals not suitable

Rendering Primitives Strips, Lists, Fans Indexed Primitives The Vertex Cache Quads and Point Sprites

Strips, Lists, Fans Triangle list Triangle fan Triangle strip Line list Line strip

Vertex Sharing List has no sharing  Vertex count = triangle count * 3 Strips and fans share adjacent vertices  Vertex count = triangle count + 2  Lower memory  Topology restrictions  Have to break into multiple rendering calls

Vertex Counts Using lists duplicates vertices a lot!  Total of 6x number of rendering vertices  Most meshes: tri count = 2x vert count Strips or fans still duplicate vertices  Each strip/fan needs its own set of vertices  More than doubles vertex count Typically 2.5x with good strips  Hard to find optimal strips and fans  Have to submit each as separate rendering call

Strips vs. Lists 32 triangles, 25 vertices4 strips, 40 vertices 25 to 40 vertices is 60% extra data!

Indexed Primitives Vertices stored in separate array  No duplication of vertices  Called a “vertex buffer” or “vertex array”  3 numbers (int/float/double) per vertex Triangles hold indices, not vertices Index is just an integer  Typically 16 bits (65,536)  Duplicating indices is cheap  Indexes into vertex array

Vertex Index Array

The Vertex Cache Vertices processed by vertex shader Results used by multiple triangles Avoid re-running shader for each triangle Storing results in video memory is slow So store results in small cache  Requires indexed primitives  Cache typically vertices in size, resulted in around 95% efficiency

Cache Performance Size and type of cache usually unknown  LRU (least recently used) or FIFO (first in first out) replacement policy  Also odd variants of FIFO policy  Variable cache size according to vertex type Reorder triangles to be cache-friendly  Not the same as finding optimal strips!  Render nearby triangles together  “Fairly good” is easy to achieve  Ideal ordering still a subject for research