DOC PREVIEW
OSU CS 553 - Performance Graphics Programming

This preview shows page 1-2-14-15-30-31 out of 31 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 31 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 31 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 31 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 31 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 31 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 31 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 31 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Performance Graphics ProgrammingMike [email protected] State Universitymjb – May 7, 2013Oregon State UniversityComputer GraphicsMotivationWhy are we covering this?Why are we covering this?There reaches a point where the amount of scientific data you are trying to display overwhelms the graphics card’s abilities. At that point, you start to wonder if there are ways you can speed-up your display without buying a new graphics card. This puts you in the same league as game developers. There are two major approaches to performance graphics programming:Two Approaches1. Eliminate large portions of the scene so that the graphics card never sees them2. Draw the scene fastermjb – May 7, 2013Oregon State UniversityComputer GraphicsEliminating Scene Detail: Bounding VolumesQuicklypre-eliminate as much scenery as possible using the CPU.Cull based on comparing bounding volumes with the viewing frustum -- try to achieve quick trivial rejections.There is a dividing line here. If it takes too much computation time to eliminate a section of mjb – May 7, 2013Oregon State UniversityComputer Graphicsgpthe scene, it might be better to display it as-is and let the graphics hardware decide what’s visible and what’s not.The Cohen-Sutherland Algorithm1. Determine a clip code for each of the 8 vertices of the bounding box.2. If you ‘inclusive-or’ ( | ) all 8 clip codes together and get 0, then the bounding box is completely inside the viewing volume3. If you ‘and’ ( & ) all 8 clip codes together and get !0, then the bounding box is completely outside the viewing volume.4. Sometimes a bounding sphere or bounding cylinder makes more sense. It depends on what bounding geometry most tightly fits your scene.15. Hierarchical Culling -- break big things into smaller things so that more can be cleanly culled.22mjb – May 7, 2013Oregon State UniversityComputer GraphicsRemove Parts of the SceneWhile Making the Player Think it is Part of the Gamemjb – May 7, 2013Oregon State UniversityComputer GraphicsTest if Something is within a Certain Angle of the Viewing DirectionP, the point in questionV, the viewing vectorf, the Field of View angleE, the eye positionP, is in the viewing volume if:ˆ()cos2VPEfPEmjb – May 7, 2013Oregon State UniversityComputer GraphicsThis can be pre-computedEliminating Scene Detail: Fog Tricks•Use fog to cover up a close-in far clipping plane–fog and haze can hide theUse fog to cover up a closein far clipping plane fog and haze can hide the fact that you are far-clipping away a lot of scene detail. And you thought it was just part of the game… :-)•Also an object partly in the haze can be displayed with less scene detailAlso, an object partly in the haze can be displayed with less scene detail• Another way to get away with a close-in far clipping plane: bring distant detail in with alpha blending (transparency).Object’sObject s Real ColorFog’sColorUniversity of MichiganFar Clipping PlaneEyemjb – May 7, 2013Oregon State UniversityComputer GraphicsMinimize How Much Data Needs to be Sent Across the Bus• Use quad strips instead of quads – transform less pointsUiliidfil didfdhi(Th•Use triangle strips instead of triangles, and instead of quad anythings. (The vendors say this, but I am not sure it is true…)• Better: use vertex arrays – only transform each vertex once• Best: use vertex buffer objects – vertex data gets stored on the graphics card.• Maximize the size of vertex array/vertex buffer object blocksSmall batches of geometry can kill performance100 triangles/batch should be a minimum>= 500 would be betterSome say they try to use a size of 10,000 vertices or moremjb – May 7, 2013Oregon State UniversityComputer GraphicsGLfloatCubeVertices[][3] =Vertex Buffers Store Arrays in GPU Memory32GLfloat CubeVertices[][3] ={{ -1., -1., -1. },{ 1., -1., -1. },{111}76{ -1., 1., -1. },{ 1., 1., -1. },{ -1., -1., 1. },{ 1., -1., 1. },{111}01{ -1., 1., 1. },{ 1., 1., 1. }};GLfl tCbCl [][3]45GLfloat CubeColors[ ][3] ={{ 0., 0., 0. },{ 1., 0., 0. },{0 1 0 }GLuint CubeIndices[ ][4] ={{ 0, 2, 3, 1 },{4 5 7 6}{ 0., 1., 0. },{ 1., 1., 0. },{ 0., 0., 1. },{ 1., 0., 1. },{0 1 1 }{ 4, 5, 7, 6 },{ 1, 3, 7, 5 },{ 0, 4, 6, 2 },{ 2, 6, 7, 3 },{0 1 5 4}mjb – May 7, 2013Oregon State UniversityComputer Graphics{ 0., 1., 1. },{ 1., 1., 1. },};{ 0, 1, 5, 4 }};Using a Vertex Buffer Object ClassSetting Up:VertexBufferObject Blob( );Blob.CollapseCommonVertices( true );FilliBlob.glBegin( GL_TRIANGLES ); // can be any of the OpenGL topologiesBlob.glColor3f( r0, g0, b0 );BlobglVertex3f(x0 y0 z0 );Filling:Blob.glVertex3f( x0, y0, z0 );. . .Blob.glEnd( );Blob.Draw( );Drawing:()mjb – May 7, 2013Oregon State UniversityComputer GraphicsEliminating Scene Detail: Level of Detail• How far away is the object from the viewer? If it’s far away, you don’t need to use as much geometric detail to display it. Occlusion querying can help. (Occlusion query lets you pretend-render a bounding box, and the graphics processor will tell you how many pixels it would have occupied.)• Don’t use up your “polygon budget” if youdon’t need to• Keep several representations for differentcomponents of the scene and switch betweenthem.• Example #1: Different resolutions of spheres• Example #2: Polygon mesh decimationmjb – May 7, 2013Oregon State UniversityComputer GraphicsDrawing the Scene Faster:Four Major Performance Bottleneck Locationsmjb – May 7, 2013Oregon State UniversityComputer GraphicsDrawing the Scene Faster:Four Major Performance Bottleneck Locations1. The computer – if the CPU cannot compute the data, read the data, uncompress the data, or call the graphics routines fast enough, then it doesn’t matter how fast your graphics card is.2. The bus – a slow bus will choke down transmission of graphics from the CPU to the graphics card. Type of BoardSpeed tothe BoardSpeed from the BoardBoardthe Boardthe BoardPCI 132 Mb/sec 132 Mb/secAGP 8X2 Gb/sec264 Mb/secAGP 8X2 Gb/sec264 Mb/secPCI Express 4 Gb/sec 4 Gb/secmjb – May 7, 2013Oregon State UniversityComputer GraphicsThe Graphics PipelineECWCMCCCECModelTransformViewTransformProjectionTransformHomogeneousDivisionPer-vertexLightingNDCECWCCCECViewportTransformNDCVertex ProcessingFragmentProcessing, Texturing,RastersORasterizationFbffSCSCSCSCTexturing,Per-fragment LightingOpsFramebufferRasterizer and Fragment ProcessingMC = Model


View Full Document

OSU CS 553 - Performance Graphics Programming

Download Performance Graphics Programming
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Performance Graphics Programming and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Performance Graphics Programming 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?