projects

Sunday, August 28, 2005

Scanline and flat shading


Finally some scanlinen conversion with flat shading..The light direction is down the positive z-axis (0, 0, 1). Thanks to Wang I now know a bit more about the mathematics of perspective projection. The scene consists of a icosahedron and a box both of which have back face culled which means that only the front face are rendered. The z-buffer for hidden surface removal is also present but is not required here since backface culling is done.... but it will be required when object are rendered one infront of the other (the box infront of the icosahedron)
The matrix for perpective calculation...
float nearP = -1.0;
Matrix4 p( nearP, 0, 0, 0,
0, nearP, 0, 0,
0, 0, 1, 0,
0, 0, -1, 15 );

transformVertices(p);
normalizeTransformedVertices();

2 Comments:

Post a Comment

<< Home