Computer Graphics: Visualisation Lecture 3 Taku Komura - - PowerPoint PPT Presentation

computer graphics
SMART_READER_LITE
LIVE PREVIEW

Computer Graphics: Visualisation Lecture 3 Taku Komura - - PowerPoint PPT Presentation

Visualisation : Lecture 2 Computer Graphics: Visualisation Lecture 3 Taku Komura tkomura@inf.ed.ac.uk Institute for Perception, Action & Behaviour Taku Komura Computer Graphics & VTK 1 Visualisation : Lecture 2 Last lecture


slide-1
SLIDE 1

Taku Komura Computer Graphics & VTK 1 Visualisation : Lecture 2

Computer Graphics:

Visualisation – Lecture 3 Taku Komura tkomura@inf.ed.ac.uk Institute for Perception, Action & Behaviour

slide-2
SLIDE 2

Taku Komura Computer Graphics & VTK 2 Visualisation : Lecture 2

Last lecture .....

  • Visualisation can be greatly enhanced through the

use of 3D computer graphics

– computer graphics are our tool in visualisation

  • In order to do effective visualisation we need:

– to know some computer graphics (this lecture)

slide-3
SLIDE 3

Taku Komura Computer Graphics & VTK 3 Visualisation : Lecture 2

Computer Graphics : simulation

  • f light behaviour in 3D
  • Effective simulation requires to

model:

– object representation

(geometry)

– object illumination

(lighting)

– camera model

(vision)

— world to image plane projection — rendering: converting

graphical data into an image

3D scene (e.g. real world)

Object with surfaces Light Source(s) Camera Model Rendering

  • n image plane
slide-4
SLIDE 4

Taku Komura Computer Graphics & VTK 4 Visualisation : Lecture 2

Overview of Computer Graphics

  • Data representation
  • Lighting

– illumination

— Ambient — Diffuse — Specular

– Shading – Lighting and surface shape perception

  • Camera model
slide-5
SLIDE 5

Taku Komura Computer Graphics & VTK 5 Visualisation : Lecture 2

Data Representation : 3D shape

  • Approximate smooth surfaces with flat,

planar polygons

– polygons formed of edges & vertices – vertex: positional point (2D or 3D) – edge: joins 2 vertices – polygon: enclosed within N edges

— polygons share common edges

– mesh: set of connected polygons forming a

surface (or object)

Hierarchy of Surface Representation

slide-6
SLIDE 6

Taku Komura Computer Graphics & VTK 6 Visualisation : Lecture 2

Surface mesh : examples

(close up)

  • Several primitives utilised, triangles generally

fastest to draw

modern graphics cards : 20-225 million + triangles per second

slide-7
SLIDE 7

Taku Komura Computer Graphics & VTK 7 Visualisation : Lecture 2

Different resolutions alter perception of surface smoothness resolution higher

slide-8
SLIDE 8

Taku Komura Computer Graphics & VTK 8 Visualisation : Lecture 2

Mesh Based Representation

  • 3D file formats:

– set of vertices in ℝ3

– polygons reference into vertex set

— implicitly define edges

e.g.

vertex 0 0 0 vertex 0 1 0 .... polyon 3 2 1 3 polyon 3 5 6 8 ...

  • perform transformations only on vertices

#VRML V1.0 ascii # Separator { Material { ambientColor 0.2 0.2 0.2 diffuseColor 1.0 1.0 1.0 } Coordinate3 { point [ 4.455030 -1.193380 1.930940, 4.581220 -1.506290 1.320410, 4.219560 -1.875190 1.918070, 3.535530 1.858740 -3.007500, 3.793260 1.185430 -3.034130, 4.045080 1.545080 -2.500000, 3.510230 3.468900 0.803110, 3.556410 3.514540 0.000000, 3.919220 3.078210 0.405431, .... .... IndexedFaceSet { coordIndex [ 0, 1, 2, -1, 3, 4, 5, -1, 6, 7, 8, -1, 9, 10, 11, -1, 12, 13, 14, -1, 15, 16, 17, -1, 18, 19, 20, -1, 21, 22, 23, -1, .... ....

slide-9
SLIDE 9

Taku Komura Computer Graphics & VTK 9 Visualisation : Lecture 2

Light interaction with surfaces

  • Simple 3 parameter model

– The sum of 3 illumination terms:

  • Ambient : 'background' illumination
  • Specular : bright, shiny reflections
  • Diffuse : non-shiny illumination and shadows

Object

Light source

(here point light source)

surface normal (specifies surface orientation)

'Virtual' camera

slide-10
SLIDE 10

Taku Komura Computer Graphics & VTK 10 Visualisation : Lecture 2

Ambient Lighting

Light from the environment

light reflected or scattered from other objects

simple approximation to complex 'real-world' process

Result: globally uniform colour for object

— Rc = resulting intensity curve — Lc = light intensity curve — Oc = colour curve of object

Object

Uniform Light source

c c

O L

= =

Colour Object Colour Light

Rc

c c c

O L R

=

On camera

Example: sphere

slide-11
SLIDE 11

Taku Komura Computer Graphics & VTK 11 Visualisation : Lecture 2

Diffuse Lighting

  • Also known as Lambertian reflection

considers the angle of incidence of light on surface

(angle between light and surface normal)

Result: lighting varies over surface with orientation to light

Object

Infinite point light source

On Ln

c n n c

O L O L

= −

  • =

=

