177
CM30075: Computer Graphics www.bath.ac.uk/~maspmh/ Peter Hall [email protected]

CM30075: Computer Graphics maspmh/ Peter Hall [email protected]

Embed Size (px)

Citation preview

Page 1: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

CM30075: Computer Graphicswww.bath.ac.uk/~maspmh/

Peter Hall

[email protected]

Page 2: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

!!

Warning!!

These slides do not replace text book reading

Page 3: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

L01: about this course

Aim: to teach the elements of Computer GraphicsTraditional 3D photorealismModern use of images, and non-photorealism

Method: traditional formslecturespersonal readingpersonal practical work

Assumptions: knowledge of analytic mathematicsvectors and matricesintegration and differentiation

Page 4: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Lecture number / curriculum index Topic Learning objective

01 / 1 Introduction to CM30075And Compuer Graphics

Pointers to course materials given., Traditional Graphics outlined briefly.

Traditional Computer Graphics

02 / 1.1.1 Modelling – Brep The B-rep modelling scheme is introduced as just one way to build objects.

03 / 1.3.1 Rendering – cameras and projection Camera models introduced. Points are projected, so that objects models can be rendered as wire-frames.

04 / A.1 Rendering – ray-casting Lines intersected with planar polygons, result used as a basis for ray-casting. Now objects can be rendered to look solid.

05 / 1.2.1 Simple reflection models Point light sources are introduced; Lambertian and Specular reflection so objects can be shaded.

06 / 1.3.2 Rendering – ray tracing Cast shadows, reflection and refraction amongst many objects. Ray-tracing as a tree.

Milestone: material for advance practical work is now covered

07 / 1.2.2 Advance lighting and reflection The BRDF is introduced. Physical models of reflection and refraction.

08 / 1.2.3 The Lighting Equation;Radiosity

The full complexity of lighting is revealed; radiosity and ray-tracing are seen as specific solutions.

09/ 1.1.1 Modelling revisited – advanced B-rep Use of spline surfaces as B-rep models; how to define them and how to render them

10/ 1.1.2 Modelling revisited – CSG and Voxels Voxel models and Volume Rendering

11 / 1.1.3 Texture maps. Texture maps introduced as things to be rendered that relieve the burden of modelling. Aliasing issue is mentioned.

Milestone: static images now (mostly) covered

12 / 1.4.1 Animation basics The basics of animation are introduced from both technical and artistic points of view.

13 / 1.4.2 Articulated figures Modelling bodies and hierarchies of transforms; inverse kinematics/dynamics is discussed

14 / 1.4.3 Soft Objects and Fluids Elastic properties – use of physics – to model cloth, putty and such like, including fluids.

15 / 1.4.5 Fire and Fluids Use of dynamic textures and particles to model animate objects with no definitive boundary.

Milestone: Traditional Computer Graphics material covered

Modern Computer Graphics: Photograph editing and non-photorealistic rendering

16 / 2.1.1 Compositing How images layer to make a whole; simple methods for making panoramas from holiday snaps.

17 / 2.1.2 Panoramic Views How to make panoramas from holiday snaps – and from video too.

18 / 2.1.3 Intelligent scissors Cutting and pasting objects in pictures; so more on compositing

19 / 2.1.4 Texture Propagation Filling in holes in images, maybe left by cutting.

20 / 2.2.1 NPR from 3D models Why is photorealism the aim? People paint! How to paint, not photograph from models.

21 / 2.2.2 NPR from photos How can photographs be processed to look like a painting? Why is this difficult?

22 / 2.2.3 Generalised Cameras The eye of Art is often not a real camera!

Milestone: course content fully introduced

23 revision

24 revision

Page 5: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Reading

Lecture Slides• are NOT intended to replace text book reading.

Standard texts• Watt, 3D Computer Graphics, Addison Wesley.• Foley et al, 3D Computer Graphics, Addison Wesley.• Watt and Watt, Advanced Computer Graphics, Addison Wesley.

For the interested.• SIGGRAPH proceedings (published as journal special issue; Transactions on Graphics)

• Eurographics proceedings• IEEE Transactions on Visualization and Computer Graphics• Computer Graphics Forum

Page 6: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

PracticalAim: You are to write a simple ray-casting / ray-tracing program.

The practical work is broken into three stages

• ray-caster with self-shading

• cast-shadows

• full ray-tracer.

You should spend no more than 15 hours on this component;

including time to prepare the documents needed for your assessment.

Page 7: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Assessment

Assessment will cover all material given in lectures, in assigned reading and in practical work.

75% Sat ExaminationQuestions usually comprise 4 parts:a) Basic knowledge (3rd class)b) Moderate knowledge, basic understanding (2.2nd class)c) Good knowledge / moderate understanding (2.2nd class)d) Good understanding – can solve new problems (1st class)

25% practical workAlready explained

Page 8: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Computer Graphics Basics

focus

window

objectcamera

point (pixel)

Traditional: What colour is this pixel?

Page 9: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Rendering Pipeline

