SlideShare a Scribd company logo
Shadow Volumes on Programmable Graphics Hardware Stefan Brabec Hans-Peter Seidel MPI Informatik
Overview Shadow Volumes Silhouette Generation in Hardware Motivation Our method Results Conclusion & Future Work
Shadow Volumes [Crow77]   Shadow algorithms for computer graphics  Compute regions of shadow in 3D Object-space algorithm Per-pixel correct shadow information Cast shadows onto arbitrary receiver geometry
Shadow Volumes Extend occluder polygons to form  semi-infinite volumes Light source is  center-of-projection Everything behind occluder is in shadow occluder light shadow region lit
Shadow Volume Generation Trivial way One volume for each polygon Better Silhouette-based approach Need to check each edge with each light !
Shadow Volume Generation An edge is a silhouette edge if it is an edge shared by a  front-facing   and   back-facing  triangle/polygon Light Light FF BF FF FF Silhouette Edge (v0,v1) ! No Silhouette Edge ! n 1 n 2 n 1 n 2
Shadow Volume Rendering Stencil-based shadow volumes [Heidmann ‘91]  Real shadows real time count  in-out  events using the stencil buffer
Shadow Volume Rendering Number of problems  near/far clipping plane  fill rate non-closed volumes See work from Everitt/Kilgard ! silhouette detection   Focus of this talk:
Motivation From some OpenGL discussion forum:
Motivation Silhouette detection is not trivial  for complex vertex shaders
Our method Use graphics hardware to compute silhouettes State-of-the-art hardware allows  computation in  object space Floating point calculations Floating point textures Powerful, programmable vertex and fragment processing units
Input Data Supported meshes Closed objects (no open edges) Two triangles meet at one edge Example: This is  not  a closed mesh, but since we are only focusing on one edge of this mesh its ok.
Coordinate Transformation First step Need to transform all geometry to a global coordinate system Also need all light sources in this system Common choices World space  View-independent Eye Space View-dependent  ok for fully dynamic scenes with moving viewer Object Space Need to transform light sources to this space (done by most CPU approaches)
Transform to world/eye space Unique identifier per vertex Transform each vertex to world/eye space render mesh as points Store position at index slot P 0 P 1 P 2 P 3 P 4 position texture P 0 P 1 P 2 P 3 P 4 P N
Transform to world/eye space Vertex program for transform / index store Simple for standard modelview transformation More complex programs modified by  simple  source-to-source  code transformation Eliminate code relevant for additional attributes (color, texcoords, etc.) Replace output position register by attribute register result.position  ->  result.texcoord[0] Add code to move vertex index to output position MOV  result.position, vertex.texcoord[..]; !!ARBvp1.0 ATTRIB  iVertexPos  = vertex.position; ATTRIB  iVertexIdx  = vertex.texcoord[0]; PARAM   mv[4]  = { state.matrix.modelview }; OUTPUT  oPos  = result.position; OUTPUT  oDumpPos  = result.texcoord[0]; # Transform the vertex to eye coordinates .   DP4   oDumpPos.x, mv[0], iVertexPos; DP4   oDumpPos.y, mv[1], iVertexPos; DP4   oDumpPos.z, mv[2], iVertexPos; DP4   oDumpPos.w, mv[3], iVertexPos; # Vertex position is its index (x,y,0,1) MOV   oPos, iVertexIdx; END
Transform to world/eye space Storing the result Need full floating point precission RGBA float textures (RGBA = x,y,z,w) One global texture to store  all  positions Index numbering is pre-processing step Multiple instances of the same object need separate index slots (use index offset) Use per-object culling (in light view) to reduce number of vertices  Mapping indices to 2D (idx % width, idx / width) overcomes texture size limitation  1D: 2048 vertices 2D: over 4M vertices ! (max 2D texture size 2048x2048)
Process edges Mesh connectivity is known Computed in pre-processing step Each edge has unique identifier (index) Two vertices for the edge Two vertices for  adjacent triangles
Process edges Render point for each edge Edge index defines output position Assign four vertex indices as attributes E 0_idx P 0_idx P 1_idx P 3_idx P 4_idx glBegin(GL_POINTS) ; glAttrib(P0_idx, P3_idx,  P1_idx, P4_idx); glVertex1f(E0_idx); glEnd();
Process Edges Vertex shader Not needed during this stage (pass-through all attributes) Fragment shader Used to compute silhouette flag Position of light sources as global parameters Use position texture of previous pass
Process edges Fragment shader E 0_idx P 0_idx P 1_idx P 3_idx P 4_idx input data 4 texture lookups for  world space positions P 0 P 1 P 3 P 4 registers P 3 P 0 P 1 P 4 N 1  = (P 3 –P 0 )x(P 1 –P 0 ) N 2  = (P 4 –P 0 )x(P 3 –P 0 ) front & back  facing ? position texture P 0 P 1 P 2 P 3 P 4 Light Store silhouette flag (yes/no) at edge index E 0 E 1 E 2 E 3 E 4 E M edge texture
Silhouette Detection What we’ve got so far One texture holding all world/eye space position (w*h = #vertices) One texture holding all silhouette flags for the edges (w*h = #edges) There’s also an additional flag (bit) for the vertex ordering (please see paper for details) Next step Use this information to extrude & render shadow volumes
Rendering Shadow Volumes Basic algorithm for all lights  { for all edges  { if (is silhouette edge for light i) { get edge’s vertices  render extruded quad  } } }
Rendering shadow volumes Vertex shader & tex lookup Best solution, but not (yet) supported Read back textures Trivial solution, but not very fast position texture P 0 P 1 P 2 P 3 P 4 P N E 0 E 1 E 2 E 3 E 4 E M edge texture glBegin(GL_QUADS) ; glVertex(P0_idx, E0_idx, 0); glVertex(P1_idx, E0_idx, 0); glVertex(P1_idx, E0_idx, 1); glVertex(P0_idx, E0_idx, 1); P =  Lookup (p_idx) mask =  Lookup (e_idx) if (mask & silhouette) { if (extrude)  // 0 or 1 flag out = P – Light_pos else out = P }  else  { out = (0,0,0,1)  // outside view   }
Rendering shadow volumes Better: keep all data on the card ! Instead of storing edge flags, store all quad information  E 0 =  silhouette quad texture E` 0 =  silhouette &    extrude P 0 L P 3 P 0- L P 3- L Q 0 Q 1 Q 2 Q 3 Q 0  = (P 0x ,P 0y ,P 0z , E 0 ) Q 1  = (P 3x ,P 3y ,P 3z , E 0 ) Q 2  = (P 3x ,P 3y ,P 3z , E` 0 ) Q 3  = (P 0x ,P 0y ,P 0z , E` 0 )
Rendering Shadow Volumes Quad texture Instead of rendering one point per edge, render 4 points (line, 2x2 point)  XYZ-components used for world space  position (edge vertices) W-component  for silhouette/extrude flag Can be used as bitmask  (number of lights)  Light0: Silhouette Light0: Extrude  Light1: Silhouette Light1: Extrude
Rendering Shadow Volumes Quad texture used as vertex array Vertex Array: glBegin(GL_QUADS) ; glArrayElement(0); glArrayElement(1); glArrayElement(2); glArrayElement(3); P_xyz = IN_xyz; E = IN_w; if(E & silhouette) { if(E & extrude) out = P-L; else out = P; } else { out = somewhere outside view } Q 0 Q 1 Q 2 Q 3
Rendering Shadow Volumes Problem: Information stored as texture image Need information in vertex path Solution: New OpenGL extension  ARB_superbuffers allows more generic memory objects
ARB_superbuffers General purpose memory objects Use the same memory object in different parts of the pipeline as a texture as a vertex array as a render target glVertexArrayMem ( GL_VERTEX_ARRAY,    4,  mem, 0); memory block glAttachMem ( GL_DRAW_FRAMEBUFFER,  GL_AUX0, mem); glAttachMem ( GL_TEXTURE_2D,    GL_IMAGES, mem); glAllocMem2D (fmt, w, h, …)
ARB_superbuffers In our application Create memory object for quad texture (width*height = 4 * #edges) During edge processing, use memory  object as render target During shadow volume rendering, use memory object as vertex array Very fast, since objects are used by reference (no data is copied)
Summary Silhouette Algorithm Pre-process meshes Number all vertices (#V) Number all edges (#E) Several instances of the same object need edge/vertex offsets  Compute position texture Render one point per vertex 4-component float texture for #V vertices Compute quad texture 4 pixels for each edge check front/back facing condition for a number of lights (fragment shader)  4-component float texture for #E * 4 entries
Summary Silhouette Algorithm (cont.) Assign quad texture as vertex array ARB_superbuffer Render shadow volumes (for each light) Send down #E quads (#E * 4 array indices) Vertex shader checks silhouette/extrude case If silhouette flag is false, move quad’s vertices way outside of view frustum (early clip) Otherwise, pass through vertices if extrude flag is false, or extrude vertices to infinity
Summary Execution of different stages Position texture needs to be computed when objects change  Quad texture needs to be re-computed when light position or objects change Selective update E.g. only recompute position for those objects that changed, no need to redo the complete texture
Results
Conclusions Silhouette detection in hardware No frame-to-frame work for CPU All dynamic data remains on the graphics card ! Works with custom vertex shaders Deformation is no longer a problem Processes a number of light sources in parallel (flag bitmask) Full hardware shadow volumes implementation More CPU resources for non-graphics work  No graphics / CPU sync requiered
Future Work Shadow volume fill-rate problem Optimizations during edge processing Intersect with large occluder polygons (walls, floor, etc.) Reduce geometry work Work with connected primitives (quad strips) More general input geometry  Meshes with open edges ? Other applications non-photorealistic rendering
Thank you !

More Related Content

PPT
Geometry Shader-based Bump Mapping Setup
PPT
CS 354 Transformation, Clipping, and Culling
PPT
CS 354 Texture Mapping
PPT
CS 354 Object Viewing and Representation
PPT
CS 354 Blending, Compositing, Anti-aliasing
PPT
CS 354 Understanding Color
PPT
CS 354 Pixel Updating
PPT
CS 354 More Graphics Pipeline
Geometry Shader-based Bump Mapping Setup
CS 354 Transformation, Clipping, and Culling
CS 354 Texture Mapping
CS 354 Object Viewing and Representation
CS 354 Blending, Compositing, Anti-aliasing
CS 354 Understanding Color
CS 354 Pixel Updating
CS 354 More Graphics Pipeline

What's hot (20)

PPT
CS 354 Viewing Stuff
PPT
CS 354 Graphics Math
PPT
CS 354 Introduction
PPT
CS 354 Acceleration Structures
PPT
NVIDIA's OpenGL Functionality
PPT
Anatomy of a Texture Fetch
PPT
OpenGL 3.2 and More
PDF
Modern OpenGL Usage: Using Vertex Buffer Objects Well
PPT
GDC 2012: Advanced Procedural Rendering in DX11
PPT
CS 354 Programmable Shading
PPT
CS 354 Final Exam Review
PPTX
Beyond porting
PPT
CS 354 Project 2 and Compression
PPT
CS 354 GPU Architecture
PPTX
Trident International Graphics Workshop 2014 4/5
PPSX
Oit And Indirect Illumination Using Dx11 Linked Lists
PPT
NVIDIA OpenGL in 2016
PPT
OpenGL for 2015
PPTX
Matlab Feature Extraction Using Segmentation And Edge Detection
PPT
CS 354 Lighting
CS 354 Viewing Stuff
CS 354 Graphics Math
CS 354 Introduction
CS 354 Acceleration Structures
NVIDIA's OpenGL Functionality
Anatomy of a Texture Fetch
OpenGL 3.2 and More
Modern OpenGL Usage: Using Vertex Buffer Objects Well
GDC 2012: Advanced Procedural Rendering in DX11
CS 354 Programmable Shading
CS 354 Final Exam Review
Beyond porting
CS 354 Project 2 and Compression
CS 354 GPU Architecture
Trident International Graphics Workshop 2014 4/5
Oit And Indirect Illumination Using Dx11 Linked Lists
NVIDIA OpenGL in 2016
OpenGL for 2015
Matlab Feature Extraction Using Segmentation And Edge Detection
CS 354 Lighting
Ad

Viewers also liked (7)

PPT
Shadow Techniques for Real-Time and Interactive Applications
PDF
Shaders in Unity by Zoel
PDF
Unity advanced computer graphics week 02
PPTX
Shader Programming With Unity
PDF
Shaders - Claudia Doppioslash - Unity With the Best
PPTX
Cg shaders with Unity3D
PPTX
Slideshare ppt
Shadow Techniques for Real-Time and Interactive Applications
Shaders in Unity by Zoel
Unity advanced computer graphics week 02
Shader Programming With Unity
Shaders - Claudia Doppioslash - Unity With the Best
Cg shaders with Unity3D
Slideshare ppt
Ad

Similar to Shadow Volumes on Programmable Graphics Hardware (20)

PPT
Real-time Shadowing Techniques: Shadow Volumes
PDF
Hpg2011 papers kazakov
PPT
Advanced Lighting for Interactive Applications
PPSX
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
PPTX
DirectX 11 Rendering in Battlefield 3
PPTX
Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)
PPT
Hardware Shaders
PPT
Praseed Pai
PDF
3Dtexture_doc_rep
PPTX
SPU Assisted Rendering
PPTX
SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3
PPT
Shadow Mapping with Today's OpenGL Hardware
PPT
The Intersection of Game Engines & GPUs: Current & Future (Graphics Hardware ...
PPTX
COLLADA & WebGL
ZIP
Adobe AIR: Stage3D and AGAL
PPTX
Penn graphics
PDF
OpenGL ES 3.0 2013
PDF
Markus Tessmann, InnoGames
PDF
"Graphical fun With WebGL shaders", Martin Splitt
Real-time Shadowing Techniques: Shadow Volumes
Hpg2011 papers kazakov
Advanced Lighting for Interactive Applications
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
DirectX 11 Rendering in Battlefield 3
Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)
Hardware Shaders
Praseed Pai
3Dtexture_doc_rep
SPU Assisted Rendering
SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3
Shadow Mapping with Today's OpenGL Hardware
The Intersection of Game Engines & GPUs: Current & Future (Graphics Hardware ...
COLLADA & WebGL
Adobe AIR: Stage3D and AGAL
Penn graphics
OpenGL ES 3.0 2013
Markus Tessmann, InnoGames
"Graphical fun With WebGL shaders", Martin Splitt

Recently uploaded (20)

PDF
KodekX | Application Modernization Development
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
A Presentation on Artificial Intelligence
PPTX
Cloud computing and distributed systems.
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Machine learning based COVID-19 study performance prediction
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Electronic commerce courselecture one. Pdf
KodekX | Application Modernization Development
The Rise and Fall of 3GPP – Time for a Sabbatical?
“AI and Expert System Decision Support & Business Intelligence Systems”
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Spectral efficient network and resource selection model in 5G networks
A Presentation on Artificial Intelligence
Cloud computing and distributed systems.
20250228 LYD VKU AI Blended-Learning.pptx
NewMind AI Weekly Chronicles - August'25 Week I
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Reach Out and Touch Someone: Haptics and Empathic Computing
Machine learning based COVID-19 study performance prediction
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
MYSQL Presentation for SQL database connectivity
Encapsulation_ Review paper, used for researhc scholars
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Electronic commerce courselecture one. Pdf

Shadow Volumes on Programmable Graphics Hardware

  • 1. Shadow Volumes on Programmable Graphics Hardware Stefan Brabec Hans-Peter Seidel MPI Informatik
  • 2. Overview Shadow Volumes Silhouette Generation in Hardware Motivation Our method Results Conclusion & Future Work
  • 3. Shadow Volumes [Crow77] Shadow algorithms for computer graphics Compute regions of shadow in 3D Object-space algorithm Per-pixel correct shadow information Cast shadows onto arbitrary receiver geometry
  • 4. Shadow Volumes Extend occluder polygons to form semi-infinite volumes Light source is center-of-projection Everything behind occluder is in shadow occluder light shadow region lit
  • 5. Shadow Volume Generation Trivial way One volume for each polygon Better Silhouette-based approach Need to check each edge with each light !
  • 6. Shadow Volume Generation An edge is a silhouette edge if it is an edge shared by a front-facing and back-facing triangle/polygon Light Light FF BF FF FF Silhouette Edge (v0,v1) ! No Silhouette Edge ! n 1 n 2 n 1 n 2
  • 7. Shadow Volume Rendering Stencil-based shadow volumes [Heidmann ‘91] Real shadows real time count in-out events using the stencil buffer
  • 8. Shadow Volume Rendering Number of problems near/far clipping plane fill rate non-closed volumes See work from Everitt/Kilgard ! silhouette detection Focus of this talk:
  • 9. Motivation From some OpenGL discussion forum:
  • 10. Motivation Silhouette detection is not trivial for complex vertex shaders
  • 11. Our method Use graphics hardware to compute silhouettes State-of-the-art hardware allows computation in object space Floating point calculations Floating point textures Powerful, programmable vertex and fragment processing units
  • 12. Input Data Supported meshes Closed objects (no open edges) Two triangles meet at one edge Example: This is not a closed mesh, but since we are only focusing on one edge of this mesh its ok.
  • 13. Coordinate Transformation First step Need to transform all geometry to a global coordinate system Also need all light sources in this system Common choices World space View-independent Eye Space View-dependent ok for fully dynamic scenes with moving viewer Object Space Need to transform light sources to this space (done by most CPU approaches)
  • 14. Transform to world/eye space Unique identifier per vertex Transform each vertex to world/eye space render mesh as points Store position at index slot P 0 P 1 P 2 P 3 P 4 position texture P 0 P 1 P 2 P 3 P 4 P N
  • 15. Transform to world/eye space Vertex program for transform / index store Simple for standard modelview transformation More complex programs modified by simple source-to-source code transformation Eliminate code relevant for additional attributes (color, texcoords, etc.) Replace output position register by attribute register result.position -> result.texcoord[0] Add code to move vertex index to output position MOV result.position, vertex.texcoord[..]; !!ARBvp1.0 ATTRIB iVertexPos = vertex.position; ATTRIB iVertexIdx = vertex.texcoord[0]; PARAM mv[4] = { state.matrix.modelview }; OUTPUT oPos = result.position; OUTPUT oDumpPos = result.texcoord[0]; # Transform the vertex to eye coordinates . DP4 oDumpPos.x, mv[0], iVertexPos; DP4 oDumpPos.y, mv[1], iVertexPos; DP4 oDumpPos.z, mv[2], iVertexPos; DP4 oDumpPos.w, mv[3], iVertexPos; # Vertex position is its index (x,y,0,1) MOV oPos, iVertexIdx; END
  • 16. Transform to world/eye space Storing the result Need full floating point precission RGBA float textures (RGBA = x,y,z,w) One global texture to store all positions Index numbering is pre-processing step Multiple instances of the same object need separate index slots (use index offset) Use per-object culling (in light view) to reduce number of vertices Mapping indices to 2D (idx % width, idx / width) overcomes texture size limitation 1D: 2048 vertices 2D: over 4M vertices ! (max 2D texture size 2048x2048)
  • 17. Process edges Mesh connectivity is known Computed in pre-processing step Each edge has unique identifier (index) Two vertices for the edge Two vertices for adjacent triangles
  • 18. Process edges Render point for each edge Edge index defines output position Assign four vertex indices as attributes E 0_idx P 0_idx P 1_idx P 3_idx P 4_idx glBegin(GL_POINTS) ; glAttrib(P0_idx, P3_idx, P1_idx, P4_idx); glVertex1f(E0_idx); glEnd();
  • 19. Process Edges Vertex shader Not needed during this stage (pass-through all attributes) Fragment shader Used to compute silhouette flag Position of light sources as global parameters Use position texture of previous pass
  • 20. Process edges Fragment shader E 0_idx P 0_idx P 1_idx P 3_idx P 4_idx input data 4 texture lookups for world space positions P 0 P 1 P 3 P 4 registers P 3 P 0 P 1 P 4 N 1 = (P 3 –P 0 )x(P 1 –P 0 ) N 2 = (P 4 –P 0 )x(P 3 –P 0 ) front & back facing ? position texture P 0 P 1 P 2 P 3 P 4 Light Store silhouette flag (yes/no) at edge index E 0 E 1 E 2 E 3 E 4 E M edge texture
  • 21. Silhouette Detection What we’ve got so far One texture holding all world/eye space position (w*h = #vertices) One texture holding all silhouette flags for the edges (w*h = #edges) There’s also an additional flag (bit) for the vertex ordering (please see paper for details) Next step Use this information to extrude & render shadow volumes
  • 22. Rendering Shadow Volumes Basic algorithm for all lights { for all edges { if (is silhouette edge for light i) { get edge’s vertices render extruded quad } } }
  • 23. Rendering shadow volumes Vertex shader & tex lookup Best solution, but not (yet) supported Read back textures Trivial solution, but not very fast position texture P 0 P 1 P 2 P 3 P 4 P N E 0 E 1 E 2 E 3 E 4 E M edge texture glBegin(GL_QUADS) ; glVertex(P0_idx, E0_idx, 0); glVertex(P1_idx, E0_idx, 0); glVertex(P1_idx, E0_idx, 1); glVertex(P0_idx, E0_idx, 1); P = Lookup (p_idx) mask = Lookup (e_idx) if (mask & silhouette) { if (extrude) // 0 or 1 flag out = P – Light_pos else out = P } else { out = (0,0,0,1) // outside view }
  • 24. Rendering shadow volumes Better: keep all data on the card ! Instead of storing edge flags, store all quad information E 0 = silhouette quad texture E` 0 = silhouette & extrude P 0 L P 3 P 0- L P 3- L Q 0 Q 1 Q 2 Q 3 Q 0 = (P 0x ,P 0y ,P 0z , E 0 ) Q 1 = (P 3x ,P 3y ,P 3z , E 0 ) Q 2 = (P 3x ,P 3y ,P 3z , E` 0 ) Q 3 = (P 0x ,P 0y ,P 0z , E` 0 )
  • 25. Rendering Shadow Volumes Quad texture Instead of rendering one point per edge, render 4 points (line, 2x2 point) XYZ-components used for world space position (edge vertices) W-component for silhouette/extrude flag Can be used as bitmask (number of lights) Light0: Silhouette Light0: Extrude Light1: Silhouette Light1: Extrude
  • 26. Rendering Shadow Volumes Quad texture used as vertex array Vertex Array: glBegin(GL_QUADS) ; glArrayElement(0); glArrayElement(1); glArrayElement(2); glArrayElement(3); P_xyz = IN_xyz; E = IN_w; if(E & silhouette) { if(E & extrude) out = P-L; else out = P; } else { out = somewhere outside view } Q 0 Q 1 Q 2 Q 3
  • 27. Rendering Shadow Volumes Problem: Information stored as texture image Need information in vertex path Solution: New OpenGL extension ARB_superbuffers allows more generic memory objects
  • 28. ARB_superbuffers General purpose memory objects Use the same memory object in different parts of the pipeline as a texture as a vertex array as a render target glVertexArrayMem ( GL_VERTEX_ARRAY, 4, mem, 0); memory block glAttachMem ( GL_DRAW_FRAMEBUFFER, GL_AUX0, mem); glAttachMem ( GL_TEXTURE_2D, GL_IMAGES, mem); glAllocMem2D (fmt, w, h, …)
  • 29. ARB_superbuffers In our application Create memory object for quad texture (width*height = 4 * #edges) During edge processing, use memory object as render target During shadow volume rendering, use memory object as vertex array Very fast, since objects are used by reference (no data is copied)
  • 30. Summary Silhouette Algorithm Pre-process meshes Number all vertices (#V) Number all edges (#E) Several instances of the same object need edge/vertex offsets Compute position texture Render one point per vertex 4-component float texture for #V vertices Compute quad texture 4 pixels for each edge check front/back facing condition for a number of lights (fragment shader) 4-component float texture for #E * 4 entries
  • 31. Summary Silhouette Algorithm (cont.) Assign quad texture as vertex array ARB_superbuffer Render shadow volumes (for each light) Send down #E quads (#E * 4 array indices) Vertex shader checks silhouette/extrude case If silhouette flag is false, move quad’s vertices way outside of view frustum (early clip) Otherwise, pass through vertices if extrude flag is false, or extrude vertices to infinity
  • 32. Summary Execution of different stages Position texture needs to be computed when objects change Quad texture needs to be re-computed when light position or objects change Selective update E.g. only recompute position for those objects that changed, no need to redo the complete texture
  • 34. Conclusions Silhouette detection in hardware No frame-to-frame work for CPU All dynamic data remains on the graphics card ! Works with custom vertex shaders Deformation is no longer a problem Processes a number of light sources in parallel (flag bitmask) Full hardware shadow volumes implementation More CPU resources for non-graphics work No graphics / CPU sync requiered
  • 35. Future Work Shadow volume fill-rate problem Optimizations during edge processing Intersect with large occluder polygons (walls, floor, etc.) Reduce geometry work Work with connected primitives (quad strips) More general input geometry Meshes with open edges ? Other applications non-photorealistic rendering