Cs 352:

83
Cs 352: Interacti ve 2D and 3D Computer Graphics

description

Cs 352:. Interactive. 2D and 3D. Computer Graphics. This Class. Interactive 2D and 3D Graphics Programming (with a taste of photorealistic graphics, image processing, and modeling) Top-down approach. Course Information Syllabus Policies Platform Projects. Aspects of Graphics. - PowerPoint PPT Presentation

Transcript of Cs 352:

Page 1: Cs 352:

Cs 352:

Interactive2D and 3D

Computer Graphics

Page 2: Cs 352:

Interactive Computer GraphicsChapter 1 - 2

This Class Interactive 2D and 3D Graphics

Programming (with a taste of photorealistic graphics,

image processing, and modeling) Top-down approach

Course Information Syllabus Policies Platform Projects

Page 3: Cs 352:

Interactive Computer GraphicsChapter 1 - 3

Aspects of Graphics Design vs. Programming Interactive vs. Photorealistic 2D vs. 3D Graphics vs. image processing vs. user

interfaces

Page 4: Cs 352:

Kinds of Graphics Software Photoshop, Illustrator, etc. 3D Modeling (CAD, animation) Rendering (ray tracing, radiosity) Animation tools Graphics programming APIs (OpenGL,

DirectX) Scene graph libraries Game engines

Interactive Computer GraphicsChapter 1 - 4

Page 5: Cs 352:

Interactive Computer GraphicsChapter 1 - 5

Comet SimulationCOMET CRASH -

Sandia supercomputer simulations of a one-kilometer comet entering Earth's atmosphere, approaching the ocean's surface, and impacting the ocean, deforming the ocean floor and creating a giant high-pressure steam explosion rising into the stratosphere. The explosion ejects comet vapor and water vapor into ballistic trajectories that spread around the globe. The New York City skyline is shown for scale.

Page 6: Cs 352:

Interactive Computer GraphicsChapter 1 - 6

Ray-traced Image

Page 7: Cs 352:

Interactive Computer GraphicsChapter 1 - 7

Page 8: Cs 352:

Interactive Computer GraphicsChapter 1 - 8

OpenGL OpenGL: a widely-used, open API for 3D

graphics Old, originally from Silicon Graphics (SGI) Low-level, procedural (vs. scene graph retained

mode) Designed for speed, control over hardware Need hardware support for top performance Widely used for CAD, VR, visualization, flight

simulators Managed by non-profit “Khronos Group” consortium

Support All major graphics cards, platforms have support Mobile devices (iOS, Android) use an embedded

version HTML5 has experimental WebGL support Bindings for JavaScript, Java, C#, Perl, Python, Ruby, Scheme, Visual

Basic, Ada, …

Page 9: Cs 352:

Graphics Only OpenGL does not support windowing,

interaction, UI, etc It must be used with another windowing

system/library such as MS Windows—various Cocoa X11 Qt GLUT, GLFW HTML5 JavaScript?

Interactive Computer GraphicsChapter 1 - 9

Page 10: Cs 352:

History GL (SGI), 1980s to early 1990s [

reality engine?] OpenGL Architecture Review Board,

1992 Selected versions:

1.0, 1992 (Happy Twentieth birthday!) 1.3, 2001—better texture support 2.0, 2004—GLSL (GL Shading Language, user

programmable vertex shaders) 3.0, 2008—plan: fundamental changes to the API—

no longer state-based, requires use of GLSL 1.3. Compromise: old API deprecated (but still used)

4.1, 2010—new geometry control, shaders, OpenGL ES 2.0 compatibility

Interactive Computer GraphicsChapter 1 - 10

Page 11: Cs 352:

OpenGL ES OpenGL ES (for Embedded Systems) is a

subset of OpenGL for mobile phones, consoles, etc

Common and Common Lite profiles (lite profiles are fixed-point only)

Version 2.0 released in 2007 GLSL for shaders Supported in iOS, Android, WebGL,… Version 3.0, 2012: texture compression, new

version of GLSL ES, 32-bit floats, enhanced texturing

Interactive Computer GraphicsChapter 1 - 11

Page 12: Cs 352:

http://wiki.maemo.org/OpenGL-ES

Interactive Computer GraphicsChapter 1 - 12

Page 13: Cs 352:

Refraction using vertex shaders

Interactive Computer GraphicsChapter 1 - 13

Page 14: Cs 352:

OpenGL vs. proprietary OpenGL

Older Has survived the Direct3D challenge and emerged

as undisputed standard for 3D graphics programming

Used more for professional applications Mobile gaming is mostly on OpenGL ES Unreal, Unity, other game engines on OpenGL ES

DirectX: MS only Used more for games Latest versions are good

Metal (Apple)

Interactive Computer GraphicsChapter 1 - 14

Page 15: Cs 352:

WebGL OpenGL 2.0 ES in your Web browser, no

plugins needed! Supported by all major browsers except

IE (Microsoft hates Web standards, OpenGL)

Working group: Apple, Google, Mozilla, Opera (not Microsoft)

Interactive Computer GraphicsChapter 1 - 15

Page 16: Cs 352:

Interactive Computer GraphicsChapter 1 - 16

Page 17: Cs 352:

Interactive Computer GraphicsChapter 1 - 17

Other software we’ll use POV ray-tracer ImageMagick image manipulation

library 3D Modeling: Google's SketchUp or

Blender HTML5 Canvas element for 2D graphics

The only cross-platform environment nowadays…

Overview Three.js graphics library for WebGL

Page 18: Cs 352:

Interactive Computer GraphicsChapter 1 - 18

Chapter 1: Graphics Systems and Models A Graphics

System Processor Memory Frame Buffer

Display Input Devices Output Devices

Page 19: Cs 352:

Interactive Computer GraphicsChapter 1 - 19

Images Array of pixels Red, Green, Blue May also have analpha value(opacity)

Page 20: Cs 352:

Interactive Computer GraphicsChapter 1 - 20

Pixels and the Frame Buffer Pixels:

picture elements 3 values: RGB, 0-255 or 0-65536 or 0.0-1.0 4 values: RGBA (Alpha = opacity)

Frame buffer Depth: bits per pixel May have 24, 32, 64, or flexible depth

HDR

Page 21: Cs 352:

Interactive Computer GraphicsChapter 1 - 21

The Human Visual System Rods: night vision Cones: day vision Three types of

cones, with different color sensitivity

We model andrender for itscapabilities

Page 22: Cs 352:

Interactive Computer GraphicsChapter 1 - 22

Page 23: Cs 352:

Interactive Computer GraphicsChapter 1 - 23

Spectral Sensitivity

Color spectrum: 780 nm (blue)…350 nm (red)

Page 24: Cs 352:

Interactive Computer GraphicsChapter 1 - 24

Page 25: Cs 352:

Interactive Computer GraphicsChapter 1 - 25

Display terms Scan line Resolution Horizontal and vertical re-trace Refresh, refresh rate Interlace NTSC, PAL, S-video, Composite,

Component HDTV

Page 26: Cs 352:

Interactive Computer GraphicsChapter 1 - 26

LED Display

Page 27: Cs 352:

Interactive Computer GraphicsChapter 1 - 27

Graphics Paradigms Modeling Rendering

Photo-realistic: Ray tracing Radiosity

Interactive: Projection – camera model Transformations, clipping Shading Texture mapping Rasterization

Page 28: Cs 352:

Interactive Computer GraphicsChapter 1 - 28

Ray Tracing

Ray Tracing

Page 29: Cs 352:

Interactive Computer GraphicsChapter 1 - 29

Ray-traced blob

Page 30: Cs 352:

Interactive Computer GraphicsChapter 1 - 30

How does Ray-Tracing work? Modeling

Build a 3D model of the world Geometric primitives Light sources Material properties

Simulate the bouncing of light rays Trace ray from eye through image pixel to see

what it hits From there, bounce ray in reflection direction,

towards light source, etc. Thus, model physics of emission, reflection,

transmission, etc. (backwards)

Page 31: Cs 352:

Interactive Computer GraphicsChapter 1 - 31

Modeling the Worldcamera { location <0, 5, -5> look_at <0, 0, 0> angle 58}

light_source { <-20, 30, -25> color red 0.6 green 0.6 blue 0.6 }

blob { threshold 0.5 sphere { <-2, 0, 0>, 1, 2 } cylinder { <-2, 0, 0>, <2, 0, 0>, 0.5, 1 } cylinder { <0, 0, -2>, <0, 0, 2>, 0.5, 1 } cylinder { <0, -2, 0>, <0, 2, 0>, 0.5, 1 } pigment { color red 1 green 0 blue 0 } finish { ambient 0.2 diffuse 0.8 phong 1 } rotate <0, 20, 0>}

Page 32: Cs 352:

Interactive Computer GraphicsChapter 1 - 32

Ray thru pixel

Page 33: Cs 352:

Interactive Computer GraphicsChapter 1 - 33

Flat blob

Page 34: Cs 352:

Interactive Computer GraphicsChapter 1 - 34

Bounce toward lights

Page 35: Cs 352:

Interactive Computer GraphicsChapter 1 - 35

Shadows

Page 36: Cs 352:

Interactive Computer GraphicsChapter 1 - 36

Shaded blob

Page 37: Cs 352:

Interactive Computer GraphicsChapter 1 - 37

Blob with Highlights

Page 38: Cs 352:

Interactive Computer GraphicsChapter 1 - 38

Blob with ground plane

Page 39: Cs 352:

Interactive Computer GraphicsChapter 1 - 39

Blob with transparency

Page 40: Cs 352:

Interactive Computer GraphicsChapter 1 - 40

Blob with refraction

Page 41: Cs 352:

Interactive Computer GraphicsChapter 1 - 41

Types of illumination Ambient – "light soup" that affects

every point equally Diffuse – shading that depends on the

angle of the surface to the light source Specular – 'highlights.' Falls off sharply

away from the reflection direction

Example: lighted teapot

Page 42: Cs 352:

Interactive Computer GraphicsChapter 1 - 42

What are these made of?

Page 43: Cs 352:

Interactive Computer GraphicsChapter 1 - 43

Material types Dielectrics (non-conductors):

In body reflection, light penetrates the surface and is affected by material pigment

Highlights are the color of the light source Examples: paint, plastic, wood, …

Conductors (metals) No light penetrates the surface Highlight and "body" reflection are affected

equally by the material Same color for diffuse and specular

reflection

Page 44: Cs 352:

Interactive Computer GraphicsChapter 1 - 44

Finishes

Page 45: Cs 352:

Interactive Computer GraphicsChapter 1 - 45

Textures

Page 46: Cs 352:

Interactive Computer GraphicsChapter 1 - 46

Surface (Ripples)

Page 47: Cs 352:

Interactive Computer GraphicsChapter 1 - 47

POV-Ray Primitives

Page 48: Cs 352:

Interactive Computer GraphicsChapter 1 - 48

Constructive Solid Geometry

Page 49: Cs 352:

Interactive Computer GraphicsChapter 1 - 49

Sunsethf

Page 50: Cs 352:

Interactive Computer GraphicsChapter 1 - 50

How to ray-trace… Transparency? Refraction? Reflection? Fog? Anti-aliasing?

Page 51: Cs 352:

Interactive Computer GraphicsChapter 1 - 51

Drawbacks of ray tracing? Time: many rays are needed per pixel…

Up to 25 rays through each pixel Each ray may bounce and split many times Each ray tested for intersection with many

objects E.g. 1M pixels * 25 rays per pixel * 40 rays

per ray tree * 1000 objects = 1 trillion object intersection tests…

Too slow for real time? Shape limitations Hard lighting

No soft shadows, inter-object diffusion, etc

Page 52: Cs 352:

Interactive Computer GraphicsChapter 1 - 52

POV-Ray An excellent, free ray tracer: POV-Ray We'll use for a brief intro to ray tracing Runs on PC, Unix, Mac, Beowolf

clusters, … Installed on the computers in the Unix

lab You may wish to install on your own

computer

First "lab": make a ray-traced image of four different types of primitives, one each plastic, glass, metal, and mirrored, over checked floor

Page 53: Cs 352:

Beyond Ray Tracing Problems with ray tracing:

hard shadows no color bleeding slow

Interactive Computer GraphicsChapter 1 - 53

