Interactive Computer Graphics Chapter 1

Report
Cs 352:
Interactive
2D and 3D
Computer Graphics
Chapter 1 - 2
Interactive 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
Chapter 1 - 3
Interactive Computer Graphics
Aspects of Graphics




Design vs. Programming
Interactive vs. Photorealistic
2D vs. 3D
Graphics vs. image processing vs. user
interfaces
Chapter 1 - 4
Interactive Computer Graphics
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
Chapter 1 - 5
Interactive Computer Graphics
Comet Simulation
COMET CRASH - Sandia
supercomputer
simulations of a onekilometer 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.
Chapter 1 - 6
Interactive Computer Graphics
Ray-traced Image
Chapter 1 - 7
Interactive Computer Graphics
Chapter 1 - 8
Interactive Computer Graphics
Intelligence Chart
Chapter 1 - 10
Interactive Computer Graphics
Nvidia: Moore's Law is Dead,
Multi-core Not Future
Chapter 1 - 11
Interactive Computer Graphics
History of Interactive Graphics
http://www.geeks3d.com/20080810/graphics-rendering-pipelines/
Chapter 1 - 12
Interactive Computer Graphics
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, …
Chapter 1 - 13
Interactive Computer Graphics
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?
Chapter 1 - 14
Interactive Computer Graphics
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
4.3, 4.4, 4.5
Chapter 1 - 15
http://wiki.maemo.org/OpenGL-ES
Interactive Computer Graphics
Chapter 1 - 16
Interactive Computer Graphics
Refraction using vertex shaders
Chapter 1 - 17
Interactive Computer Graphics
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, Maemo, WebGL,
Blackberry, WebOS…
Version 3.0, 2012: texture compression, new version of
GLSL ES, 32-bit floats, enhanced texturing
Chapter 1 - 18
Interactive Computer Graphics
OpenGL vs. proprietary

OpenGL






DirectX:




Older
Has survived the Direct3D challenge and emerged as
undisputed standard for 3D graphics programming (apart
from Windows games)
Used more for professional applications
Mobile gaming is mostly on OpenGL ES
Unreal, Unity, other game engines on OpenGL ES
MS only
Used more for games
Latest versions are good
Metal (Apple)
Chapter 1 - 19
Interactive Computer Graphics
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)
Chapter 1 - 20
Interactive Computer Graphics
Chapter 1 - 21
Interactive Computer Graphics
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
Chapter 1 - 22
Interactive Computer Graphics
Chapter 1: Graphics Systems and Models

A Graphics System



Processor
Memory
Frame Buffer
 Display
 Input Devices
 Output Devices
Chapter 1 - 23
Interactive Computer Graphics
Graphics Architecture
Chapter 1 - 24
Images



Array of pixels
Red, Green, Blue
May also have an
alpha value
(opacity)
Interactive Computer Graphics
Chapter 1 - 25
Interactive Computer Graphics
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
Chapter 1 - 26
Interactive Computer Graphics
Display terms







Scan line
Resolution
Horizontal and vertical re-trace
Refresh, refresh rate
Interlace
NTSC, PAL, S-video, Composite, Component
HDTV
Chapter 1 - 27
Interactive Computer Graphics
LCD Display

An unpowered LCD layer changes
polarization of light
Chapter 1 - 28
Interactive Computer Graphics
The Human Visual System




Rods: night vision
Cones: day vision
Three types of
cones, with
different color
sensitivity
We model and
render for its
capabilities
Chapter 1 - 29
Interactive Computer Graphics
Spectral Sensitivity

Color spectrum: 780 nm (blue)…350 nm (red)
Chapter 1 - 30
Interactive Computer Graphics
Graphics Paradigms


Modeling
Rendering

Photo-realistic:



Ray tracing
Radiosity
Interactive:





Projection – camera model
Transformations, clipping
Shading
Texture mapping
Rasterization
Chapter 1 - 31
Interactive Computer Graphics
Ray Tracing
Ray Tracing
Chapter 1 - 32
Ray-traced blob
Interactive Computer Graphics
Chapter 1 - 33
Interactive Computer Graphics
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)
Chapter 1 - 34
Interactive Computer Graphics
Modeling the World
camera {
location
look_at
angle 58
}
<0, 5, -5>
<0, 0, 0>
light_source { <-20, 30, -25>
color red 0.6 green 0.6 blue 0.6 }
blob {
threshold 0.5
sphere
{ <-2, 0, 0>,
cylinder { <-2, 0, 0>,
cylinder { <0, 0, -2>,
cylinder { <0, -2, 0>,
pigment { color red 1
finish
{ ambient 0.2
rotate <0, 20, 0>
}
1, 2 }
<2, 0, 0>, 0.5, 1
<0, 0, 2>, 0.5, 1
<0, 2, 0>, 0.5, 1
green 0 blue 0 }
diffuse 0.8 phong
}
}
}
1 }
Chapter 1 - 35
Ray thru pixel
Interactive Computer Graphics
Chapter 1 - 36
Flat blob
Interactive Computer Graphics
Chapter 1 - 37
Interactive Computer Graphics
Bounce toward lights
Chapter 1 - 38
Shadows
Interactive Computer Graphics
Chapter 1 - 39
Shaded blob
Interactive Computer Graphics
Chapter 1 - 40
Interactive Computer Graphics
Blob with Highlights
Chapter 1 - 41
Interactive Computer Graphics
Blob with ground plane
Chapter 1 - 42
Interactive Computer Graphics
Blob with transparency
Chapter 1 - 43
Interactive Computer Graphics
Blob with refraction
Chapter 1 - 44
Interactive Computer Graphics
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
Chapter 1 - 45
Interactive Computer Graphics
What are these made of?
Chapter 1 - 46
Interactive Computer Graphics
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
Chapter 1 - 47
Finishes
Interactive Computer Graphics
Chapter 1 - 48
Textures
Interactive Computer Graphics
Chapter 1 - 49
Interactive Computer Graphics
Surface (Ripples)
Chapter 1 - 50
Interactive Computer Graphics
POV-Ray Primitives
Chapter 1 - 51
Interactive Computer Graphics
Constructive Solid Geometry
Chapter 1 - 52
Sunsethf
Interactive Computer Graphics
Chapter 1 - 53
Interactive Computer Graphics
How to ray-trace…





Transparency?
Refraction?
Reflection?
Fog?
Anti-aliasing?
Chapter 1 - 54
Interactive Computer Graphics
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?
Hard lighting

No soft shadows, inter-object diffusion, etc
Chapter 1 - 55
Interactive Computer Graphics
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
Chapter 1 - 56
Interactive Computer Graphics
Beyond Ray Tracing

Problems with ray tracing:



hard shadows
no color bleeding
slow
Chapter 1 - 57
Interactive Computer Graphics
Radiosity in POV-Ray
Chapter 1 - 58
Interactive Computer Graphics
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
Chapter 1 - 59
Radiosity image
Interactive Computer Graphics
Chapter 1 - 60
Radiosity - table
Interactive Computer Graphics
Chapter 1 - 61
Interactive Computer Graphics
Image: Wikipedia
Chapter 1 - 62
Interactive Computer Graphics
Radiosity example
Chapter 1 - 63
Interactive Computer Graphics
Source: ACM
Chapter 1 - 64
Interactive Computer Graphics
Form factors


We need to know the percentage of the light
leaving one patch that reaches another (form
factor).
How to compute?
Chapter 1 - 65
Interactive Computer Graphics
Hemicube algorithm

Hemicube algorithm for form factor
computation:



Put a hemicube around patch reference point
Render an image in each of five directions
Count pixels…
Chapter 1 - 66
Interactive Computer Graphics
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)
Chapter 1 - 67
Interactive Computer Graphics
Interactive techniques

Ray tracing and radiosity are too slow
We'll concentrate on interactive techniques

What kind of rendering can be done quickly?

Chapter 1 - 68
Interactive Computer Graphics
Shutterbug - Orthographic
Chapter 1 - 69
- Perspective
Interactive Computer Graphics
Chapter 1 - 70
- Depth Cueing
Interactive Computer Graphics
Chapter 1 - 71
- Depth Clipping
Interactive Computer Graphics
Chapter 1 - 72
- Colored Edges
Interactive Computer Graphics
Chapter 1 - 73
Interactive Computer Graphics
- Hidden line removal
Chapter 1 - 74
Interactive Computer Graphics
- Hidden surface removal
Chapter 1 - 75
- Flat shading
Interactive Computer Graphics
Chapter 1 - 76
Interactive Computer Graphics
- Gouraud shading
Chapter 1 - 77
Interactive Computer Graphics
- Gouraud/specular
Chapter 1 - 78
Interactive Computer Graphics
- Gouraud/phong
Chapter 1 - 79
Interactive Computer Graphics
- Curved surfaces
Chapter 1 - 80
Interactive Computer Graphics
- Improved illumination
Chapter 1 - 81
Interactive Computer Graphics
- Texture mapping
Chapter 1 - 82
Interactive Computer Graphics
- Displacements, shadows
Chapter 1 - 83
- Reflections
Interactive Computer Graphics
Chapter 1 - 84
Interactive Computer Graphics
Rendering pipeline

Transformations
Clipping
Projection
Rasterization

(what is done where?)




similar documents