1 / 22

Week 2: Review of graphics API

Week 2: Review of graphics API. Programmable pipeline. OpenGL block diagram. Generation. Traversal. Xformation. Rasteriz. & tex. Display. Display list. Per-vertex operations & Primitive assembly. Per- fragment operations. Frame buffer. Video display. Evaluator. Rasterization.

shaina
Download Presentation

Week 2: Review of graphics API

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Week 2: Review of graphics API Programmable pipeline

  2. OpenGL block diagram Generation Traversal Xformation Rasteriz. & tex. Display Display list Per-vertex operations & Primitive assembly Per- fragment operations Frame buffer Video display Evaluator Rasterization Application generation Application traversal Texture memory Pixel operations Application & higher level graphics libraries OpenGL implementation

  3. Per-vertex operations • Transform vertex coords. (modelview m.) • Transform and renormalize normals • Generate and transform texture coords. • Lighting calculations Display list Per-vertex operations & Primitive assembly Per- fragment operations Frame buffer Video display Evaluator Rasterization Application generation Application traversal Texture memory Pixel operations

  4. Primitive assembly • Flat shading • Clipping • Projection transformations • Viewport and depth-range operations • Culling Display list Per-vertex operations & Primitive assembly Per- fragment operations Frame buffer Video display Evaluator Rasterization Application generation Application traversal Texture memory Pixel operations

  5. Rasterization • Convert each primitive into fragments • Fragment: “transient data structures” • position (x,y); depth; color; texture coordinates; coverage; … Display list Per-vertex operations & Primitive assembly Per- fragment operations Frame buffer Video display Evaluator Rasterization Application generation Application traversal Texture memory Pixel operations

  6. Interpolation issues http://www.cse.ohio-state.edu/~hwshen/781/pipeline.ppt

  7. p1 P1’ p p L P2’ p2 Linear Interpolation Issues • Linear interpolation takes place in screen space • Problems can happen when projecting • Texture coordinates • Colors • Positions are okay. • Cannot recover p’s color and texture coordinates from linear Interpolation Lerp(Cp1’,Cp2’) along L != Cp • Need perspective correct interpolation for unprojected values http://www.cse.ohio-state.edu/~hwshen/781/pipeline.ppt

  8. More explanations • Equal spacing in screen (pixel) space is not the same as in texture space in perspective projection • Perspective foreshortening from Hill courtesy of H. Pfister http://www.cse.ohio-state.edu/~hwshen/781/pipeline.ppt

  9. Perspective-Correct Texture Coordinate Interpolation • Interpolate (tex_coord/w) over the polygon, then do perspective divide after interpolation • Compute at each vertex after perspective transformation • “Numerators” s/w, t/w • “Denominator” 1/w http://www.cse.ohio-state.edu/~hwshen/781/pipeline.ppt

  10. Perspective-Correct Texture Coordinate Interpolation • Linearly interpolate 1/w, s/w, and t/w across the polygon • At each pixel • Perform perspective division of interpolated texture coordinates (s/w, t/w) by interpolated 1/w (i.e., numerator over denominator) to get (s, t) http://www.cse.ohio-state.edu/~hwshen/781/pipeline.ppt

  11. Perspective-Correct Interpolation • That fixed it!

  12. Back to the pipeline

  13. Rasterization • Convert each primitive into fragments • Fragment: “transient data structures” • position (x,y); depth; color; texture coordinates; coverage; … Display list Per-vertex operations & Primitive assembly Per- fragment operations Frame buffer Video display Evaluator Rasterization Application generation Application traversal Texture memory Pixel operations

  14. Per fragment operations (I) • Generate texel for every fragment • Fog calculations • Coverage (antialiasing) values application Display list Per-vertex operations & Primitive assembly Per- fragment operations Frame buffer Video display Evaluator Rasterization Application generation Application traversal Texture memory Pixel operations

  15. Per fragment operations (II) • Scissoring • Alpha test • Stencil test • Depth-buffer test • Blending • Dithering and logical operation • Masking Display list Per-vertex operations & Primitive assembly Per- fragment operations Frame buffer Video display Evaluator Rasterization Application generation Application traversal Texture memory Pixel operations

  16. Hello world Per- vertex Operations Per- fragment Operations (I)

  17. Vertex shader • Is run once every time a vertex position is specified • glVertex, glDrawArrays, … • Must compute gl_Position • May compute gl_ClipVertex or gl_PointSize

  18. Hello world

  19. Fragment shader • Is run once for every fragment produced • Has access to the interpolated value for each varying variable • Color, normal, texture coordinates, arbitrary values • Output goes to the fixed pipeline • gl_FragColor – computed R, G, B, A for the fragment • gl_FragDepth – computed depth value for the fragment • gl_FragData[n] – arbitrary data per fragment, stored in multiple render targets

  20. Playing with GLSL Demo

More Related