Page 54: Cs 352:

Interactive Computer GraphicsChapter 1 - 54

Radiosity in POV-Ray

Page 55: Cs 352:

Interactive Computer GraphicsChapter 1 - 55

Radiosity Treat each patch as reflector and

emitter of light Each patch affects every other patch

depending on distance, orientation, occlusion etc.

Let light "bounce around" for a few iterations to compute the amount of light reaching a patch

Page 56: Cs 352:

Interactive Computer GraphicsChapter 1 - 56

Radiosity image

Page 57: Cs 352:

Interactive Computer GraphicsChapter 1 - 57

Radiosity - table

Page 58: Cs 352:

Image: Wikipedia

Interactive Computer GraphicsChapter 1 - 58

Page 59: Cs 352:

Interactive Computer GraphicsChapter 1 - 59

Radiosity example

Page 60: Cs 352:

Source: ACM

Interactive Computer GraphicsChapter 1 - 60

Page 61: Cs 352:

Form factors We need to know the percentage of the

light leaving one patch that reaches another (form factor).

How to compute?

Interactive Computer GraphicsChapter 1 - 61

Page 62: Cs 352:

Hemicube algorithm Form factor computation:

Put a hemicube around patch reference point

Render an image in each of five directions Count pixels…

Interactive Computer GraphicsChapter 1 - 62

Page 63: Cs 352:

Interactive Computer GraphicsChapter 1 - 63

Radiosity summary Radiosity gives wonderful soft shading But even slower than ray tracing… Can't do reflection, refraction, specular

highlights with radiosity Can combine ray tracing and radiosity

for best of both worlds (and twice the time)

Page 64: Cs 352:

Interactive Computer GraphicsChapter 1 - 64

Interactive techniques Ray tracing and radiosity are too slow We'll concentrate on interactive

techniques

What kind of rendering can be done quickly?

Page 65: Cs 352:

Interactive Computer GraphicsChapter 1 - 65

Shutterbug - Orthographic

Page 66: Cs 352:

Interactive Computer GraphicsChapter 1 - 66

- Perspective

Page 67: Cs 352:

Interactive Computer GraphicsChapter 1 - 67

- Depth Cueing

Page 68: Cs 352:

Interactive Computer GraphicsChapter 1 - 68

- Depth Clipping

Page 69: Cs 352:

Interactive Computer GraphicsChapter 1 - 69

- Colored Edges

Page 70: Cs 352:

Interactive Computer GraphicsChapter 1 - 70

- Hidden line removal

Page 71: Cs 352:

Interactive Computer GraphicsChapter 1 - 71

- Hidden surface removal

Page 72: Cs 352:

Interactive Computer GraphicsChapter 1 - 72

- Flat shading

Page 73: Cs 352:

Interactive Computer GraphicsChapter 1 - 73

- Gouraud shading

Page 74: Cs 352:

Interactive Computer GraphicsChapter 1 - 74

- Gouraud/specular

Page 75: Cs 352:

Interactive Computer GraphicsChapter 1 - 75

- Gouraud/phong

Page 76: Cs 352:

Interactive Computer GraphicsChapter 1 - 76

- Curved surfaces

Page 77: Cs 352:

Interactive Computer GraphicsChapter 1 - 77

- Improved illumination

Page 78: Cs 352:

Interactive Computer GraphicsChapter 1 - 78

- Texture mapping

Page 79: Cs 352:

Interactive Computer GraphicsChapter 1 - 79

- Displacements, shadows

Page 80: Cs 352:

Interactive Computer GraphicsChapter 1 - 80

- Reflections

Page 81: Cs 352:

Interactive Computer GraphicsChapter 1 - 81

Rendering pipeline

Where does lighting happen? Shading? Reflections? Resizing and moving objects? Textures? Bump mapping? Displacement mapping? Hidden surface removal?

Page 82: Cs 352:

History of Interactive Graphics

http://www.geeks3d.com/20080810/graphics-rendering-pipelines/

Interactive Computer GraphicsChapter 1 - 82

Page 83: Cs 352:

Nvidia: Moore's Law is Dead, Multi-core Not Future

Interactive Computer GraphicsChapter 1 - 83