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

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

- 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
- Choose
- Define TgCS/BCS

- Each twig has several leaves, LCS
- Choose
- Define LCS/TgCS

- 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

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

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

- 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,

- A nineteenth century mathematician
- Grassmann

and a nineteenth century physicist

- Maxwell

- All colours are subjectively the same as a linear combination of three
basis colours
- Linear combination defined in a special way
- Is there anything special about three?

- Change of basis, etc., etc.
- Display-dependent standard bases: RGB.
- Display-independent standard bases: XYZ.

- Non-linear bases
- HSV
- Opponent colours

But,

- Only approximately correct
- but to within 1-2% for most humans,
- only describes matching, not appearance

- Doesn't describe non-additive colour mixture
- CMY(K) for printing inks

More precise requires illumination as well

CIELab, CIELuv