shaders
play

Shaders Jeremy Nicholson COMP30019: Graphics and Interaction 05 - PowerPoint PPT Presentation

Shaders Jeremy Nicholson COMP30019: Graphics and Interaction 05 Sep 2011 Jeremy Nicholson Shaders Rendering Pipeline (Foley Figure 14.41) Jeremy Nicholson Shaders Rendering Pipeline (OpenGL Red Book, section 1) Jeremy Nicholson Shaders


  1. Shaders Jeremy Nicholson COMP30019: Graphics and Interaction 05 Sep 2011 Jeremy Nicholson Shaders

  2. Rendering Pipeline (Foley Figure 14.41) Jeremy Nicholson Shaders

  3. Rendering Pipeline (OpenGL Red Book, section 1) Jeremy Nicholson Shaders

  4. Rendering Pipeline (Angel Figure 1.38) Jeremy Nicholson Shaders

  5. Rendering Pipeline Vertex processing: Vertex position: co-ordinate transformations (model) projection transformations Vertex colour: Illumination model Jeremy Nicholson Shaders

  6. Rendering Pipeline Clipping and primitive assembly: Clipping: Clipping volume (based on viewing frustum) projection transformations Primitive assembly Vertices → line segments, polygons, etc. Jeremy Nicholson Shaders

  7. Rendering Pipeline Rasterisation: Scan conversion of polygons Line segment → fragments Fragments: ”potential pixels” Position and colour to be entered into frame buffer Jeremy Nicholson Shaders

  8. Rendering Pipeline Fragment processing: Hidden surface removal Some fragments may not be visible because they are behind other fragments Texturing, blending, etc. Jeremy Nicholson Shaders

  9. Shaders Loosely speaking, programming on the GPU itself Typically high-powered processor, lots of RAM Parallel processing plays an important part not massively parallel typically only a couple of simple mathematical operations e.g. matrix multiplication of a single transformation matrix to many vertices Don’t typically do any “shading” Jeremy Nicholson Shaders

  10. Types of Shaders Vertex Shader: Input: set of primitives (vertices) Output: set of primitives Operate on vertex values and associated data Normals Colour Material properties Texture? Jeremy Nicholson Shaders

  11. Types of Shaders Geometry Shader: Input: set of primitives Output: set of primitives Add/remove vertices or other primitives Triangulation (why?) Hidden surface removal? Shadow volumes etc. Jeremy Nicholson Shaders

  12. Types of Shaders Fragment Shader: Input: set of fragments Output: set of fragments Apply operations to viewport pixels (primarily colour) Texture mapping Bump mapping Potentially lighting model Rasterisation/anti-aliasing? Jeremy Nicholson Shaders

  13. Types of Shaders Pixel Shader: Input: set of fragments Output: set of pixel values Actually rendering images to the display Depth testing/occlusion/blending Hardware conversion: dithering, γ -correction Double buffering Jeremy Nicholson Shaders

  14. Shaders and the Rendering Pipeline Vertex processing: Vertex Shader Clipping and primitive assembly: Geometry Shader Rasterisation: Fragment Shader Fragment processing: Pixel Shader (Loosely) Jeremy Nicholson Shaders

  15. Shaders and the Rendering Pipeline Vertex Shader: ??? Geometry Shader: ??? Fragment Shader: ??? Pixel Shader: ??? Jeremy Nicholson Shaders

  16. Shaders and the Rendering Pipeline Vertex Shader: Modelling transform, Lighting, Viewing transform Geometry Shader: Trivial accept/reject, some Lighting Fragment Shader: Rasterisation Pixel Shader: Display (Typically, but Clipping and Map to 3D viewport are ”missing”) Jeremy Nicholson Shaders

  17. Shaders in OpenGL Contrast with ”legacy” OpenGL Gives you the power (and hassle) of specifying your own modelling/viewing operations, illumination model, shading model Only Vertex/Geometry/Fragment Shaders implemented in OpenGL And geometry only recently! Manipulated using a pared-down programming language... Jeremy Nicholson Shaders

  18. GLSL: The OpenGL shading language ”GL slang” Reference: Orange book Not many in-builts Some mathematical functions (e.g. Trigonometric) I/O partly limited: specific streams for vertex position, colour, etc. Jeremy Nicholson Shaders

  19. GLSL: The OpenGL shading language Common key words: in - input (from OpenGL or earlier in the Shader pipeline) out - output (to next Shader in the pipeline, or occasionally OpenGL) uniform - ”constant” variable: same across many inputs (iterationsof Shader) — allowing preprocessing and optimisation varying - actual variable: for intermediate calculation etc. Jeremy Nicholson Shaders

  20. Examples Trivial Example (Angel 2.2) Jeremy Nicholson Shaders

  21. Examples Illumination Model (in Vertex Shader) (Angel 5.3) Jeremy Nicholson Shaders

  22. Examples Illumination Model (in Fragment Shader) (Angel 5.6) Jeremy Nicholson Shaders

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend