Computer Graphics Index Buffers

Slides:



Advertisements
Similar presentations
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 1/16 Deferred Lighting Deferred Lighting – 11/18/2014.
Advertisements

Status – Week 257 Victor Moya. Summary GPU interface. GPU interface. GPU state. GPU state. API/Driver State. API/Driver State. Driver/CPU Proxy. Driver/CPU.
Random access memory Sequential circuits all depend upon the presence of memory. A flip-flop can store one bit of information. A register can store a single.
 The success of GL lead to OpenGL (1992), a platform-independent API that was  Easy to use  Close enough to the hardware to get excellent performance.
Meshes Dr. Scott Schaefer. 3D Surfaces Vertex Table.
Computer System Overview
CSE 381 – Advanced Game Programming Basic 3D Graphics
4.7. I NSTANCING Introduction to geometry instancing.
CMPE 421 Parallel Computer Architecture
Mesh Data Structure. Meshes Boundary edge: adjacent to 1 face Regular edge: adjacent to 2 faces Singular edge: adjacent to >2 faces Mesh: straight-line.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
Computer Graphics Basic 3D Geometry CO2409 Computer Graphics Week 5-1.
1 How will execution time grow with SIZE? int array[SIZE]; int sum = 0; for (int i = 0 ; i < ; ++ i) { for (int j = 0 ; j < SIZE ; ++ j) { sum +=
Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2.
CSCE 552 Spring D Models By Jijun Tang. Triangles Fundamental primitive of pipelines  Everything else constructed from them  (except lines and.
Graph.
CE Operating Systems Lecture 17 File systems – interface and implementation.
1 Building Models Ed Angel Professor Emeritus of Computer Science University of New Mexico Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley.
© GCSE Computing Computing Hardware Starter. Creating a spreadsheet to demonstrate the size of memory. 1 byte = 1 character or about 1 pixel of information.
1 OGRE Programming Intermediate Tutorial: Volume Selection.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
Maths & Technologies for Games Graphics Optimisation - Batching CO3303 Week 5.
Computer Graphics Matrices
A study of efficiency INDEX BUFFERS JEFF CHASTINE 1.
Our Graphics Environment Landscape Rendering. Hardware  CPU  Modern CPUs are multicore processors  User programs can run at the same time as other.
How to use a Pixel Shader CMT3317. Pixel shaders There is NO requirement to use a pixel shader for the coursework though you can if you want to You should.
A novel approach to visualizing dark matter simulations
Pushin’ Geo to the GPU As well as colors, normals, and other vertex data Made by Jeff Chastine, Modified by Chao Mei Jeff Chastine.
Memory Hierarchy Ideal memory is fast, large, and inexpensive
Jonathan Walpole Computer Science Portland State University
CE 454 Computer Architecture
Random access memory Sequential circuits all depend upon the presence of memory. A flip-flop can store one bit of information. A register can store a single.
Real-Time Rendering Buffers in OpenGL 3.3
Ramya Kandasamy CS 147 Section 3
How will execution time grow with SIZE?
Random access memory Sequential circuits all depend upon the presence of memory. A flip-flop can store one bit of information. A register can store a single.
Deferred Lighting.
Real-Time Rendering Geometry and Buffers
Introduction to OpenGL
Cache Memory Presentation I
Review Graph Directed Graph Undirected Graph Sub-Graph
Arrays, For loop While loop Do while loop
File Handling Programming Guides.
Chapter 2: System Structures
Chapter VI OpenGL ES and Shader
Subtraction The arithmetic we did so far was limited to unsigned (positive) integers. Today we’ll consider negative numbers and subtraction. The main problem.
Building Models Ed Angel Professor Emeritus of Computer Science
Meshes.
Chapter III Modeling.
Fundamentals of Data Structures
Introduction to geometry instancing
1.1 The Characteristics of Contemporary Processors, Input, Output and Storage Devices Types of Processors.
How can we find data in the cache?
Clusters, Sectors, and Files
Recall: ROM example Here are three functions, V2V1V0, implemented with an 8 x 3 ROM. Blue crosses (X) indicate connections between decoder outputs and.
Computer Graphics Practical Lesson 8
Random access memory Sequential circuits all depend upon the presence of memory. A flip-flop can store one bit of information. A register can store a single.
Loops and Arrays in JavaScript
Computer Graphics Introduction to Shaders
ECE 352 Digital System Fundamentals
03 | Creating, Texturing and Moving Objects
Introduction to OpenGL
ECE 352 Digital System Fundamentals
Registers Today we’ll see some common sequential devices: counters and registers. They’re good examples of sequential analysis and design. They are also.
Advance Database System
Mickaël Sereno Graphics Memory Mickaël Sereno 11/07/2019 Mickaël Sereno -
Concepts of Computation
Memory Management & Virtual Memory
Opengl implementation
Presentation transcript:

Computer Graphics Index Buffers CO2409 Computer Graphics Week 9

Contents Vertex Buffers / Duplication Duplication with Lists and Strips Introducing Index Buffers

Vertex Buffers / Duplication So far we have typed in vertex data in C++ (CPU data) [We will load from files shortly, but the point is the same] Each triplet of vertices has represented a triangle… …but this has lead to vertex duplication For example, a cube needed 36 vertices rather than expected 8 Duplicate vertices affect efficiency: A vertex is at least three floats (X,Y,Z) – say 12 bytes Usually more, around 32-48 bytes (we will see why later) So duplication wastes memory Main RAM – our vertex array. Video card RAM – vertex buffer Video card (GPU) may perform redundant processing on these additional vertices

Vertex Buffers One triangle in a C++ vertex lists has looked like this: … D3DXVECTOR3(-0.5, 0.5,0.5),D3DXVECTOR4(1.0,1.0,0.0,0),// Position(xyz)… D3DXVECTOR3(-0.5,-0.5,0.5),D3DXVECTOR4(0.0,1.0,1.0,0),// …& colour(RGBA) D3DXVECTOR3( 0.5,-0.5,0.5),D3DXVECTOR4(0.0,1.0,0.0,0),// …for each vertex When grouped into triplets like this, it is a triangle list This C++ array is stored in CPU-local memory The DirectX code copies the data to GPU-local memory to allow efficient rendering [GPU = Graphics Processing Unit, a CPU for graphics] A block of vertices in GPU-memory is a Vertex Buffer Same layout as list above, just in different memory Access from C++ code to vertex buffer data is limited

Vertex Buffers / Triangle Lists Consider how duplication occurs in a triangle list: Each triangle represented by a triplet of vertices No sharing of vertices possible in this layout Vertices that occur in multiple triangles must be duplicated: In this simple example there is already 50% duplication A larger model may store 6 copies of each vertex 6 times more memory and processing than necessary Triangle List Geometry Vertex 0 Vertex 1 Vertex 2 Vertex 3 2 Triangles 4 Vertices Need 6 Vertices in list

Vertex Buffers / Triangle Strips Can reduce duplication by using triangle strips Just a reordering of the vertex data: First triangle is as normal – a triplet of vertices Each subsequent triangle adds one new vertex and reuses the last 2 Need to specify to API if using this different topology Clearly a benefit, but requires careful ordering of triangles Still get vertex duplication along strip edges: 3 duplicates here Larger models typically duplicate each vertex once Not yet ideal 1 2 3 4 5 1 6 3 7 5 8 Strip 1 Strip 2

Two triangle list with indexes Index Buffers An index buffer is just an array of integers They index the vertex buffer Define triangles using triplets of indexes (indices) This is for a triangle list Similar process for a strip Only store each vertex once Duplicate indexes, not vertices Index Buffer Vertex Buffer 1 2 3 Vertex 0 Vertex 1 Vertex 2 Vertex 3 Two triangle list with indexes No vertex duplication Indexes are integers – 2 or 4 bytes only If indexes are duplicated it is not as wasteful as duplicating a vertex (remember a typical vertex will be around 32-48 bytes)

Example Use of Buffers A square using a vertex buffer only { 5, 0, 5, 0xff00ff00 }, // Triangle 1 { 5, 10, 5, 0xffffff00 }, { 15, 0, 5, 0xff00ff00 }, { 5, 10, 5, 0xffffff00 }, // Triangle 2 { 15, 10, 5, 0xffffff00 }, Using an index buffer { 5, 0, 5, 0xff00ff00 }, // Vertex Buffer // Index Buffer { 0, 1, 2, // Triangle 1 1, 2, 3 } // Triangle 2

Using Index Buffers Most applications use index buffers In DirectX: Create our own an array of integers Ask DirectX to create a index buffer & copy data into it Similar process to that of a vertex buffer For rendering we use the function DrawIndexed Instead of Draw Two independent choices to store geometry: Store triangles in a list or a strip Use just vertices, or vertices & indexes

Vertex Caching Index buffers & triangle strips reduce data storage What about data processing? Given two triangles sharing a vertex, does the GPU process this vertex twice? No – the GPU has a cache of recently used vertices Given a vertex it has seen recently, it uses the previous result So we should order triangles to put adjacent ones together Triangle strips are naturally ordered this way But triangle lists can be reordered for similar benefit Almost negates the value of triangle strips A well-ordered list has close performance to a strip, but is simpler to set up and understand