SlideShare une entreprise Scribd logo
1  sur  12
VERTEX RENDERING
1
2014WHAT ARE VERTICES ?
 Vertices –
 Points defined in a specific coordinate axes, to represent 3D geometry
 Atleast 3 vertices are used to define a Triangle – one of the primitives supported by
GLES
Where from ?
2014VERTEX BASICS
 Where do vertices come from ?
 Output of Modelling tools
 Mesh rendering / transforms – optimisations
 For 2D operations (ex Window systems), just 2 triangles
Depth Complexity
2014DEPTH-COMPLEXITY
 # of times same area rendered
 Ideal ~ 1
 > 1, higher complexity
 Goal is to reduce Depth-Complexity
4
Overlapping region
Summary of vertex ops
2014VERTEX OPERATIONS
 Vertex operations are floating point intensive matrix operations - reciprocals, square-roots
 Conversion to Triangles (not needed in OpenGL ES)
 Sorting
 Clipping
 Transformation/ Scale
 Perspective
 Vertex Shaders
 Scan conversion
 Edge walk
 Interpolation
 Followed by Pixel Operations
5
Attributes
2014VERTEX ATTRIBUTES
 A vertex is characterised by its position {x,y,z}
 {x,y,z} are floating point values
 Additionally, normals are required for directional lighting calculations in shader
 Vertex normal, Face normal - Description
 3D Tools output the normal map also along with vertex information
 Additionally, texture coordinates are required
 Again, 3D tools output the texture coordinates
 Each HW implementation must support a minimum number of vertex attributes
 Maximum number can be queried using MAX_VERTEX_ATTRIBS
CPU to GPU xfer
2014VERTICES – CPU TO GPU
 Optimising Vertex operations
 A 3D object will have a lot of “common” vertices
 Ex – Cube has 6*2 triangles, (6*2)*3 vertices, but only 8 “points”
 So rather than passing vertices, pass 8 vertices, and 36 indices to the vertices to
reduce Bandwidth
 Indices can be 16bit, so reduce BW by ~50%
 GL_ARRAY_BUFFER (vertices), GL_ELEMENT_ARRAY_BUFFER (index)
 STATIC_DRAW, DYNAMIC_DRAW
 Tip: Re-use by binding
 What are Vertex Buffer Objects ?
 genBuffers (createBuffer in WebGL), binding, bufferData/offset and usage
 Usage of Index Buffers (ELEMENT_ARRAY_BUFFER) Objects
2014A NOTE ON BINDING, BUFFER OBJECTS
 What is “Binding” ?
 Binding a server to a client – ex, VBO to a texture
 All objects are associated with a context state
 Binding an object is ~ copying the object state  context
 Removes clientserver movement everytime
 “Xfer-once-to-server, keep the token, Use-multipletimes-later”
 Good practice to “unbind” after operations– set binding to 0/null to avoid rogue
programs changing state of bound object
 Buffer-Objects
 Allows data to be stored on the “server” ie, the GPU memory, rather than client
memory (via pointer)
 GPU can decide where to place it for the fastest performance
Lab
WITH AND WITHOUT VBO
 Without VBO
 ARRAY_BUFFER and
ELEMENT_ARRAY_BUFFER
used, in glBindBuffer()
 Vertices and Attributes uploaded
individually as buffers via
 glEnableVertexAttribArray()
 glVertexAttribPointer()
 Drawn via
 glDrawElements
 pointer to index buffer passed
 CPU-GPU data transfer happens every draw
 With VBO
 ARRAY_BUFFER and
ELEMENT_ARRAY_BUFFER
used, in glBindBuffer()
 Vertices and Attributes uploaded
individually via
 glBufferData()
 Attributes specified only by offsets in buffer
 glVertexAttribPointer takes in only offset
 Drawn via
 glDrawElements()
 No pointer passed here
 Hint to GL via “GL_STATIC_DRAW” or
similar
9
2014STRIDE SPECIFICATION
 Stride can be specified as ‘0’, in which case the GL Engine automatically
calculates required stride corresponding to the type specified for the attribute
10
2014PROGRAMMING !
 Recall the Bandwidth needs for the vertex transfers /
frame
 Passing Vertices
 Create Buffer Object
 bindBuffer
 bufferData
 Indices are passed as type ELEMENT_ARRAY
 Passing Attributes
 bindAttribLocation
 enableVertexAttribArray
 vertexAttribPointer
 Render
 DrawElements
 Lab – Point Cloud
2014LAB L3 – POINT CLOUD IN VIEWPORT
12

Contenu connexe

Tendances

OpenGL ES on Android
OpenGL ES on AndroidOpenGL ES on Android
OpenGL ES on Android
Chris Farrell
 

Tendances (20)

VMworld 2013: On the Way to GPU Virtualization – 3D Acceleration in Virtual M...
VMworld 2013: On the Way to GPU Virtualization – 3D Acceleration in Virtual M...VMworld 2013: On the Way to GPU Virtualization – 3D Acceleration in Virtual M...
VMworld 2013: On the Way to GPU Virtualization – 3D Acceleration in Virtual M...
 
GFX Part 4 - Introduction to Texturing in OpenGL ES
GFX Part 4 - Introduction to Texturing in OpenGL ESGFX Part 4 - Introduction to Texturing in OpenGL ES
GFX Part 4 - Introduction to Texturing in OpenGL ES
 
Look Ma, No Jutter! Optimizing Performance Across Oculus Mobile
Look Ma, No Jutter! Optimizing Performance Across Oculus MobileLook Ma, No Jutter! Optimizing Performance Across Oculus Mobile
Look Ma, No Jutter! Optimizing Performance Across Oculus Mobile
 
OpenGL ES based UI Development on TI Platforms
OpenGL ES based UI Development on TI PlatformsOpenGL ES based UI Development on TI Platforms
OpenGL ES based UI Development on TI Platforms
 
NVIDIA OpenGL in 2016
NVIDIA OpenGL in 2016NVIDIA OpenGL in 2016
NVIDIA OpenGL in 2016
 
Virtual Reality Features of NVIDIA GPUs
Virtual Reality Features of NVIDIA GPUsVirtual Reality Features of NVIDIA GPUs
Virtual Reality Features of NVIDIA GPUs
 
Gl efficiency
Gl efficiencyGl efficiency
Gl efficiency
 
Learn how to do stylized shading with Shader Graph – Unite Copenhagen 2019
Learn how to do stylized shading with Shader Graph – Unite Copenhagen 2019Learn how to do stylized shading with Shader Graph – Unite Copenhagen 2019
Learn how to do stylized shading with Shader Graph – Unite Copenhagen 2019
 
OpenGL ES Presentation
OpenGL ES PresentationOpenGL ES Presentation
OpenGL ES Presentation
 
CS 354 Introduction
CS 354 IntroductionCS 354 Introduction
CS 354 Introduction
 
Holy smoke! Faster Particle Rendering using Direct Compute by Gareth Thomas
Holy smoke! Faster Particle Rendering using Direct Compute by Gareth ThomasHoly smoke! Faster Particle Rendering using Direct Compute by Gareth Thomas
Holy smoke! Faster Particle Rendering using Direct Compute by Gareth Thomas
 
CS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingCS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and Culling
 
[Unite Seoul 2020] Mobile Graphics Best Practices for Artists
[Unite Seoul 2020] Mobile Graphics Best Practices for Artists[Unite Seoul 2020] Mobile Graphics Best Practices for Artists
[Unite Seoul 2020] Mobile Graphics Best Practices for Artists
 
GTC 2012: GPU-Accelerated Path Rendering
GTC 2012: GPU-Accelerated Path RenderingGTC 2012: GPU-Accelerated Path Rendering
GTC 2012: GPU-Accelerated Path Rendering
 
GDC 2012: Advanced Procedural Rendering in DX11
GDC 2012: Advanced Procedural Rendering in DX11GDC 2012: Advanced Procedural Rendering in DX11
GDC 2012: Advanced Procedural Rendering in DX11
 
OpenGL ES on Android
OpenGL ES on AndroidOpenGL ES on Android
OpenGL ES on Android
 
OpenGL Interaction
OpenGL InteractionOpenGL Interaction
OpenGL Interaction
 
SIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and Beyond
SIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and BeyondSIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and Beyond
SIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and Beyond
 
Slides: Accelerating Vector Graphics Rendering using the Graphics Hardware Pi...
Slides: Accelerating Vector Graphics Rendering using the Graphics Hardware Pi...Slides: Accelerating Vector Graphics Rendering using the Graphics Hardware Pi...
Slides: Accelerating Vector Graphics Rendering using the Graphics Hardware Pi...
 
[TGDF 2020] Mobile Graphics Best Practices for Artist
[TGDF 2020] Mobile Graphics Best Practices for Artist[TGDF 2020] Mobile Graphics Best Practices for Artist
[TGDF 2020] Mobile Graphics Best Practices for Artist
 

Similaire à GFX Part 3 - Vertices and interactions in OpenGL

Similaire à GFX Part 3 - Vertices and interactions in OpenGL (20)

Graphics programming in open gl
Graphics programming in open glGraphics programming in open gl
Graphics programming in open gl
 
Making High Quality Interactive VR with Unreal Engine Luis Cataldi
Making High Quality Interactive VR with Unreal Engine Luis CataldiMaking High Quality Interactive VR with Unreal Engine Luis Cataldi
Making High Quality Interactive VR with Unreal Engine Luis Cataldi
 
Making High Quality Interactive VR with Unreal Engine Luis Cataldi
Making High Quality Interactive VR with Unreal Engine Luis CataldiMaking High Quality Interactive VR with Unreal Engine Luis Cataldi
Making High Quality Interactive VR with Unreal Engine Luis Cataldi
 
OpenGLES Android Graphics
OpenGLES Android GraphicsOpenGLES Android Graphics
OpenGLES Android Graphics
 
Accelerating Spark MLlib and DataFrame with Vector Processor “SX-Aurora TSUBASA”
Accelerating Spark MLlib and DataFrame with Vector Processor “SX-Aurora TSUBASA”Accelerating Spark MLlib and DataFrame with Vector Processor “SX-Aurora TSUBASA”
Accelerating Spark MLlib and DataFrame with Vector Processor “SX-Aurora TSUBASA”
 
“How Transformers are Changing the Direction of Deep Learning Architectures,”...
“How Transformers are Changing the Direction of Deep Learning Architectures,”...“How Transformers are Changing the Direction of Deep Learning Architectures,”...
“How Transformers are Changing the Direction of Deep Learning Architectures,”...
 
Point cloud mesh-investigation_report-lihang
Point cloud mesh-investigation_report-lihangPoint cloud mesh-investigation_report-lihang
Point cloud mesh-investigation_report-lihang
 
VMUGIT UC 2013 - 04 Duncan Epping
VMUGIT UC 2013 - 04 Duncan EppingVMUGIT UC 2013 - 04 Duncan Epping
VMUGIT UC 2013 - 04 Duncan Epping
 
ShaderX³: Geometry Manipulation - Morphing between two different objects
ShaderX³: Geometry Manipulation - Morphing between two different objectsShaderX³: Geometry Manipulation - Morphing between two different objects
ShaderX³: Geometry Manipulation - Morphing between two different objects
 
OSGi Cloud Ecosystems (OSGi Users Forum Germany)
OSGi Cloud Ecosystems (OSGi Users Forum Germany)OSGi Cloud Ecosystems (OSGi Users Forum Germany)
OSGi Cloud Ecosystems (OSGi Users Forum Germany)
 
Building stateful serverless orchestrations with Azure Durable Azure Function...
Building stateful serverless orchestrations with Azure Durable Azure Function...Building stateful serverless orchestrations with Azure Durable Azure Function...
Building stateful serverless orchestrations with Azure Durable Azure Function...
 
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...
 
Building Reactive Microservices with Vert.x
Building Reactive Microservices with Vert.xBuilding Reactive Microservices with Vert.x
Building Reactive Microservices with Vert.x
 
Shadow Volumes on Programmable Graphics Hardware
Shadow Volumes on Programmable Graphics HardwareShadow Volumes on Programmable Graphics Hardware
Shadow Volumes on Programmable Graphics Hardware
 
Tez Data Processing over Yarn
Tez Data Processing over YarnTez Data Processing over Yarn
Tez Data Processing over Yarn
 
Greg Hogan – To Petascale and Beyond- Apache Flink in the Clouds
Greg Hogan – To Petascale and Beyond- Apache Flink in the CloudsGreg Hogan – To Petascale and Beyond- Apache Flink in the Clouds
Greg Hogan – To Petascale and Beyond- Apache Flink in the Clouds
 
Advanced Scenegraph Rendering Pipeline
Advanced Scenegraph Rendering PipelineAdvanced Scenegraph Rendering Pipeline
Advanced Scenegraph Rendering Pipeline
 
GPU - how can we use it?
GPU - how can we use it?GPU - how can we use it?
GPU - how can we use it?
 
Introduction of openGL
Introduction  of openGLIntroduction  of openGL
Introduction of openGL
 
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
 

Plus de Prabindh Sundareson

Plus de Prabindh Sundareson (20)

Synthetic Data and Graphics Techniques in Robotics
Synthetic Data and Graphics Techniques in RoboticsSynthetic Data and Graphics Techniques in Robotics
Synthetic Data and Graphics Techniques in Robotics
 
Work and Life
Work and Life Work and Life
Work and Life
 
GPU Algorithms and trends 2018
GPU Algorithms and trends 2018GPU Algorithms and trends 2018
GPU Algorithms and trends 2018
 
Machine learning in the Indian Context - IEEE talk at SRM Institute
Machine learning in the Indian Context - IEEE talk at SRM InstituteMachine learning in the Indian Context - IEEE talk at SRM Institute
Machine learning in the Indian Context - IEEE talk at SRM Institute
 
Students Hackathon - 2017
Students Hackathon - 2017Students Hackathon - 2017
Students Hackathon - 2017
 
ICCE Asia 2017 - Program Outline
ICCE Asia 2017 - Program OutlineICCE Asia 2017 - Program Outline
ICCE Asia 2017 - Program Outline
 
Call for Papers - ICCE Asia 2017
Call for Papers - ICCE Asia 2017Call for Papers - ICCE Asia 2017
Call for Papers - ICCE Asia 2017
 
Technology, Innovation - A Perspective
Technology, Innovation - A PerspectiveTechnology, Innovation - A Perspective
Technology, Innovation - A Perspective
 
Open Shading Language (OSL)
Open Shading Language (OSL)Open Shading Language (OSL)
Open Shading Language (OSL)
 
IEEE - Consumer Electronics Trends Opportunities (2015)
IEEE - Consumer Electronics Trends Opportunities (2015)IEEE - Consumer Electronics Trends Opportunities (2015)
IEEE - Consumer Electronics Trends Opportunities (2015)
 
John Carmack talk at SMU, April 2014 - Virtual Reality
John Carmack talk at SMU, April 2014 - Virtual RealityJohn Carmack talk at SMU, April 2014 - Virtual Reality
John Carmack talk at SMU, April 2014 - Virtual Reality
 
GFX2014 OpenGL ES Quiz
GFX2014 OpenGL ES QuizGFX2014 OpenGL ES Quiz
GFX2014 OpenGL ES Quiz
 
Gfx2014 Graphics Workshop - Lab manual
Gfx2014 Graphics Workshop - Lab manualGfx2014 Graphics Workshop - Lab manual
Gfx2014 Graphics Workshop - Lab manual
 
Render to Texture with Three.js
Render to Texture with Three.jsRender to Texture with Three.js
Render to Texture with Three.js
 
ANGLE on Windows for OpenGLES2.0
ANGLE on Windows for OpenGLES2.0ANGLE on Windows for OpenGLES2.0
ANGLE on Windows for OpenGLES2.0
 
Yocto usage for Graphics SDK on AM335x
Yocto usage for Graphics SDK on AM335xYocto usage for Graphics SDK on AM335x
Yocto usage for Graphics SDK on AM335x
 
Gfx2013 lab manual
Gfx2013 lab manualGfx2013 lab manual
Gfx2013 lab manual
 
ARM Linux Embedded memory protection techniques
ARM Linux Embedded memory protection techniquesARM Linux Embedded memory protection techniques
ARM Linux Embedded memory protection techniques
 
Qt5 (minimal) on beaglebone, with Yocto
Qt5 (minimal) on beaglebone, with YoctoQt5 (minimal) on beaglebone, with Yocto
Qt5 (minimal) on beaglebone, with Yocto
 
Moksha - HTML5/CSS with Qt5+Snowshoe on AM335x
Moksha - HTML5/CSS with Qt5+Snowshoe on AM335xMoksha - HTML5/CSS with Qt5+Snowshoe on AM335x
Moksha - HTML5/CSS with Qt5+Snowshoe on AM335x
 

