DOC PREVIEW
OSU CS 553 - Performance Graphics Programming

This preview shows page 1-2-3-4-5 out of 16 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 16 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 16 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 16 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 16 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 16 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

5/7/20131Performance Graphics ProgrammingMike [email protected] State Universitymjb – May 7, 2013Oregon State UniversityComputer GraphicsMotivationWhy 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:1. Eliminate large portions of the scene so that the graphics card never sees themTwo Approachesmjb – May 7, 2013Oregon State UniversityComputer Graphics2. Draw the scene faster5/7/20132Eliminating Scene Detail: Bounding VolumesQuickly pre-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.mjb – May 7, 2013Oregon State UniversityComputer GraphicsThere is a dividing line here. If it takes too much computation time to eliminate a section of the 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 dt0th th b di b i l t land 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 bo nding geometr most tightl fits o r scenemjb – May 7, 2013Oregon State UniversityComputer Graphicsbounding geometry most tightly fits your scene.5. Hierarchical Culling -- break big things into smaller things so that more can be cleanly culled.1225/7/20133Remove 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 DirectionV, the viewing vectorP, the point in questionf, the Field of View angleE, the eye positionmjb – May 7, 2013Oregon State UniversityComputer GraphicsP, is in the viewing volume if:ˆ()cos2VPE fPEThis can be pre-computed5/7/20134Eliminating Scene Detail: Fog Tricks• Use fog to cover up a close-in 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 detail• Another way to get away with a close-in far clipping plane: bring distant detail in with alpha blending (transparency).Object’s Real Colormjb – May 7, 2013Oregon State UniversityComputer GraphicsUniversity of MichiganFog’sColorFar Clipping PlaneEyeMinimize How Much Data Needs to be Sent Across the Bus• Use quad strips instead of quads – transform less points• Use triangle strips instead of triangles, and instead of quad anythings. (The vendors say this but I am not sure it is true )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 bettermjb – May 7, 2013Oregon State UniversityComputer GraphicsSome say they try to use a size of 10,000 vertices or more5/7/20135GLfloat CubeVertices[ ][3] ={{ -1., -1., -1. },{ 1., -1., -1. },{ -1., 1., -1. },{1.,1.,-1. },Vertex Buffers Store Arrays in GPU Memory3276{ 1., 1., 1. },{ -1., -1., 1. },{ 1., -1., 1. },{ -1., 1., 1. },{ 1., 1., 1. }};GLfloat CubeColors[ ][3] ={{ 0., 0., 0. },GLuint CubeIndices[ ][4] ={0145mjb – May 7, 2013Oregon State UniversityComputer Graphics{}{ 1., 0., 0. },{ 0., 1., 0. },{ 1., 1., 0. },{ 0., 0., 1. },{ 1., 0., 1. },{ 0., 1., 1. },{ 1., 1., 1. },};{ 0, 2, 3, 1 },{ 4, 5, 7, 6 },{ 1, 3, 7, 5 },{ 0, 4, 6, 2 },{ 2, 6, 7, 3 },{ 0, 1, 5, 4 }};Using a Vertex Buffer Object ClassVertexBufferObject Blob( );Blob.CollapseCommonVertices( true );Setting Up:Filling:Blob.glBegin( GL_TRIANGLES );// can be any of the OpenGL topologiesBlob.glColor3f( r0, g0, b0 );Blob.glVertex3f( x0, y0, z0 );. . .Blob.glEnd( );Drawing:mjb – May 7, 2013Oregon State UniversityComputer GraphicsBlob.Draw( );5/7/20136Eliminating 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 se p o r “pol gon b dget” ifo•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 GraphicsExample #2: Polygon mesh decimationDrawing the Scene Faster:Four Major Performance Bottleneck Locationsmjb – May 7, 2013Oregon State UniversityComputer Graphics5/7/201371. 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.Drawing the Scene Faster:Four Major Performance Bottleneck Locations2. 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 BoardPCI 132 Mb/sec 132 Mb/secmjb – May 7, 2013Oregon State UniversityComputer GraphicsAGP 8X 2 Gb/sec 264 Mb/secPCI Express 4 Gb/sec 4 Gb/secThe Graphics PipelineModelTransformViewTransformProjectionTransformHomogeneousDivisionPer-vertexLightingNDCECWCMCCCECViewportTransformFragmentProcessing, Texturing,Per-fragment LightingRastersOpsRasterizationFramebufferSCSCSCSCVertex Processingmjb – May 7, 2013Oregon State UniversityComputer GraphicsMC = Model CoordinatesWC = World CoordinatesEC = Eye CoordinatesCC = Clip CoordinatesNDC = Normalized Device


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?