Colour Object ) ( cos Colour Light  

θ

Rc θ

Rc=LcOccos

No dependence on camera angle!

Example: sphere (lit from left)

slide-12
SLIDE 12

Taku Komura Computer Graphics & VTK 12 Visualisation : Lecture 2

Specular Lighting

  • Direct reflections of light source off shiny
  • bject

specular intensity n = shiny reflectance of object

Result: specular highlight on object

Object On

Rc = colour curve Rn = camera position S (Reflection)

θ

Infinite point light source

Ln

No dependence on object colour.

c n n c

O L O L

= −

  • =

=

Colour Object ) ( cos Colour Light  

θ

α

slide-13
SLIDE 13

Taku Komura Computer Graphics & VTK 13 Visualisation : Lecture 2

Specular Light

slide-14
SLIDE 14

Taku Komura Computer Graphics & VTK 14 Visualisation : Lecture 2

Combined Lighting Models

  • Rc = wa(ambient) + wd(diffuse) +ws(specular)

– for relative weights wa, wd, ws – also specular power n

+ + = Ambient (colour) Diffuse (directional) Specular (highlights) Rc

slide-15
SLIDE 15

Taku Komura Computer Graphics & VTK 15 Visualisation : Lecture 2

Are we supposed to do the computation of lighting at all the points over the surface?

  • Depends on the shading model

– Flat Shading (once per polygon) – Gouraud shading (for all the vertex of the polygon) – Phong Shading (all the points)

slide-16
SLIDE 16

Taku Komura Computer Graphics & VTK 16 Visualisation : Lecture 2

Local Shading Models

  • Flat Shading (less computation needed)
  • Gouraud shading
  • Phong Shading (heavy computation needed)
slide-17
SLIDE 17

Taku Komura Computer Graphics & VTK 17 Visualisation : Lecture 2

How to compute the normal vectors?

  • The mesh is a set of polygons
  • We can compute the normal vectors for each polygon

(triangle)

  • We can color the whole polygon using the same normal

vector (flat shading)

slide-18
SLIDE 18

Taku Komura Computer Graphics & VTK 18 Visualisation : Lecture 2

Flat Shading

  • Compute the color at the middle of the polygon
  • All points in the same polygon are colored by

the same color

slide-19
SLIDE 19

Taku Komura Computer Graphics & VTK 19 Visualisation : Lecture 2

Computing the normal vectors of the vertices

  • We can compute the normals of the vertices by averaging

the normal vectors of the surrounding triangles

slide-20
SLIDE 20

Taku Komura Computer Graphics & VTK 20 Visualisation : Lecture 2

Gouraud Shading (Smooth Shading)

  • Compute the color at each vertex first
  • Compute the color inside the polygon by interpolating the

colors of the vertices composing the polygon

Ln

slide-21
SLIDE 21

Taku Komura Computer Graphics & VTK 21 Visualisation : Lecture 2

Phong Shading

  • interpolating the normal vectors at the vertices
  • Do the computation of illumination at each point in the

polygon

Ln

slide-22
SLIDE 22

Flat shaded Flat shaded Utah Teapot Utah Teapot Phong shaded Phong shaded Utah Teapot Utah Teapot

slide-23
SLIDE 23

Flat shaded spot lights Flat shaded spot lights Phong shaded Phong shaded spot lights spot lights

  • Gouraud shading is not good when the polygon

count is low

slide-24
SLIDE 24

Comparison

  • Summary

– Phong shading is good but computationally costly – Flat shading is easy but results are too bad – Gouraud shading is usually used for simple applications

slide-25
SLIDE 25

Taku Komura Computer Graphics & VTK 25 Visualisation : Lecture 2

Surface Shape Perception - 1

3D surface of the skin from a medical scanner. Diffuse lighting only. Light is coming from the top front

Perpendicular to light

Area perpendicular to the light can be recognized well

slide-26
SLIDE 26

Taku Komura Computer Graphics & VTK 26 Visualisation : Lecture 2

Surface Shape Perception - 2

3D surface of the skin from a medical scanner. Diffuse + specular lighting. Specular Power = 4.0

Edge of highlight

Area at the Edge of the highlight can be recognized well

slide-27
SLIDE 27

Taku Komura Computer Graphics & VTK 27 Visualisation : Lecture 2

Surface Shape Perception - 3

3D surface of the skin from a medical scanner. Diffuse + specular lighting. Specular Power = 200.0

Edge of highlight

slide-28
SLIDE 28

Taku Komura Computer Graphics & VTK 28 Visualisation : Lecture 2

Perception of Shape

  • Specular highlights

– improve perception of surface shape features (e.g. nose) – ... but only where the highlight occurs

slide-29
SLIDE 29

Taku Komura Computer Graphics & VTK 29 Visualisation : Lecture 2

Enhancing the Perception of Shape

  • Specular highlights

– We can

— dynamically change the specular power, — Rotate the light — Rotate the viewpoint

to enhance the perception of the shape >> changing the edge of the highlight

slide-30
SLIDE 30

Taku Komura Computer Graphics & VTK 30 Visualisation : Lecture 2

Other cues to shape

  • Texture
  • The motion/direction of lines or patterns
  • n the surface of the shape
  • Stereo
  • Viewing depth with 2 eyes
  • Stereo displays frequently used for visualisation
slide-31
SLIDE 31

Taku Komura Computer Graphics & VTK 31 Visualisation : Lecture 2

Scene Coordinate Systems

Object A’s Coordinate System 3D (x,y,z) Object B’s Coordinate System 3D (x,y,z)

Object Coordinates

World Coordinates

  • Light Position
  • Camera Position
  • Object Position(s)

3D (x,y,z)

Object A’s Transform Objects B’s Transform

Display transform

  • Window size
  • Position

2D (x,y) Camera transform

  • 4x4 Matrix (3D→2D)
  • 1

1

View Coordinates

1

  • 1

Display Coordinates

  • Object / World co-ordinates:

transformations and rotations in ℝ3

  • Camera transform: 3D→2D matrix

transformation (perspective projection).

slide-32
SLIDE 32

Taku Komura Computer Graphics & VTK 32 Visualisation : Lecture 2

Camera Model

Position View Up

View angle

Front Clipping Plane

Direction of Projection

  • Perspective projection (3D world → 2D image plane rendering)

all rays into camera go through a common point

  • View Frustrum – 3D space viewable to camera

bound by clipping planes (front, back); by camera view angle (top, bottom)

clipping planes eliminate data that is too near or too distant from camera

Back Clipping Plane View Frustrum

slide-33
SLIDE 33

Taku Komura Computer Graphics & VTK 33 Visualisation : Lecture 2

Summary

  • Computer Graphics (basics)

– representing object geometry as polygon meshes – illumination models (ambient, diffuse, specular) – Shading models (flat, Gouraud, Phong) – camera model & projection

  • Next lecture: systems architectures for visualisation