Make 3D models

transform models into place

illuminate models

project models

clip invisible parts

raterization

display

The rendering pipeline shows

the flow of information uses

and the processes needed

to synthesise an image.

In fact, there are many rendering pipelines.

The order of processes can change depending, for example, on whether rendering time or rendering quality is more important.

These different pipelines differ only in details – the general flow of information from 3D model to 2D image is always the same.

Page 10: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Modern approaches

point (pixel)

target image source image

What colour is this pixel?

Page 11: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

• The B-rep modelling scheme is introduced as just one way to build objects.

L02: B-rep basics

points points and lines points, lines, and polygons

Page 12: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk
Page 13: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

B-rep basics

Brep = Boundary Representation

Start with a set of M points p = { (x, y, z)i : i = 1…M }

Make a set of N lines from points L = { (i, j)k : k = 1…N }

Make a set of m polygons from lines B = { (k1, k2, …, kn}l : l = 1…m }

A model is three-dimensional (3D),

if the points are 3D (as above).

Page 14: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Different informationsupports different rendering

• points onlydots (used in Chemistry, also in modern Point based Rendering)

• linesWire-frame rendering, good for quick tests in animation, say

• polygonsshaded surfaces

points points and lines points, lines, and polygons

Page 15: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

x1 y1 z1

x2 y2 z2

xi yi zi

xM yM zM

2 i

2 k

1 3 4 6 8

2 1 7 * *

point table line table polygon table

!! ALWAYS INDEX POINTS !!

Practical Issues

• avoids repeated points, so more efficient

• avoids numerical error when animating

Page 16: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Different tables can be used

x1 y1 z1

x2 y2 z2

xi yi zi

xM yM zM

1 3 4

3 4 7

point table triangle table

Triangles are the most common polygon, because triangles are always flat.

But triangles are expensive – many of them; so other polygons used for modelling are often decomposed into triangles for rendering.

Page 17: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk
Page 18: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

A Minor Complication!! POINT ORDER MATTERS !!

anti-clockwiseclockwise

The ordering gives the polygon a “front” and “back”.

eh! which side is which?

Page 19: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

The normal of a triangular polygon

The normal of a polygon is used in lighting calculations (and in other calculations too).

Suppose a triangle has points, p, q, r, each point in 3D.

The normal direction is

n = (p-q) x (q-r)

where x is the vector cross product.

Exercise: Show that reversing the order of points also reverses the direction of the normal.

Page 20: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

build a table of trianglesfrom these points

1

2

3

4 5

6

7

8

Exercise: The points are randomly numbered.

From the view given,point 4 is at the back of the cube,point 5 is the nearest corner.

Build a table of trianglesin which vertices are consistentlyordered clockwise,when each face of the cube is viewedfrom the outside.

Page 21: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

B-rep basics: summary

• B-rep = boundary representation

• Models objects with points, lines, polygons

• Points are ordered around a polygon

• Best to index into tables

• The form of tables dictates rendering algorithms

Exercise: Build a 3D cube from well ordered triangles, render it as a wire-frame. See L03 for projection methods.

Page 22: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk
Page 23: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

• Camera models introduced.

• Points are projected, so that objects models can be rendered as wire-frames.

L03: Cameras and Projection

Page 24: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

The Linear CameraIn a linear camera

• rays of light travel in straight lines from a object

• the camera captures all rays passing through a single focus

• intersect a planar window to make the image

• the normal from the plane to the focus is the optical axis

focus

windowobject

image

ray

optical axis

Page 25: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

The Linear Camera

focuswindow

object

image

Two variants exist:

• the “physical” model – shown in the previous slidehas the focus between the object and the window,in which the image is inverted

• the “mathematical model” – which we use, is shown belowhas the window between the object and focusleaving the image the right way up

Page 26: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Basic Perspective Projection

h

W

wHh

w

Uses similar triangles to compute the height of the image

object

image

focus

W

H

Page 27: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

