GAMES202 Lecture 02 - Recap of CG Basics

GAMES202_Lecture_02 (ucsb.edu)

Outline

 

I. Basic GPU Hardware Pipeline

Graphics Pipeline

From vertices to images.

image-20230728151130552

 

II. OpenGL

OpenGL is a set of APIs that call the GPU pipeline from CPU

 

Cons

 

Understanding

 

Usage and Analogy

Important Analogy: Oil Painting

  1. Place objects/models

  2. Set position of an easel

  3. Attach a canvas to the easel

  4. Paint to the canvas

  5. (Attach other canvases to the easel and continue painting)

  6. (Use previous paintings for reference)

 

In OpenGL (one-to-one):

  1. (Place objects/models) Model specification and transformation:

    • User specifies an object's vertices, normals, texture coordinates and send them to GPU as a Vertex Buffer Object (VBO)

      • Very similar to .obj files

    • Use OpenGL functions to obtain matrices

      • e.g., glTranslate, glMultMatrix, etc.

      • No need to write anything on our own.

  2. (Set position of an easel) View transformation, Creating and Using a Framebuffer:

    • Set camera (the viewing transformation matrix) by simply calling e.g., gluPerspective:

  3. (Attach a canvas to the easel) One Pass in OpenGL. Specify a framebuffer to use:

    • Multiple Render Target: Specify one or more textures as output (shading, depth, etc.)

    • Render (fragment shader specifies the content on each texture)

  4. (Paint to the canvas) For each vertex/primitive, ..., in parallel:

    • For example, how to perform shading.

    • For each vertex in parallel:

      • OpenGL calls user-specified vertex shader: transformation matrices, other ops.

    • For each primitive, OpenGL rasterizes:

      • Generates a fragment for each pixel the fragment covers, along with all the necessary properties of that fragment

        • such as texture coordinates

  1. (Attach other canvases to the easel and continue painting)

    Same as 3.

  2. (Use previous paintings for reference) Multiple passes

    • Use your previous painting for reference

 

Summary: in each pass:

Finally, we can do multiple passes.

Basically, it is a State Machine.

 

The "real" action that we care about the most:

 

III. OpenGL Shading Language (GLSL)

Shading Languages

Shader Setup

 

Initializing Shaders (FYI)

 

Writing Shaders (FYI)

Important Concepts:

 

Important Concepts:

Debugging Shaders

 

IV. The Rendering Equation

In real-time rendering (RTR)

(1)Lo(p,ωo)=Le(p,ωo)+Ω+Li(p,ωi)fr(p,ωi,ωo)(nωi)V(p,ωi)dωi

 

Environment Lighting

 

Global Lighting