CS488 - Introduction to Computer Graphics - Lecture 10

Public Service Announcements

  1. Assignment 3 due 18 June, one week from today.
  2. PDF that covers colour

Hierarchical Models

What we have

How to render any polygon anywhere

  1. Put the polygon where you want it to be in world coordinates
  2. Transform to view coordinates
  3. Perspective transform
  4. Clip in normalized device coordinates.
  5. Scan convert each polygon in any order, using z-buffer to remove occuded pixels

What we want to have

Objects made of polygons that we can feed into the rendering pipeline.

Argument by example

  1. A Forest consists of many trees, each at a different location, scale and orientation
  2. Each Tree has a Trunk (in a TkCS) and a Root (in an RCS)
  3. Each Trunk has several branches, each with a BCS
  4. Each branch has many twigs, each having a TgCS
  5. Each twig has several leaves, LCS

Aside. It seems to me that we have, rather glibly, required a lot of choosing and defining

  1. We defined one polygon mesh for each version of a tree element: 5(types of element) x 10(versions per type) = 50 meshes to model.
  2. We choose a set of each type from the versions: 10(elements per set) x 10(choices per element) = 100
  3. We define a matrix for each element: 1(trunk) x 1(root) x 10(branches) x 10(twigs) x 10(leaves) = 1000

This should seem like a lot of work, because it is. Remember this when I tell you that your project has too much modelling.

This seems like work a computer could do better than a human. Much research has been done with -- usually -- disappointing results. We have not yet found good algorithms that put in the right amounts of randomness and order. The human visual system seems to be very finally tuned to expect a correct

How do we render a leaf?

  1. Transform points from LCS to TgCS (MLTg)
  2. Transform points from TgCS to BCS (MTgB)
  3. Transform points from BCS to TkCS (MBTk)
  4. Transform points from TkCS to TCS (MTkT)
  5. Transform points from TCS to WCS (MTW)
  6. Transform points to view coordinates (MWV)
  7. Perspective Transform points to the image plane (MVIp)

Make up the matrix M = MVIp * MWV * MTW * MTkT * MBTk * MTgB * MLTg1

How do we render the second leaf?

  1. Multiply again: M2 = MVIp * MWV * MTW * MTkT * MBTk * MTgB * MLTg2

    Too much work.

  2. Do less work: M2 = M * (MLTg1)^-1 * MLTg2

    Accumulating round-off error.

  3. Keep around

    We like this approach because we can do it with a stack.

Scene Graph

Render a scene using a matrix stack.

Render a forest

proc forest(  )
  unitMatrix( )
  multMatrix(MVP)
  multMatrix(MWV)
  pushMatrix( )
    multMatrix(MTW1)
    tree1( )
  popMatrix( )
  pushMatrix( )
    multMatrix(MTW2)
    tree2( )
  popMatrix( )
  etc.
 

Render trees

proc tree1( )
  pushMatrix( )
    multMatrix(MTTk11)
    trunk1( )
  popMatrix( )
  pushMatrix( )
    multMatrix(MTR12)
    root2( )
  popMatrix( )

proc tree2( )
  pushMatrix( )
    multMatrix(MTTk21)
    trunk1( )
  popMatrix( )
  pushMatrix( )
    multMatrix(MTR22)
    root2( )
...

We don't want always to write a program, so we encapsulate the program as data.

Traverse a DAG

traverse( root )

proc traverse( node ) {
  if ( drawable( node ) ) {
    draw( node )
  }
  for each child {
    traverse( child )
  }
  return
}

Build a DAG

scene = gr.transform( )

tree1 = gr.transform( )
gr.add_child( tree1, scene )
gr.set_transform( tree1, gr.translation(...)*gr.rotation(...)*...)
...

root = gr.transform( )
rootshape = gr.cylinder( )
gr.add_child( root, tree1 )
gr.set_transform( root, gr.scaling(...)*... )
gr.addchild( rootshape, root )
gr.setmaterial( rootshape, rough_bark )

trunk = gr.transform( )
gr.add_child( trunk, tree1 )
gr.set_transform( trunk, gr.scaling(...)*... )
trunkshape = gr.cylinder( )
gr.add_child( trunkshape, trunk )
gr.add_material( trunkshape, roughbark )
// The code below is repeated for each branch
  branch = gr_transform( )
  gr.add_child( branch, trunk )
  gr.set_transform( branch, gr... )
  branchshape = gr_cylinder( )
  gr.add_child( branch, branchshape)
  gr.setmaterial( branchshape, mediumbark )
    twig = grtransform( )
    ...

column1 = gr.transform( )
gr.add_child( temple1, column1 )
gr.set_transform( column1, gr.translation(...)*gr.scaling(...)
...

which generates the DAG:

forest
|
tree1------------------------------tree2----------tree3--...
|                                  |              |
trunk1--root1                      trunk2--root2
|                                  |
branch11--branch12--branch13--...  branch21--...
|                                  |
twig111--twig112--twig113--...     twig211--...
|                                  |
leaf1111--leaf1112--leaf1113--...  leaf2111--...

Colour -- pdf

What is needed for colour?

  1. An eye.
  2. A source of illumination.
  3. A surface.

How is colour created?

  1. Source of illumination emits light (photons of differing wavelength).
  2. Surface modifies light.
  3. Eye compares surfaces and notices different modifications.

How do we represent colour?

To the rescue,

But,

More precise requires illumination as well


Terminology

  1. Illumination
  2. Ambient illumination
  3. Notes terminology

Lambertian Surfaces

Model of body reflection

How much light hits the surface?

  1. Idealize light sources as points emitting light
    1. How much light does a source emit?
    2. How much light is there at a distance r from the source?
      • Segregate the light by direction
      • How much light per unit angle?
    3. How much light per square metre?
      • Falls off with distance.
      • How? Think how big the surface of a sphere is.
    4. How much of the surface does a square metre of the sphere cover?
      • Depends on the angle
      • How?
  2. What if the lights were (infinite) lines?
  3. What if the lights were (infinite) planes?
  4. What do we do in practice?

Comment. Two general aspects of the above are very important to getting things right in computer graphics

  1. The scaling arguments from dimensionality
  2. The geometric derivations of angular facts from small areas

How much light leaves the surface?

This material is described with diagrams here.

We are only interested in the light leaving the surface in a particular direction. Why?

The light divides into two parts at the surface

The simplest model of body reflectance is Lambert's cosine law. Surfaces with body reflectance following Lambert's cosine law are called Lambertian.

What makes a Lambertian surface Lambertian?

What goes into the eye

Important point

What colour is the light?


Highlights

Part of the light didn't enter the body of the surface, but was reflected

Suppose the surface is smooth

Suppose we roughen the surface just a little

And if we roughen the surface a lot

Here is the hack

How is the incoming light divided between ambient, surface and body reflection?

L(\lambda) = Ia * ka(\lambda) + Id * (l.n) * kd(\lambda) + Is * ( r.v )^p * ks


Return to: