CS488 - Introduction to Computer Graphics - Lecture 15
Hierarchical Models
What we have
How to render any polygon anywhere
- Put the polygon where you want it to be in world coordinates
- Transform to view coordinates
- Perspective transform
- Clip in normalized device coordinates.
- 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.
- Making the objects is called modelling.
- Here we discuss the data structures and algorithms associated with
hierarchical modelling
- Hierarchical is a synonym for `divide and conquer'.
An example
- A forest is many trees, each at a different location, scale and
orientation
- Use only two or three different trees, each defined with respect to
a tree-centred coordinate system (TCS)
- With respect to the world coordinate system (WCS) define, for each
tree, a matrix that expressed the relationship between the TCS and
the WCS.
- Each tree has a trunk (in a TkCS) and a root (in an RCS)
- Choose from a few of each
- Define matrices that define RCS and TkCS to the TCS
- Each Trunk has several branches, each with a BCS
- Choose from a few of each
- Define BCS/TkCS matrices
- Each branch has several twigs, each having a TgCS
- Each twig has several leaves, LCS
How do we render a leaf?
- Transform points from LCS to TgCS (MLTg)
- Transform points from TgCS to BCS (MTgB)
- Transform points from BCS to TkCS (MBTk)
- Transform points from TkCS to TCS (MTkT)
- Transform points from TCS to WCS (MTW)
- Transform points to view coordinates (MWV)
- Perspective Transform points (MVP)
Make up the matrix M = MVP * MWV * MTW * MTkT * MBTk * MTgB * MLTg
- and use it on each point (probably polygon vertex) in the leaf
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
- This is done by a modelling tool, or program
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?
- An eye.
- A source of illumination.
- A surface.
How is colour created?
- Source of illumination emits light (photons of differing
wavelength).
- Surface modifies light.
- Eye compares surfaces and notices different modifications.
How do we represent colour?
- As some kind of sum of photons?
- As a distribution of photons (over wavelength)?
- As a ratio of distributions of photons?
To the rescue,
But,
- Only approximately correct
- but to within 1-2% for most humans,
- only describes matching, not appearance
- Doesn't describe non-additive colour mixture
More precise requires illumination as well
CIELab, CIELuv
Return to: