30
A Few Things about Graphics Jian Huang Computer Science University of Tennessee

A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Embed Size (px)

Citation preview

Page 1: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

A Few Things about Graphics

Jian Huang

Computer Science

University of Tennessee

Page 2: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Graphics• Graphics studies light transport in 3D scene,

sometimes over time as well.• Example applications abound nowadays in

movies, MTVs, …• In a nutshell, it’s some math and methods to

compute such math efficiently on processors, memory banks and buses (lots of parallelism)

• Well, everything should start with that Rendering Equation

Page 3: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

The Rendering Equation• I(x,x’) = intensity passing from x’ to x• g(x,x’) = geometry term (1, or 1/r2, if x visible

from x’, 0 otherwise)• (x,x’) = intensity emitted from x’ in the direction

of x• (x,x’,x’’) = scattering term for x’ (fraction of

intensity arriving at x’ from the direction of x’’ scattered in the direction of x)

• S = union of all surfaces

Page 4: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

It’s not analytically solvable• So, instead of simply doing the math, can we use

computer to compute this equation in some simplified version (oftentimes, immensely)?

• When approximations are made, priorities are set accordingly to what is the most appealing to viewer given the current hardware capability

• The consumer of the result is human being, so the measurement of good and bad is not as conventional as other computer science disciplines

Page 5: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

What does it take to get that equation done?

• First, one has to model the scene– What color model is used (RGB, HSV)– Surfaces as geometrical meshes (volumes …)– Materials as lighting and texturing parameters– Light sources

• Second, compute the result for a screen device as it would appear on a retina – the rendering process– The graphics pipeline– Speed and high quality (30 fps, 60 fps, 120 fps)– Framebuffer: 320x240, 640x480, …, 1024x768, … 6000x6000. – Popular engines use OpenGL or DX, D3D libraries

Page 6: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Geometric Primitives

• All geometric primitives are specified by vertices

Page 7: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Transformations• Modeling transformations

• build complex models by positioning simple components

• Viewing transformations

• place virtual camera in the world

• transform from world coordinates to eye coordinates

• Vary transformations over time creates motion - Animation

WORLD

OBJECTEYE

Page 8: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Affine Transformation in 3D

• Translation

• Rotate

• Scale

• Shear

Page 9: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

1. 2.

3. 4.

5. 6.

Page 10: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

3D Models - The Mesh

Assembled scene

Page 11: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

A Virtual World

• Objects– Shape: meshed geometry (and topology)– Appearance: lighting, shading and texture

• Scene– Camera and viewing– Light position– Scene composition

Page 12: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Appearance

• Having just the geometry, objects don’t look right yet.

• The first step is to use light sources

• The second step is to put textures on

Page 13: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Multiple Light Source• IL: light intensity

• For multiple light sources– Repeat the diffuse and specular calculations for each light source– Add the components from all light sources– The ambient term contributes only once

• The different reflectance coefficients can differ. – Simple “metal”: ks and kd share material color, – Simple plastic: ks is white

• Remember, when cosine is negative lighting term is zero!

Page 14: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Un-lit

Page 15: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Smooth Shaded

Page 16: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

What is a Texture?

• Color

• Specular ‘color’ (environment map)

• Normal vector perturbation (bump map)

• Displacement mapping

• Transparency

• ...

Page 17: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Rendering

Page 18: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Textures Make A Difference

• Good textures, when applied correctly, make a world out of nothing!

Page 19: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Examples

Page 20: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Examples (cont.)

Page 21: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Examples (cont.)

Page 22: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Before and After “Good” Texture

Page 23: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Before and After “Good” Texture

Page 24: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

More

Page 25: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Every Renderer is a State Machine

• All rendering attributes are encapsulated in the as states

• Transformations• Viewing• Rendering styles• Shading• Lighting• Texture mapping

Page 26: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

The Punch Line• Graphics models the world with geometry and

appearance attributes

• The rendering process is extremely computation-intensive. What processor won Processor-Of-The-Year award last year?

• The graphics state is complicated to maintain.• The requirement is high interactivity

Page 27: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Distributed Graphics• Systems for distributing the shared graphical state

of multi-display, multi-person, distributed, interactive applications

Page 28: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Distributed Graphics

• Two key problems:– The graphics database needs to be distributed

• Replication is a standard go-around

– The graphics states are distributed• This is the tricky part

Page 29: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Distributed Graphics

• Two major categories:– Data can be replicated (let’s do this!)– Data can not be replicated

• Dependent on the choice– Drastically different approach– Specific pros and cons

• Let’s make sure graphics states are shared properly

Page 30: A Few Things about Graphics Jian Huang Computer Science University of Tennessee

Distributed vs. Monolithic Apps

• Distributed control– In a non-trivial distributed application, different components need

to be notified of changes to the distributed state

• Interactivity– Network latency bandwidth limitations make updates to

distributed state much slower. For performance, need to perform some operations locally

• Local variations– There are times when a shared graphical scene may need to be

modified locally