cm30075 computer graphics www bath ac uk maspmh l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
CM30075: Computer Graphics bath.ac.uk/~maspmh/ PowerPoint Presentation
Download Presentation
CM30075: Computer Graphics bath.ac.uk/~maspmh/

Loading in 2 Seconds...

play fullscreen
1 / 177

CM30075: Computer Graphics bath.ac.uk/~maspmh/ - PowerPoint PPT Presentation


  • 288 Views
  • Uploaded on

CM30075: Computer Graphics www.bath.ac.uk/~maspmh/ Peter Hall pmh@cs.bath.ac.uk !! Warning !! These slides do not replace text book reading L01: about this course Aim: to teach the elements of Computer Graphics Traditional 3D photorealism Modern use of images, and non-photorealism

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'CM30075: Computer Graphics bath.ac.uk/~maspmh/' - lotus


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
l01 about this course
L01: about this course

Aim: to teach the elements of Computer Graphics Traditional 3D photorealism Modern use of images, and non-photorealism

Method: traditional forms lectures personal reading personal practical work

Assumptions: knowledge of analytic mathematics vectors and matrices integration and differentiation

reading
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
practical
Practical
  • Aim: 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.
assessment
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 work Already explained

computer graphics basics

camera

object

point (pixel)

focus

window

Computer Graphics Basics

Traditional: What colour is this pixel?

rendering pipeline

Make 3D models

transform models into place

illuminate models

project models

clip invisible parts

raterization

display

Rendering Pipeline

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.

modern approaches

target image

source image

point (pixel)

Modern approaches

What colour is this pixel?

l02 b rep basics
L02: B-rep basics
  • The B-rep modelling scheme is introduced as just one way to build objects.

points

points and lines

points, lines, and polygons

b rep basics
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).

different information supports different rendering

points

points and lines

points, lines, and polygons

Different informationsupports different rendering
  • points only dots (used in Chemistry, also in modern Point based Rendering)
  • linesWire-frame rendering, good for quick tests in animation, say
  • polygons shaded surfaces
practical issues
Practical Issues

!! ALWAYS INDEX POINTS !!

polygon table

point table

line table

  • avoids repeated points, so more efficient
  • avoids numerical error when animating
different tables can be used
Different tables can be used

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.

a minor complication

anti-clockwise

clockwise

A Minor Complication

!! POINT ORDER MATTERS !!

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

eh! which side is which?

the normal of a triangular polygon
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.

build a table of triangles from these points
build a table of trianglesfrom these points

1

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.

2

6

4

5

7

3

8

b rep basics summary
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.

l03 cameras and projection
L03: Cameras and Projection
  • Camera models introduced.
  • Points are projected, so that objects models can be rendered as wire-frames.
the linear camera

object

window

image

focus

ray

optical axis

The Linear Camera
  • In 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
the linear camera25

object

image

window

focus

The Linear Camera
  • 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 focus leaving the image the right way up
basic perspective projection
Basic Perspective Projection

Uses similar triangles to compute the height of the image

object

image

focus

3d is almost as easy as 2d
3D is almost as easy as 2D

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

homogeneous points
Homogeneous Points

Make projection easy and convenient

3D point (x, y, z) written as (x,y,z,1)

homogeneous point (x, y, z, a) maps to real point 1/a (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!

slide29

A little homogeneous geometry

the set of all rays project

normally onto the window

to make a pattern of “spokes”

object point

a scaled version of the image

straight line (a ray of light)

image point

a scaled version of the object

window

focus:

at the origin

a particular line – the optical axis – passes

normally through the window and through the

focus. This line has the image of the focus –

a vanishing point.

projection with a matrix
Projection with a matrix

Using homogeneous coordinates, projection can be written as a matrix

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

Compare this to with f = 1.

the camera as a matrix
The camera as a matrix
  • Using a matrix for projection is very convenient in many ways.
  • It means we can model the camera as a matrix, C, say.Now projection of a homogenous point p is justq = 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).
  • It means we can move the camera about in space just by pre-multiplying by a matrix transformq = pMC
  • It means we can change the internals of the camera (focal length, aspect ratio, etc) by post-multiplying by a matrixq = pMCK
  • We can do all of this at once! just set A = MCK, now A is a linear cameraq = pA
some examples

Setting

using

rotates then translates the camera before projection.

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

Some Examples
another example
Another example

To change focal length, set

now post-multiply

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

All at once
rendering with a projection matrix
Rendering with a Projection Matrix

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

  • Project all points using the projection matrix
  • Keep all points that lie within the window bounds
  • Connect points in the picture that are connected in 3D

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.

l04 ray casting
L04: Ray-Casting
  • Lines are intersected with planar polygons.
  • The result used as a basis for ray-casting.
  • Now objects can be rendered to look solid.
ray casting algorithm
Ray-casting algorithm

For each pixel Cast a ray from the focus through the pixel Compute all intersections with all polygons Find the nearest polygon Colour pixel with polygon colour

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

ray casting basics
Ray Casting Basics
  • One ray per pixel, cast into the scene
  • Look for nearest intersection
  • Colour pixel accordingly

scene of objects

camera

pixel

focus

window

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

line polygon intersection
Line / Polygon intersection

n

c

an infinitely wide plane

an infinitely long line

x(s)

r

p

compute scale factor

Given the scale factor,

the intersection is easy to get

point inside triangle
Point Inside Triangle?

outside

inside

p2

p1

x

p3

some “turns” are anti-clockwise,

others are clockwise

all three “turns” are anti-clockwise

direction of turn:

parallel direction of turn, sij > 0:

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?

A practical problem
slide42

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 space use the inverse of M to move camera!
  • a projection P maps 3D points, to the windowP is rank degenerate can be (4x3) but usually is (4x4)
  • internal parameters, maps window points to frame-buffertransform confined to the plane a matrix K (a 3x3 will do!)
slide43

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.

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!

y

i

K

j

x

K-1

point is at (x,y)

pixel is typically at (j,i)

slide44

The external parameters transforms the canonical camera

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

M

M-1

ray casting takes a long time
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?

l05 simple reflection
L05: Simple Reflection
  • Point light sources are introduced.
  • Lambertian and Specular reflection, so objects can be shaded.
point light sources
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.

basic reflection model
Basic Reflection Model

light direction

surface normal

mirror direction

Mirror reflection - specular reflection – Phong reflection

Diffuse refection – Lambertian reflection

diffuse lambertian reflection
Diffuse/Lambertian Reflection

A beam of light spreads over an area, and is reflected equally in all directions.

So here we’ve not drawn any reflected direction

over anarrow area

over a wide area

these beams

are of equal width

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

So, the area will appear less bright.

slide50

w

h

q

q

w

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

Energy density in beam: I/w

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

h = w/cos(q)

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

lambertian reflection in graphics
Lambertian reflection in Graphics

We know that light from the source strikes a surface, to be spread equally

in all directions. So, only the angle between the light direction and the

surface is important.

Iout = Ilightcos(q)

The cosine we need is the dot (inner) product of the unit normal and

unit vector pointing to the light.

Iout = Ilightn.l

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

Iout = cIlightn.l

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

diffuse reflection in colour
Diffuse reflection in colour

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

Rout = credRlightn.l

Gout = cgreenGlightn.l

Bout = cblueBlightn.l

For white light, Rlight = Glight = Blight.

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

specular reflection

eye direction, e

light direction, l

surface normal, n

mirror direction, r

Specular Reflection

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?

phong reflection
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 colour

in just the same sort of way as Lambertian reflection

a complete but simple reflection model
A complete but simplereflection model

A complete model (for a single colour channel) is

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

  • 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
l06 ray tracing
L06: Ray-tracing

Ray-tracing is a global lighting method.

  • Cast shadows
  • Reflection and refraction amongst many objects.
  • Ray-tracing as a tree.
cast shadows
Cast Shadows

Is the box resting on the table ?

is a point in shadow
Is a point in shadow?

point

light

point

light

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

how can we tell
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

reversibility of light
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.

ray tracing extends ray casting

refracted ray

intersection

Ray tracing extends ray casting

window

eye

object

ray

reflected ray

ray tracing tree
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

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

the root

original ray from eye thru’ pixel

intersection

reflected

