CS488 - Introduction to Computer Graphics - Lecture 15


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.

An example

  1. A forest is 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 several twigs, each having a TgCS
  5. Each twig has several leaves, LCS

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 (MVP)

Make up the matrix M = MVP * MWV * MTW * MTkT * MBTk * MTgB * MLTg

Scene Graph

Render a scene

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

Render a forest

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

proc tree2( )
  pushMatrix( )
    multMatrix(MTTk11)
    trunk1( )
  popMatrix( )
  pushMatrix( )
    multMatrix(MTR12)
    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 ( primitve( node ) ) {
    draw( node )
  } else { for each child {
    traverse( child )
  }
}

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

Colour

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

CIELab, CIELuv


Return to: