38
COMPUTER GRAPHICS CSCI 375

Computer Graphics CSCI 375

  • Upload
    ban

  • View
    76

  • Download
    0

Embed Size (px)

DESCRIPTION

Computer Graphics CSCI 375. What do I need to know?. Familiarity with Trigonometry Analytic geometry Linear algebra Data structures OOP. Computer Graphics (& Related Areas). Graphics 3D model => 2D image Image processing Computer vision 2D image => 3D model. Applications. Movies - PowerPoint PPT Presentation

Citation preview

Page 1: Computer Graphics CSCI 375

COMPUTER GRAPHICSCSCI 375

Page 2: Computer Graphics CSCI 375

What do I need to know?

Familiarity with Trigonometry

Analytic geometry

Linear algebra

Data structures

OOP

Page 3: Computer Graphics CSCI 375

Computer Graphics (& Related Areas) Graphics

3D model => 2D image

Image processing

Computer vision 2D image => 3D model

Page 4: Computer Graphics CSCI 375

Applications

Movies

Video games

Visualization

Simulation

Page 5: Computer Graphics CSCI 375

Image Processing

Manipulate 2D bitmaps

Applies directly to pixel grid Color correction Scaling Blurring Sharpening

Page 6: Computer Graphics CSCI 375

Image Synthesis

Graphics deals with image synthesis

Synthesis of 2D image from 3D scene description is called rendering

Page 7: Computer Graphics CSCI 375

Photorealistic Rendering

Indistinguishable from reality

Ray tracing

Page 8: Computer Graphics CSCI 375

PhotorealRendering

CG Choice Award Gallery:http://forums.cgsociety.org/forumdisplay.php?f=121

Page 9: Computer Graphics CSCI 375
Page 10: Computer Graphics CSCI 375

Non-Photorealistic Rendering Non-photoreal rendering

artificial water colors

pencil sketches

paint brushstrokes

Scientific and medical visualization

Page 11: Computer Graphics CSCI 375
Page 12: Computer Graphics CSCI 375

Computer Vision

2D images => 3D model

Aspects of AI

Page 13: Computer Graphics CSCI 375

Animation

Sequence of images

May be generated by physical simulation Rigid bodies Deformable objects Gasses, liquids Particle effects

Character animation

Page 14: Computer Graphics CSCI 375

Modeling

Creating 3D geometric data

3ds Max, Maya

Procedural modeling algorithms

Digitizers and computer vision

Mesh simplification

Page 15: Computer Graphics CSCI 375

Raster Graphics

Modern displays are raster based

Pixels and subpixels

Old style vector displays

Page 16: Computer Graphics CSCI 375

Framebuffer

Framebuffer Space for final image

Grid of pixels

Colors are usu. 24 bits

Depth (z)

Usu. on GPU

Page 17: Computer Graphics CSCI 375

Primitives

Complex scenes built from simpler objects

Objects built from primitives Point Line Triangle

Page 18: Computer Graphics CSCI 375

3D Models

Collection of triangles

Each triangle stores 3 vertices

Vertex position color normal

Page 19: Computer Graphics CSCI 375

3D Models

struct Vector3 {float x, y, z;

};

struct Vertex {Vector3 position;

};

struct Triangle {Vertex vertices[3];

};

class Model {std::vector<Triangle> triangles;

};

Page 20: Computer Graphics CSCI 375

Traditional Graphics Pipeline Primitives processed in stages

Transformation

Lighting

Clipping

Scan conversion

Fragment processing

Page 21: Computer Graphics CSCI 375

The Graphics PipelineModeling Transformations

Illumination(Lighting)

Viewing Transformation(Perspective / Orthographic)

Clipping

Projection (to Screen Space)

Scan Conversion(Rasterization)

Visibility / Display

Page 22: Computer Graphics CSCI 375

The Graphics Pipeline

Primitives are processed in stages

Each stage forwards result to next stage

Modeling Transformations

Illumination(Lighting)

Viewing Transformation(Perspective / Orthographic)

Clipping

Projection (to Screen Space)

Scan Conversion(Rasterization)

Visibility / Display

Page 23: Computer Graphics CSCI 375

Transformation

Transformations Rotation Translation Scales Projection

Matrices

Page 24: Computer Graphics CSCI 375

Modeling Transformations

3D models defined in own coordinate system (object/local space)

Modeling transforms orient models within a common coordinate frame (world space)

Modeling Transformations