refracted

intersection

reflected

refracted

intersection

a “parent” ray

when going

UP the tree

reflected

refracted

intersection

a leaf

using the tree in a simple way
Using the tree in a simple way

The 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.

a detail of the tree
A detail of the tree

non-leaf intersection

local light + child rays

to parent

surface

leaf intersection

local light only

leaf intersection

local light only

to parent

to light

normal

normal

to parent

mirror

direction

to light

mirror

direction

surface

surface

whitted ray tracing
Whitted ray-tracing

Turner 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.

l07 advanced reflection and refraction
L07: Advanced Reflectionand Refraction
  • The BRDF is introduced.
  • Physical models of reflection and refraction are considered.
overall energy transfer

incident light Ein

refracted light, Erefr

reflected light, Erefl

Overall energy transfer

schematically

conservation of energy

Ein = Erefl + Erefr + Eabs

recall the simple lighting model
Recall the simple lighting model

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

n

e

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

l

r

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

a visualisation
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 a.In fact

c = 1 + e.ra

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

a more general idea
A more general idea
  • The light energy depends on
  • the direction of the incident light
  • the direction of view
diffuse specular lighting
Diffuse/Specular lighting

diffuse to diffuse

diffuse to specular

specular to specular

specular to diffuse

the bdrf
The BDRF

BDRF = bi-directional reflectance function

f(f1,f2, q1,q2)

f the fraction of light energy transferredfrom an incident light ray at (f1,f2)to viewing direction (q1, q2)

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

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

the importance of the bdrf
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.
where do we get a brdf from
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.

…under a microscope

flat surface

a perfect mirror

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

Look up Torrance Sparrow model.

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

l08 the rendering equation
L08: The rendering equation
  • The full complexity of global lighting
  • radiosity in brief
  • radiosity and ray-tracing as specific solutions

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

global lighting

light out

light in

Global Lighting

Every 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?

slide77

Scattering, Shadows and refraction complicate further still !

light out

light in

and real cases are still more complicated !

kajya s rendering equation
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.

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

r(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.

use of rendering equation
Use of Rendering Equation

Different lighting models are special-case solutions:

The local-model

Ray-tracing

Radiosity

slide80

rewrite

as

with R an integral operator

Now

hence

Solving the rendering equation

slide81

consider

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

subsequent terms account for scattering from other points

ray tracing
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
radiosity

light falls onto a patch from all others

light radiates to all other patches

Radiosity
  • Diffuse to Diffuse

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

slide84

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

slide85

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:

slide86

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.

l09 brep with curves
L09: Brep with curves
  • Spline surfaces as B-rep models
  • How to define them
  • How to render them
slide88

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.

slide89

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

slide90

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.

slide91

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.

slide92

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.

u

x(u)

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

x(u,v)

v

slide93

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][dcba]

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!

slide94

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 = [p0p1p2p3]

parameter vector

the “Bezier” matrix

4 control points

slide95

Examples of Bezier curves

control points

Bezier curve

slide96

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.

slide98

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.

slide99

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

slide100

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 surfaces Frenet frames Gaussian curvature

l10 csg and voxels
L10: CSG and Voxels
  • Construct Solid Geometry basics
  • Voxel models
csg basics
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 line f(x,y) = 0 are points on the line f(x,y) < 0 are point below the line

slide103

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

slide104

Creating new shapes

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 + x22 -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.

slide105

doughnut(.)

tetrahedron(.)

AND

DIF

plane(.)

plane(.)

plane(.)

plane(.)

cylinder(.)

sphere(.)

Combining shapes

CSG primitives are just sets of points.

So they are easy to combine into more complex shapes.

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

slide106

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.

slide107

CSG vs Brep

B-rep

CSG

points implicit

point explicit

sets easy to handle

sets hard to handle

goodish to ray trace

hardish to ray-trace

hard for radiosity

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.

voxel models
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 - bones MRI – soft tissue

slide109

a single voxel

many voxels

voxels are arranged into a brick;

each brick can contain hundreds – thousands – of voxels

in each direction

slide110

colour

f

  • Typical rendering: CAT scans
  • CAT scan data produces voxels with a “density”,
  • so is a scalar field f(x,y,z).
  • Use the scalar field to assign colourand opacity
  • Compute a normal at each voxelUse finite differences for this
  • Shoot a ray through a pixel into the volume,compute lighting at each voxelintegrate colour and opacity over the ray
l11 texture maps
L11: Texture maps
  • Texture maps
  • Variations
  • Two problems
texture maps what and why
Texture maps: what and why

A texture map is a picture:

a carpet a label on a can of food the earth …many other examples

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

slide114

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

=

variations on a theme
Variations on a theme
  • Bump mapping
  • Environment mapping
  • Procedural mapping
two problems
Two problems

1. Flat pictures will not map onto many (most) surfaces: toroids bunnies etc

2. Aliasing – the texture map is made of pixels the pixels can show up and the texture is squashed / stretched to fit the surface making the problem worse

sort of solving problem 1

y

x

c

(sort of) solving problem 1

Use “intermediate” shapes, typically sphere cylinder cube

x is a point on the object

c is the object centre

y is the project of x on the im-shape

slide118

Basic algorithm has two steps:

  • 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
  • Map the object to the same 3D surface x = 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
slide119

x

x

x

x

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

object normal

centroid

surface normal

reflected ray

this one makes reflect the environment

slide120

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

3D textures(procedural)

environment

bump

opacity

simple

sort of solving problem 2
(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

slide122

1.The texture is scaled

and filtered

2.In use, the program selected the

correct section of the mipmap, according

to distance

l12 animation basics
L12: Animation Basics
  • Animation as an art
  • Animation of solid bodies
  • Camera motion
animation as an art
Animation as an art
  • technically, animation is motion
  • artistically it means “bring to life”
slide125

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

All tricks break Physics

ghosting

streak-lines

squash-and-stretch

rubber inertia

animation of solid bodies
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

examples
Examples

RiTi

TiRi

camera motion
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...

slide130

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

l13 articulated figures
L13: Articulated Figures
  • Model Specifications
  • Hierarchies of transforms
  • Inverse kinematics/dynamics
model specifications
Model specifications

Articulated models comprise

  • a set of “limbs”
  • joints that link the limbs
  • methods to move the limbs

plus appearance information (colour etc)

slide136

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)

slide137

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.

parent frame

rotation angle

hierarchies of transforms

Simple articulated models have a tree-like structure

body

neck

left upper arm

right upper arm

left upper leg

right upper leg

head

left lower arm

right lower arm

left lower leg

right lower leg

right foot

left foot

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.

Hierarchies of Transforms
slide139

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?

slide142

Problem:

in the modified video,

why does the foot not goes though the floor?

inverse kinematics dynamics
Inverse kinematics/dynamics
  • Kinematics – the location of the limbs at any given time.
  • Dynamics – the motion of the limbs at any given time.
slide144

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.

l14 soft objects and fluids
L14: Soft Objects and Fluids
  • Non-physical models
  • Physical models; elasticity etc for cloth, putty
  • Water and fluids
soft objects and physics
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.

non physics approaches
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 !

slide148
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.

physics models
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/dt u = dx/dt

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

slide150
Elasticity is a well used model

Soft objects are stretchy !!

Force = -k * stretch

Thus given a form for F, motion is determined.

slide151

Bending forces (twisting forces)

Different variants can be – and are - used

water and fluids
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

l15 fire and smoke
L15: Fire and Smoke
  • Not given in 2008
l16 nonphotorealistic rendering
L16: NonPhotorealistic Rendering
  • Why is photorealism the aim? People paint!
  • What is NPR?
  • NPR issues
why photorealism people paint
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
what is npr
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
slide158

Paint boxes

from the simple…

…to the complex

slide159

Rendering 3D models

Breslav et al, SIGGRAPH 2007

npr issues
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
slide164

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?

l17 npr from models
L17: NPR from models
  • The problems
  • Some solutions
the problems
The problems
  • Consider a pencil drawing, marks are used to depict:
  • object boundaries and other contours
  • shadows and shading
  • texture
slide167

Apparent ridges

Judd et al, SIGGRAPH 2007

slide168

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.
slide170

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.

slide172

Marks make textures too…

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