Dernier

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Dernier (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

GFX Part 3 - Vertices and interactions in OpenGL

  • 2. 2014WHAT ARE VERTICES ?  Vertices –  Points defined in a specific coordinate axes, to represent 3D geometry  Atleast 3 vertices are used to define a Triangle – one of the primitives supported by GLES Where from ?
  • 3. 2014VERTEX BASICS  Where do vertices come from ?  Output of Modelling tools  Mesh rendering / transforms – optimisations  For 2D operations (ex Window systems), just 2 triangles Depth Complexity
  • 4. 2014DEPTH-COMPLEXITY  # of times same area rendered  Ideal ~ 1  > 1, higher complexity  Goal is to reduce Depth-Complexity 4 Overlapping region Summary of vertex ops
  • 5. 2014VERTEX OPERATIONS  Vertex operations are floating point intensive matrix operations - reciprocals, square-roots  Conversion to Triangles (not needed in OpenGL ES)  Sorting  Clipping  Transformation/ Scale  Perspective  Vertex Shaders  Scan conversion  Edge walk  Interpolation  Followed by Pixel Operations 5 Attributes
  • 6. 2014VERTEX ATTRIBUTES  A vertex is characterised by its position {x,y,z}  {x,y,z} are floating point values  Additionally, normals are required for directional lighting calculations in shader  Vertex normal, Face normal - Description  3D Tools output the normal map also along with vertex information  Additionally, texture coordinates are required  Again, 3D tools output the texture coordinates  Each HW implementation must support a minimum number of vertex attributes  Maximum number can be queried using MAX_VERTEX_ATTRIBS CPU to GPU xfer
  • 7. 2014VERTICES – CPU TO GPU  Optimising Vertex operations  A 3D object will have a lot of “common” vertices  Ex – Cube has 6*2 triangles, (6*2)*3 vertices, but only 8 “points”  So rather than passing vertices, pass 8 vertices, and 36 indices to the vertices to reduce Bandwidth  Indices can be 16bit, so reduce BW by ~50%  GL_ARRAY_BUFFER (vertices), GL_ELEMENT_ARRAY_BUFFER (index)  STATIC_DRAW, DYNAMIC_DRAW  Tip: Re-use by binding  What are Vertex Buffer Objects ?  genBuffers (createBuffer in WebGL), binding, bufferData/offset and usage  Usage of Index Buffers (ELEMENT_ARRAY_BUFFER) Objects
  • 8. 2014A NOTE ON BINDING, BUFFER OBJECTS  What is “Binding” ?  Binding a server to a client – ex, VBO to a texture  All objects are associated with a context state  Binding an object is ~ copying the object state  context  Removes clientserver movement everytime  “Xfer-once-to-server, keep the token, Use-multipletimes-later”  Good practice to “unbind” after operations– set binding to 0/null to avoid rogue programs changing state of bound object  Buffer-Objects  Allows data to be stored on the “server” ie, the GPU memory, rather than client memory (via pointer)  GPU can decide where to place it for the fastest performance Lab
  • 9. WITH AND WITHOUT VBO  Without VBO  ARRAY_BUFFER and ELEMENT_ARRAY_BUFFER used, in glBindBuffer()  Vertices and Attributes uploaded individually as buffers via  glEnableVertexAttribArray()  glVertexAttribPointer()  Drawn via  glDrawElements  pointer to index buffer passed  CPU-GPU data transfer happens every draw  With VBO  ARRAY_BUFFER and ELEMENT_ARRAY_BUFFER used, in glBindBuffer()  Vertices and Attributes uploaded individually via  glBufferData()  Attributes specified only by offsets in buffer  glVertexAttribPointer takes in only offset  Drawn via  glDrawElements()  No pointer passed here  Hint to GL via “GL_STATIC_DRAW” or similar 9
  • 10. 2014STRIDE SPECIFICATION  Stride can be specified as ‘0’, in which case the GL Engine automatically calculates required stride corresponding to the type specified for the attribute 10
  • 11. 2014PROGRAMMING !  Recall the Bandwidth needs for the vertex transfers / frame  Passing Vertices  Create Buffer Object  bindBuffer  bufferData  Indices are passed as type ELEMENT_ARRAY  Passing Attributes  bindAttribLocation  enableVertexAttribArray  vertexAttribPointer  Render  DrawElements  Lab – Point Cloud
  • 12. 2014LAB L3 – POINT CLOUD IN VIEWPORT 12