Illumination(Lighting)

Viewing Transformation(Perspective / Orthographic)

Clipping

Projection (to Screen Space)

Scan Conversion(Rasterization)

Visibility / Display

Object space World space

Page 25: Computer Graphics CSCI 375

Viewing Transformation Maps world space to eye

space Viewing position is

transformed to origin & direction is oriented along some axis (usually z)

Modeling Transformations

Illumination(Lighting)

Viewing Transformation(Perspective / Orthographic)

Clipping

Projection (to Screen Space)

Scan Conversion(Rasterization)

Visibility / Display

Eye space

World space

Page 26: Computer Graphics CSCI 375

Projection Objects are projected to 2D

image place (screen space)

Modeling Transformations

Illumination(Lighting)

Viewing Transformation(Perspective / Orthographic)

Clipping

Projection (to Screen Space)

Scan Conversion(Rasterization)

Visibility / Display

NDC Screen Space

Page 27: Computer Graphics CSCI 375

Lighting

Vertex or fragment color

Different light types

Shadows, reflections, and translucency

Page 28: Computer Graphics CSCI 375

Lighting

Vertices lit according to material properties, surface properties (normal) and light sources

Local lighting model (diffuse, ambient, Phong, etc.)

Modeling Transformations

Illumination(Lighting)

Viewing Transformation(Perspective / Orthographic)

Clipping

Projection (to Screen Space)

Scan Conversion(Rasterization)

Visibility / Display

Page 29: Computer Graphics CSCI 375

Clipping

Camera and view volume

Culling

Clipping

Outputs visible primitives

Page 30: Computer Graphics CSCI 375

Clipping Transform to Normalized

Device Coordinates (NDC)

Remove portions of object outside view volume

Modeling Transformations

Illumination(Lighting)

Viewing Transformation(Perspective / Orthographic)

Clipping

Projection (to Screen Space)

Scan Conversion(Rasterization)

Visibility / Display

Eye space NDC

Page 31: Computer Graphics CSCI 375

Scan Conversion

Scan conversion or rasterization 2D primitives => pixels

Per-vertex data is interpolated across the triangle

Page 32: Computer Graphics CSCI 375

Scan Conversion (Rasterization)

Rasterizes primitives into pixels

Interpolate values as we go (color, depth, etc.)

Modeling Transformations

Illumination(Lighting)

Viewing Transformation(Perspective / Orthographic)

Clipping

Projection (to Screen Space)

Scan Conversion(Rasterization)

Visibility / Display

Page 33: Computer Graphics CSCI 375

Fragment Processing

Output of rasterization Set of fragments Z-values …

Z-buffer algorithm

Texturing and transparency operations

Page 34: Computer Graphics CSCI 375

OpenGL

Open Graphics Library (OpenGL) Standard specification defining a cross-

platform API for writing 2D and 3D graphics apps

Cell phones to supercomputers Developed by SGI in 1992 Current version 4.4 Managed by non-profit Khronos Group

Consortium focused on open, royalty-free standards for authoring and acceleration of parallel computing, graphics, and dynamic media (OpenCL, OpenGL, OpenGL ES, WebGL, COLLADA)

Page 35: Computer Graphics CSCI 375

Supporting Infrastructure

OpenGL Application

GLEW GLUT

GLX, WGL

Windowing System (X, Windows)

GPU

Graphics Drivers

GL

Page 36: Computer Graphics CSCI 375

OpenGL Example

Drawing a colored triangle glBegin (GL_TRIANGLES); glColor3f (1.0f, 0.0f, 0.0f); glVertex3f (-1.0f, -1.0f, 0.0f); glColor3f (0.0f, 1.0f, 0.0f); glVertex3f (+1.0f, -1.0f, 0.0f); glColor3f (0.0f, 0.0f, 1.0f); glVertex3f (0.0f, +1.0f, 0.0f); glEnd ();

Inefficient; we’ll improve upon this

Page 37: Computer Graphics CSCI 375

OpenGL Program Organization main () { // Initialize and create window // Set up key and mouse event handlers // Initialize OpenGL // Set up lighting // Load assets

Page 38: Computer Graphics CSCI 375

OpenGL Program Organization (Cont’d) // Update and render loop while (userWantsToContinue) { // Clear screen // Specify camera position & orientation

(pose) for (Model model : scene) { // Specify object pose // Draw model // Frame completion code (buffer swap) } // Cleanup code }