University of California, Berkeley EECS Dept, CS Division |
||
Jordan Smith |
SLIDE: Scene Language for Interactive Dynamic Environments |
Prof. Carlo H. Séquin |
Home | Goals | Publications | People | Gallery | Assignments | Distributions |
In this assignment, you are building slidelight, the full SLIDE software renderer. The final features which you need to complete are:
New options appear in bold.
For shading and lighting of smooth objects approximated by a polygonal model it is necessary to assign normals at the vertices. This can be directly in a SLIDE file:
point p0 ( 0 0 0 ) normal ( 0 0 1 ) endpoint
This is useful if you know what smooth surface you are trying to approximate. Other times the user will just give a well connected polygonal object and expect you to compute a reasonable normal for the vertices.
You should average the face normals of the faces which are incident to the point (the faces which mention its ID in their point list). A good way to do this averaging is to weight a face's normal by the magnitude of the angle between the edges of the face which are incident to that point. Point normals can then change dynamically if any of the face normals around them change dynamically. A face's normal can change dynamically if ones of its point's changes position dynamically. So you need to dynamically update point normals where it is necessary.
The SLIDE shading flags are: SLF_INHERIT, SLF_WIRE, SLF_FLAT, SLF_GOURAUD, and SLF_PHONG. We are not implementing Phong shading, so treat SLF_PHONG the same as SLF_GOURAUD. A face should use the shading flag which is specified closest to it in the rendering hierarchy. If a node has a shading flag of SLF_INHERIT (which is the default) then the current shading flag value is used. This is analogous to how SLIDE surface properties are inherited.
The final value of the shading flag at the face render affects how point surface properties and normals are used. If shading flag is SLF_WIRE, then no lighting calculations are performed and no normals are needed. If shading flag is SLF_FLAT (or SLF_INHERIT because flat shading is the default if no shading is specified), then the face surface and the face normal are used and they override the point surfaces. Lighting should only be calculated at the centroid of the face using the face normal. If the shading flag is SLF_GOURAUD (or SLF_PHONG) then point normals are used and lighting is calculated at each vertex of a polygon. Also if point surfaces are defined, then they are used. If the point surface is SLF_INHERIT then the face surface is used at that point.
The SLIDE light types are: SLF_AMBIENT, SLF_DIRECTIONAL, SLF_POINT, and SLF_SPOT.
You must handle local viewer for a perspective projection camera or distant viewer if there is a parallel projection camera. For details on how to calculate the lighting color values see the SLIDE language documentation.
You will be implementing Gouraud color interpolation in your ScanConversion class. So the input to your FillPolygon routine will be a list of vertices with (R, G, B ) color values (either described in the SLIDE file or calculated based on the lighting conditions). Now as you scan convert your polygon you will need to linearly interpolate the color values along the edges of your polygon and then horizontally across the scan line. This is analogous to interpolating Z values for Z-buffering.
Like the Z values in Z-Buffering, you should update the color values by adding a delta value at each step in Y along the edge, and then in X along the scan line. You should compute:
I = ( R, G, B )
dI/dY = ( dR/dY, dG/dY, dB/dY )
dI/dX = ( dR/dX, dG/dX, dB/dX )
Along an edge: Icurr = Iprev + dI/dY
Along a scan line: Icurr = Iprev + dI/dX
For more information see the class notes on scan conversion.
You will need to modify the polygon clipping algorithm to calculate the color values at the intersection point when a polygon edge is clipped.
Follow the listed instructions for as7.
The SLIDE Implementation Specification gives information about the C++ class structure which implements the SLIDE viewer. It also gives an outline of the operation of the viewer.
This page was originally built by Jordan Smith.
Last modified: Wednesday, 27-Oct-2004 14:46:38 PDT