3D is almost as easy as 2D

),(),( yxz

fvu

v xu

y

zf

),,( zyx

),,( fvu

In the canonical camera, focal length (f) is taken as 1.

Page 28: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Homogeneous Points

Make projection easy and convenient

3D point (x, y, z) written as (x,y,z,1)homogeneous point (x, y, z, ) maps to real point 1/ (x, y, z)

The homogeneous points p = (x,y,z,1) and q = (sx, sy, sz, s)differ only by a scale factor s; this makes them equivalent in homogenous space.

Notice (x,y,z) and (sx,sy,sz) are two points on the same straight line passing through the origin. This makes them equivalent – they represent the same line!

In homogeneous space, lines and points are dual concepts!

Page 29: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

object point

image point

straight line (a ray of light)

focus:at the origin

a particular line – the optical axis – passesnormally through the window and through thefocus. This line has the image of the focus –a vanishing point.

the set of all rays projectnormally onto the windowto make a pattern of “spokes”

A little homogeneous geometry

window

a scaled version of the image

a scaled version of the object

Page 30: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Projection with a matrix

Using homogeneous coordinates, projection can be written as a matrix

we do need to divide by homogeneous depth, , after this

Compare this to with f = 1.),(),( yxz

fvu

Page 31: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

The camera as a matrixUsing a matrix for projection is very convenient in many ways.

1. It means we can model the camera as a matrix, C, say.Now projection of a homogenous point p is just

q = pCand we know that the homogeneous image point q is just a scale factor away from being correct – and all we need do is scale it by its depth (last element).

2. It means we can move the camera about in space just by pre-multiplying by a matrix transform

q = pMC

3. It means we can change the internals of the camera (focal length, aspect ratio, etc) by post-multiplying by a matrix

q = pMCK

4. We can do all of this at once! just set A = MCK, now A is a linear camera q = pA

Page 32: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Some Examples

Setting

using

rotates then translates the camera before projection.

Notice this is equivalent to applying M-1 to the point.

Page 33: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Another exampleTo change focal length, set

now post-multiply

Page 34: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

All at once

Define a new linear projective camera in a new place and with a new focal length

It is easy to use this camera…

Of course, you can set M and K as you please

– not just rotate and translate and new focal length!

Exercise: See notes for an exercise

Page 35: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Rendering with a Projection Matrix

1. Project all points using the projection matrix

2. Keep all points that lie within the window bounds

3. Connect points in the picture that are connected in 3D

If we had a model built just of points (no lines, planes etc) then we could make a simple images using this simple technique:

This produces a “wire frame” picture – easy, and fast!

If all pixels inside a projected triangle can be identified,then they too can be coloured.

This is the basis of scan-conversion.

Page 36: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

• Lines are intersected with planar polygons.

• The result used as a basis for ray-casting.

• Now objects can be rendered to look solid.

L04: Ray-Casting

Page 37: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Ray-casting algorithm

For each pixelCast a ray from the focus through the pixelCompute all intersections with all polygonsFind the nearest polygonColour pixel with polygon colour

Actually, the polygon colour is modified to create the effect of shading, as on a sphere.

Page 38: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Ray Casting Basics

• One ray per pixel, cast into the scene• Look for nearest intersection• Colour pixel accordingly

Expensive part: computing the intersection of a ray with a polygon

focus

pixel

window

scene of objects

camera

Page 39: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Line / Polygon intersection

p r

x(s)

c

n

an infinitely wide plane

an infinitely long line

compute scale factor

Given the scale factor,

the intersection is easy to get

Page 40: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Point Inside Triangle?inside

outside

all three “turns” are anti-clockwise some “turns” are anti-clockwise,others are clockwise

direction of turn:

p1

p2

p3

x

parallel direction of turn, sij > 0:

Page 41: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

A practical problem

The frame buffer is in the computer.

We imagine casting rays thru’ pixel centres

i

j

The window is in “space”;

where are pixel centres in space?

Page 42: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Solution: recall the camera as a matrix, C = MPK

y = xC = ((xM)P)K

• external parameters M locates the camera in spaceM is a 4x4 matrix, (eg rotation)notice M maps a model point in spaceuse the inverse of M to move camera!

• a projection P maps 3D points, to the windowP is rank degeneratecan be (4x3) but usually is (4x4)

• internal parameters, maps window points to frame-buffertransform confined to the planea matrix K (a 3x3 will do!)

Page 43: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

K

x

y

i

j

The internal parameters transform the pixels centres from “frame buffer” coordinates to “window coordinates”.

There is no single “answer” – here I’ve mapped a rectangular frame buffer to a window which is square, so pixels get stretched into rectangles – but you may keep pixels square.

pixel is typically at (j,i) point is at (x,y)

It is very common (almost universal) to “flip” coordinates so pixel (j,i) maps to location (x,y);and notices row (j) increase going DOWN - take care when designing K!

K-1

Page 44: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

The external parameters transforms the canonical camera

in “camera space” to the desired camera in “world space”.

M-1

M

Page 45: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Ray-casting takes a long time

Why does ray-casting take so long?

Because every ray is compared to every polygon.

Is this necessary?

What are bounding spheres?

Homework question: what is a BSP tree?

Page 46: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

• Point light sources are introduced.

• Lambertian and Specular reflection, so objects can be shaded.

L05: Simple Reflection

Page 47: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Point light sources

• A point light source is, er, a point (x,y,z) that emits light.

• Actually the point light can be at infinity (think of the sun), in which case (x,y,z) is its direction.

Most point lights sources are often at infinity in computer graphics.This makes shading/reflection efficient to compute because the direction of the light is the same for every intersection point.

Page 48: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Basic Reflection Model

mirror direction

light direction

surface normal

Mirror reflection - specular reflection – Phong reflectionDiffuse refection – Lambertian reflection

Page 49: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Diffuse/Lambertian ReflectionA beam of light spreads over an area, and is reflected equally in all directions.So here we’ve not drawn any reflected direction

The energy in the light is spread out more over the wider area.

So, the area will appear less bright.

over anarrow area over a wide area

these beamsare of equal width

Page 50: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Functional analogy: the sun warms the earth more near the equator than the pole

w

h

h = w/cos()

w

The light energy in the beam of width w is spread over a length h = w/cos().

Energy density in beam: I/w

Energy density on ground: I/h = Icos()/w

Page 51: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Lambertian reflection in Graphics

Iout = Ilightcos()The cosine we need is the dot (inner) product of the unit normal andunit vector pointing to the light.

We know that light from the source strikes a surface, to be spread equallyin all directions. So, only the angle between the light direction and thesurface is important.

Iout = Ilight n.l

BUT the surface can absorb some light, so only a fraction c is reflected

Iout = cIlight n.l

The “diffuse reflection coefficient” c depends on the surface material.

Page 52: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Diffuse reflection in colour

Rout = credRlight n.l

To handle colour is easy: just do the same calculation for each colour channel

Bout = cblueBlight n.l

Gout = cgreenGlight n.l

For white light, Rlight = Glight = Blight.

The coefficients c are often thought of as the colour of the material.

Page 53: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Specular Reflection

mirror direction, r

light direction, l

surface normal, n

eye direction, e

How much light is reflected in a particular direction?

Intuitively, the angle between the mirror and eye directions is important.Homework: The eye direction is a given, what is the mirror direction?

Page 54: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Phong Reflection

Phong’s specular reflection model

Iout = kIlight(r.e)n

Notice how the cosine (r.e) is used.

k is the “specular reflection coeffiecient” for the surface.

Phong reflection works for colourin just the same sort of way as Lambertian reflection

Page 55: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

A complete but simplereflection model

Iout = aIamb+ cIlight n.l + kIlight(r.e)n

A complete model (for a single colour channel) is

We see the diffuse and specular terms are added up.

There is an additional term for “ambient” light - this is light that comes equally from every direction- ambient light allows us see the very darkest regions of a picture

Specular highlights often look white, (just look around at things to see this) so k is often given the same value in every colour channel

Page 56: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Ray-tracing is a global lighting method.

• Cast shadows

• Reflection and refraction amongst many objects.

• Ray-tracing as a tree.

L06: Ray-tracing

Page 57: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Cast Shadows

Is the box resting on the table ?

Page 58: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Is a point in shadow?

point light

lightpoint

A point is in shadow if the line between it and a light is blocked by an object

Page 59: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

How can we tell?

The point to light ray is a line

Look for intersections of the this line with any object

This is almost an exact repetition of the ray-casting,

except intersections need not be ordered,

just finding one is enough

Page 60: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Reversibility of light

Ray tracing relies on a physical principle:a ray of light can be traced in either direction

So, if a ray of light splits into two parts then its energy is divided.

But we can “run this backwards” and add up the energy in the divided rays to get the energy in the original.

The paths of the light rays are identical, backwards or forwards.

Page 61: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Ray tracing extends ray casting

eye window

rayobject

reflected ray

intersection

refracted ray

Page 62: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Ray tracing tree

A ray/object intersection generate a new (reflected, refracted) pair of rays.These new rays also intersect to generate new rays, hence a tree

original ray from eye thru’ pixel

intersection

reflected refracted

intersection

reflected refracted

intersection

reflected refracted

Stop when a ray “leaves” the scene, or a set depth

intersection

a leaf

the root

a “parent” raywhen goingUP the tree

Page 63: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Using the tree in a simple wayThe ray-tracing tree is used “bottom up”, from the leaves to the root.

There are no reflected or refracted rays at a leaf.You can work out the light to the parent using the simple lighting model.But now the direction to the eye is in fact the direction of the parent ray.

The leaf contributes some energy to its parent,this parent receives light contributions from both its children.

Now work out the simple light model for the parent, as if it was a leaf,Add this to the contributions from its children.

And so on.

Page 64: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

A detail of the tree

surface

normalto light

mirrordirection

to parent

leaf intersectionlocal light only

surface

normal

to light mirrordirection

to parent

leaf intersectionlocal light only

surface

to parent

non-leaf intersectionlocal light + child rays

Page 65: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Whitted ray-tracingTurner Whitted produced the first ray-racer (1980).It was the first global illumination model. It includes

• Hidden surface removal• Self shading (as in diffuse/specular reflection)• Cast shadows• Reflection and refraction (making the model “global”)

The full coursework is to write a Whitted ray-tracer.

A restriction is to not include reflection and refraction, which is “advanced” ray casting.

A further restriction include self-shading only, which is “simple” ray-casting, and the minimum required to make a picture of some kind.

Page 66: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

• The BRDF is introduced.

• Physical models of reflection and refraction are considered.

L07: Advanced Reflectionand Refraction

Page 67: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Overall energy transfer

incident light Ein

reflected light, Erefl

refracted light, Erefr

schematically

Ein = Erefl + Erefr + Eabsconservation of energy

Page 68: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Recall the simple lighting model

c = kaIa + Ikd(n.l) + Iks(r.e)

This takes into account• ambient light• diffuse reflection• specular reflection

n

l re

The energy in the colour depends on where the viewer is, e,compared to the reflection r – and hence the light direction l.

Page 69: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

A visualisation

Suppose we set Ia = 0, I = 1, kd = 1, ks=1, and n.l = 1Furher, fix r. Now the lighting depends only on e and .In fact

c = 1 + e.r

to get a picture of how the energy depends on point of view

Page 70: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

A more general idea

The light energy depends on

• the direction of the incident light

• the direction of view

Page 71: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Diffuse/Specular lighting

diffuse to diffuse diffuse to specular

specular to diffuse specular to specular

Page 72: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

The BDRF

BDRF = bi-directional reflectance function

f(

f the fraction of light energy transferredfrom an incident light ray at (1,2)to viewing direction (1, 2)

In the simple model this is (e.r) in which r depends on input direction l.(Recall computing r from l is a homework!)

A full BDRF is even more complicated – wavelength, polarization…!

Page 73: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

The importance of the BDRF

The BDRF controls the kind of material an object appears to be made from, for example

• plastic

• metal

• ceramic

The simple model tends to make things look plastic.

Page 74: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Where do we get a BRDF from?

BRDF can be measured from the real thing; not easy!

In graphics, “micro-surfaces” can be used to estimate BRDF.

Look up Torrance Sparrow model.

see, eg www.cs.princeton.edu/~smr/cs348c-97/surveypaper.html

flat surface …under a microscope

a perfect mirroreach micro-facet a perfect mirrorbut overall surface is not!

Page 75: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

• The full complexity of global lighting

• radiosity in brief

• radiosity and ray-tracing as specific solutions

L08: The rendering equation

See: Watt & Watt, Advanced Animation and Rendering, subsec 12.2

Page 76: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Global LightingEvery object reflects light

(otherwise, it would look like a black hole)

So, every object can be reflected in every other !

This makes global lighting very complicated.

what colour is the light coming out?

light in

light out

Page 77: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Scattering, Shadows and refraction complicate further still !

light in

light out

and real cases are still more complicated !

Page 78: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Kajya’s rendering equation

The light transported from point y to point x

g(x,y) is the “visibility” function, 0 if x is in shadow wrt y, 1/|y-x|2 otherwise.

(x,y) is the transfer directly from y to x

(x,y,z) is BDRF (scattered light) toward x by y given light source at z

S is the set of all points in the scene

Important: I(.,.) appears both sides.

Page 79: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Use of Rendering Equation

Different lighting models are special-case solutions:

The local-model

Ray-tracing

Radiosity

Page 80: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

rewrite

as with R an integral operator

Now

hence

Solving the rendering equation

Page 81: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

consider

first term – direct (local) lighting: x is the eye, y a point

subsequent terms account for scattering from other points

Page 82: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Ray-tracing

• Forward ray-tracing (from the eye to lights)

– specular to specular : bounces, Phong term– specular to diffuse: Lambertian– diffuse to diffuse (but badly!): Ambient

• Backward ray-tracing (to the eye from lights)

– diffuse to specular

Page 83: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Radiosity

• Diffuse to Diffuse

This is the (badly modelled) “ambient” term in “local” models

light falls onto a patch from all others

light radiates to all other patches

Page 84: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

The light energy per unit area is called radiosity

total energy at a patch is its radiosity x its area

and energy is conserved, so at a patch

radiosity x area = emitted energy + reflected energy

Page 85: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

In a closed environment the energy transfer betweenpatches will reach an equilibrium.

If we use a discrete environment (ie a finite model),then we can use a discrete form of the radiosity equation

The form factors are correlated:

so that, on division by Ai we get the basic equation used:

Page 86: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

the radiosity equation in matrix form

the hard part is computing the form factors.

(See a standard text for how to do this)

Once they are at hand, solve the system for the B.

then render with a scan converter.

Page 87: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

• Spline surfaces as B-rep models

• How to define them

• How to render them

L09: Brep with curves

Page 88: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Many real world objects are curved.

But so far, we have used flat modelling primitives.

Here, we learn how to use curved primitives.

We first look at curve lines in space,

and then at curved surfaces in space.

Page 89: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Both curves and surfaces are collections of points in space.

The points are related to one another by some function or other.

In principle the curves and surfaces contain an infinite number of points,but in practice we are forced to use finitely many points.

And we can think of surfaces as a collection of curves

Page 90: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

There are many ways to define curves and surfaces

Implicit: “balances” a points coordinates

Unit Circle… x2 + y2 = 1

Unit sphere: x2 + y2 + z2 = 1

We will use implicit forms in CSG modelling.

Here we will use parametric forms.

Parametric forms allow you to compute points directly.

This is much better for Brep models.

Page 91: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Parametric forms allow you to compute points directly.

This is much better for Brep models.

Parametric curves require one parameter, u.

x(u)

is a point in 3D, on the curve.

Parametric surfaces require two parametersx(u,v)

is a point in 3D, on the surface.

Page 92: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Formally

x(u) is a mapping from the real line, R, to a subset of R3.

It’s as if the real line (x axis) is bent into the shape of the curve.

x(u,v) is a mapping from the real plane, R2, to a subset of R3.It’s as if the real plane (xy-plane) is bent into the shape of the curve.

u

u

v

x(u)

x(u,v)

Page 93: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Curves:

An easy way to specify a curve is with a polynomial;most modellers use cubics:

x(u) = a + bu + cu2 + du3

= [u3 u2 u 1][d c

b a]

The coefficients a, b, c, d specify the curve.

But this is not the most convenient way,because it’s hard to control.So the cubic is usually specified in some other way.

This is an abuse of notation!

Page 94: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Bezier Curves and Surfaces

are just one of the many alternatives

x(u) = UMP

U = [u3 u2 u 1]

M = [ -1 3 -3 1 3 -6 3 0 -3 3 0 0 1 0 0 0 ]

P = [p0

p1

p2

p3]

the “Bezier” matrix

parameter vector

4 control points

Page 95: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Examples of Bezier curves

control points

Bezier curve

Page 96: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Bezier surfaces

analogous issues over control of surfaces argue in favour of,

say, Bezier surfaces; again one of may controllable forms.

x(u,v) = UMPMtVt

The M is the Bezier matrix,

U and V parameter vectors,

P is now a 4x4 matrix of control points.

Page 97: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

A Bezier surface example

Page 98: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Rendering curved surfaces

Can compute intersection of ray/patchbut this is difficult and expensive.

More often, the surface is broken into many small triangles;the approximation error is carefully controlled.

Homework: read and summarise (for yourself) one method for decomposing a surface into triangles.

Page 99: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Computing normals of surfaces

Could use normal from a triangle.Better to get the normal at a point directly.

compute partials(only one is shown)

get normal direction

Page 100: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Issues not considered here:

Stitching patches together to make a bigger surface.Continuity issues constrain the points around the joins.

The differential geometry of curves and surfacesFrenet framesGaussian curvature

Page 101: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

• Construct Solid Geometry basics

• Voxel models

L10: CSG and Voxels

Page 102: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

CSG basics

Brep is not the only way to represent objects.CSG is another common way.

CSG is models define sets of points via inequalities.

Example

A straight line, y = mx+c, divides the plane:

set f(x,y) = mx + c – y

then f(x,y) > 0 are points above the linef(x,y) = 0 are points on the linef(x,y) < 0 are point below the line

Page 103: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

More generally

if f(x,y,z) is any scalar function of 3 spatial variablesthen it can be used to partition space points,using the sign of f(x,y,z).

More examples:

unit sphere: f(x,y,z) = x^2 + y^2 + z^2 – 1

unit cylinder: f(x,y,z) = x^2 + y^2 – 1

Page 104: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Let’s write f(x) in place of f(x,y,z);x has become a vector, x = (x,y,z,1).

Now suppose f(x) = x12 + x2

2 -1, a sphere

And suppose M is a transform,

then f(xM) is a mapped version of the sphere;

is an ellipse – maybe with a new centre.

Creating new shapes

Page 105: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Combining shapes

CSG primitives are just sets of points.

So they are easy to combine into more complex shapes.

plane(.)plane(.) plane(.) plane(.)

tetrahedron(.)

AND

sphere(.) cylinder(.)

DIF

doughnut(.)

Any set operation can be used to combine primitivesAny new shapes can be combined too.

Page 106: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Rendering CSG

Ray tracing could be suitable –

the “CSG” plane is already used by us!and bounding spheres are CSG models!

We just have to be clever about following the model treewhen deciding if a ray strikes an object (eg dougnut example).

And (partial) differentiating gives normals;

Homework: show the normal at a point x on the unit sphere is 2x.

Page 107: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

CSG vs Brep

CSG B-rep

points implicit point explicit

sets easy to handle sets hard to handle

goodish to ray trace

hard for radiosity

hardish to ray-trace

good for radiosity

easy to combine hard to combine

hard to get from life easier to get from life

NB: This list is my personal view based on vast non-experience.

Page 108: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Voxel Models

A pixel is a picture element – an area of colour

A voxel is a volume element – a volume of colour

Voxels are often (partially) transparent.

Voxels (typcally) come from medical data:CAT - bonesMRI – soft tissue

Page 109: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

a single voxel

many voxels

voxels are arranged into a brick;

each brick can contain hundreds – thousands – of voxels

in each direction

Page 110: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Typical rendering: CAT scans

CAT scan data produces voxels with a “density”,

so is a scalar field f(x,y,z).

1. Use the scalar field to assign colourand opacity

2. Compute a normal at each voxelUse finite differences for this

3. Shoot a ray through a pixel into the volume,compute lighting at each voxelintegrate colour and opacity over the ray

f

colo

ur

Page 111: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Example – taken from Wikipedia

Page 112: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

• Texture maps

• Variations

• Two problems

L11: Texture maps

Page 113: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Texture maps: what and why

A texture map is a picture:

a carpeta label on a can of foodthe earth…many other examples

Texture maps are used where the level detail neededmake standard modelling inefficient / impossible.

Page 114: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

The idea is to “wrap” or “warp” a flat pictureonto a 3D surface

In this example,a texture of the earth ismapped onto a sphere

+

=

Page 115: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Variations on a theme

• Bump mapping

• Environment mapping

• Procedural mapping

Page 116: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Two problems

1. Flat pictures will not map onto many (most) surfaces:toroidsbunniesetc

2. Aliasing – the texture map is made of pixelsthe pixels can show upand the texture is squashed / stretchedto fit the surfacemaking the problem worse

Page 117: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

x

(sort of) solving problem 1

Use “intermediate” shapes, typicallyspherecylindercube

x is a point on the object

c is the object centre

y is the project of x on the im-shape

y

c

Page 118: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Basic algorithm has two steps:

1. Map the 2D texture (u,v) to the 3D surface (x,y,z):x = x(u,v),y = y(u,v),z = z(u,v)T(u,v) -> T(x,y,z)

This is called the S-mapping

2. Map the object to the same 3D surfacex = x’(xo,yo,zo)y = y’(xo,yo,zo)z = z’(xo,yo,zo)T(x,y,z) -> T(xo,yo,zo)

This is called the O-mapping

Page 119: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Other O-mappings from the object to im-surface exist

x x

x x

centroid object normal

surface normalreflected ray

this one makes reflect the environment

Page 120: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

simple bump opacity

www.sli.unimelb.edu.au/envis/texture.html

environment

3D textures(procedural)

Page 121: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

(sort of) solving problem 2

Recall: Aliasing of textures

solution : mip-mapping

mip = multim im parvo "many things in a small space“

The texture is scaled

and filtered

BEFORE use

Page 122: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

1.The texture is scaled

and filtered

2.In use, the program selected the

correct section of the mipmap, according

to distance

Page 123: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

• Animation as an art

• Animation of solid bodies

• Camera motion

L12: Animation Basics

Page 124: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Animation as an art

• technically, animation is motion

• artistically it means “bring to life”

Page 125: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Traditional animatorsuse many tricks to bringtheir characters to life –to animate them.

All tricks break Physics

streak-lines

ghosting

squash-and-stretch

rubber inertia

Page 126: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk
Page 127: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Animation of solid bodies

This is easy – the same transform is applied to all points

The transform is usually a matrix, but does not have to be.

The transform can be differential

x(t+dt) = f[ x(t) ]

but this often leads to numerical error;

so the transform is more often absolute

x(t) = f[ x(0) ]

The set of point {x(0)} is – conveniently – the “canonical” object

Page 128: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Examples

RiTiTiRi

Page 129: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Camera motion

Cameras often follow a path through a scene.

The path is often defined by a cubic curve.

But this just says where the camera is, we need to know:

* where it points

* and control the camera speed.

We must return to the differential geometry of a curve...

Page 130: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

To control speed and acceleration along the curve

we need

Arc-Length Parameterisation

Recall the Brep curves; x(u) = U*P is a point on the curve

u is a “natural parameter”

parameterisation is arbitrary

define c(u) as the length of the arc

Page 131: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk
Page 132: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

To control viewing direction along the curve

we need

Frenet Frames

Page 133: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

• Model Specifications

• Hierarchies of transforms

• Inverse kinematics/dynamics

L13: Articulated Figures

Page 134: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk
Page 135: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Model specifications

Articulated models comprise

• a set of “limbs”

• joints that link the limbs

• methods to move the limbs

plus appearance information (colour etc)

Page 136: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Here the limbs are just rectangles;

limbs that are rigid bodies are much easier to handle

in which case rectangles are OK to use.

So we can think about the joints.

These are specified in many different ways.

Here a joint is just a point

the limbs move around the point

Often within a constrained angle

(In 3D, within a constrained solid angle)

Page 137: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

rotation angle

parent frame

The way angles are measured

must be carefully specified.

A frame is needed.

Here the “x” axis runs between joints.

X-axis rotation is, then , angle moved.

Page 138: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Hierarchies of TransformsSimple articulated models have a tree-like structure

head

right upper arm

right lower armleft lower arm

left upper arm left upper leg

left lower leg

left foot

right upper leg

right lower leg

right foot

body

neck

This tree is used to locate the whole body first, then the next layer of limbs,

and so on. In this tree the feet are placed last of all.

Page 139: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Placing a transform at each node in the tree

is a very common method

to make the object move.

We already know how to orient the limb inside its frame,

so all we do is move the frame!

Which way around is correct?

y = xMbodyMupperMlowerMfoot

or

y = xMfootMlowerMupperMbody

or will either do?does it matter?

Page 140: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk
Page 141: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk
Page 142: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Problem:

in the modified video,

why does the foot not goes though the floor?

Page 143: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Inverse kinematics/dynamics

• Kinematics – the location of the limbs at any given time.

• Dynamics – the motion of the limbs at any given time.

Page 144: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

IK method

Put the “puppet” into a poses at various times.

The computer works out how to move from one pose to the next,

in the time available.

The solution has to be subject to some constraints,

typically minimisation of some energy measure.

The method is hard, and tedious – too much so for these note.

See Watt & Watt, section 16.4 for details.

Page 145: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

• Non-physical models

• Physical models; elasticity etc for cloth, putty

• Water and fluids

L14: Soft Objects and Fluids

Page 146: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Soft Objects and Physics

Animation of rigid bodies is easy to achieve;

Animation of articulated figures benefits from“inverse kinematics” and “inverse dynamics”.

Animation of soft objects all but requires the use of physics.

Page 147: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Non-physics approaches

• Parametric transforms• Spline surfaces• Free-form deformations

Parametric transforms, eg angle of turn about z depend s on z:

R( theta(z) )

Or could animate splines; eg.

Bezier surfaces are easy to move – just move the control points !

Page 148: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

• Free form deformations

FFD’s “move the space”.

FFD’s are tricubic Bezier patches:

Q(u,v,w) = sum sum sum p(i,j,k) Bi(u) Bj(v) Bk(w)

Any point on any object and (u,v,w) maps to the point Q.

Page 149: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Physics models

Simple use of physics;

i) Use Newton’s second law

F = m d2x/dt2

write as a set of first order ODES

F = m du/dtu = dx/dt

ii) Integrate the differential equations over time;setting boundary conditions at time = 0;

