How to render any polygon anywhere
Objects made of polygons that we can feed into the rendering pipeline.
Make up the matrix M = MVP * MWV * MTW * MTkT * MBTk * MTgB * MLTg
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(...)
...
What is needed for colour?
How is colour created?
How do we represent colour?
To the rescue,
and a nineteenth century physicist
But,
More precise requires illumination as well
CIELab, CIELuv