Page 150: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

• Elasticity is a well used model

Soft objects are stretchy !!

Force = -k * stretch

Thus given a form for F, motion is determined.

Page 151: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Different variants can be – and are - used

Bending forces (twisting forces)

Page 152: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Water and fluids

The “atom and force” model is good for “soft solids”

But liquids as best modelled in other ways

Again, though, physics is the basis of all the models

Page 153: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

• Not given in 2008

L15: Fire and Smoke

Page 154: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

• Why is photorealism the aim? People paint!

• What is NPR?

• NPR issues

L16: NonPhotorealistic Rendering

Page 155: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Why photorealism? people paint!

Why photorealism ?

• Physics provides starting point for models

• Photographs provide a foil to test against

But people paint !

• Artwork shows off important regions better

• Photography is just one depictive style amongst many

Page 156: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Which is the simplest to understand?

Page 157: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

What is NPR?

• NPR is a sub-branch of Computer Graphics that studies making images that do not look photographic.

• NPR is said to have started around 1990.

• Several sub-divisions exist– paint-boxes– rendering 3D models– rendering from photographs and/or video

Page 158: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Paint boxes

from the simple… …to the complex

Page 159: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Rendering 3D models

Breslav et al, SIGGRAPH 2007

Page 160: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Rendering from photographs and/or video

Page 161: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

NPR issues

• NPR depends on perception and interpretation– “drawing implies seeing”– models are much more complex– interaction is common

• Mark making– What kind of mark?– Where to mark?

• No single foil to test against– there is no “correct” drawing

Page 162: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

NPR depends on Perception and Interpretation

Page 163: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

No single foil to test against

Page 164: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Mark making: what and where?

What: Emulate real media

pencil, oil paint, chalk, …..

physical models possible

can test for quality of a given mark

What: Produce new media

Can the computer be used to make marks not made before?

Where: Should marks be made locally, globally, or both?

How to decide where to place marks?

Where: How can marks be made stable in animations?

Page 165: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

• The problems

• Some solutions

L17: NPR from models

Page 166: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

The problems

Consider a pencil drawing, marks are used to depict:

• object boundaries and other contours

• shadows and shading

• texture

Page 167: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Apparent ridges

Judd et al, SIGGRAPH 2007

Page 168: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

For apparent ridges we need:

• differential geometry of surfaces

• projection

The curvature at a surface point S(x,y) – how curved is the surface?

Use the Hessian, H, which is a 2x2 matrix of 2nd order partials of S.

The EVD of H = UKUT

principle directions, U = [u1 u2], principle curvature, K = [k1 k2]

Ridges and valleys where k1 is an extremum in direction u1.

Project the local surface geometry (tangents, normals ‘n all),

Look for extremum in this observed geometry.

Page 169: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk
Page 170: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Shadows and shading

Shading lines – cross hatches etc

Can be based in “image space”………or in “object space”

Again, curvature can be used, this time to direct pencil lines.

Page 171: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Other methods use solid texture maps, that adapt to local lighting and geometry

Page 172: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

Marks make textures too…

With NPR, even the marks can be animated (look at the sea)

Page 173: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

L18: NPR from images

Page 174: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

L18: Smart cut-and-paste

Page 175: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

L19: Texture Propagation

Page 176: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

L21: NPR from images

Page 177: CM30075: Computer Graphics maspmh/ Peter Hall pmh@cs.bath.ac.uk

L22: Generalised Cameras