[SOLVED] CS flex *** Adding Shading to the Gz rendering library ***

$25

File Name: CS_flex_***__Adding_Shading_to_the_Gz_rendering_library __***.zip
File Size: 574.62 KB

5/5 - (1 vote)

***Adding Shading to the Gz rendering library***

You will add a flexible shader to your Gz rendering library.You should modify rend.cpp from your HW3 code.No new API functions are added in HW4.The renderer should continue to support flat-shading (like in HW2/HW3).In addition, you should support Gouraud shading of vertices with bilinear (screen space) color interpolation over the triangle, AND, you should support Phong shading at each pixel with bilinear (screen space) normal interpolation over the triangle.

The shading mode is selected by choosing an interpolation mode.
The GZ_INTERPOLATE flag selects between flat shading, vertex shading with color interpolation, and normal interpolation with each pixel getting a shading computation.

You will support two light types GZ_AMBIENT_LIGHT and a directional light specified by GZ_DIRECTIONAL_LIGHT.Both are of type GzLight (in Gz.h).The direction vector is only valid for directional lights and it is the vector from the scene to the light in image-space.Direction is constant since we assume the light is very far away.Ambient light direction has no meaning and is not used.

The API specifies that only one ambient light is supported, but multiple directional lights are possible (up to 10).Lights are specified through a call to GzPutAttribute().(see below)

The hw4 directory has the Gz.h file with comments for the new items you need defined for the API.

GzPutAttribute must now accept the following tokens and values:

tokenvalue type

GZ_RGB_COLORGzColorset default flat-shade color
GZ_INTERPOLATEint shader interpolation mode

GZ_DIRECTIONAL_LIGHTGzLightset a directional light
GZ_AMBIENT_LIGHTGzLightset ambient light color
GZ_AMBIENT_COEFFICIENTGzColorKa ambient reflectance coefs
GZ_DIFFUSE_COEFFICIENTGzColorKd diffuse reflectance coefs
GZ_SPECULAR_COEFFICIENTGzColorKs specular reflectance coefs
GZ_DISTRIBUTION_COEFFICIENTfloatspecular power s

Below are values used for GZ_INTERPOLATE

GZ_INTERPOLATE specifies the shader interpolation mode to use
GZ_FLAT0/* do flat shading with GZ_RBG_COLOR */
GZ_COLOR1/* interpolate vertex color */
GZ_NORMALS2/* interpolate vertex normals */

Gz.h also specifies a GzLight type which is needed since the application has to set up lights.

P.S. If you have compile error related to GzLight, delete any definition in your rend.h file. Its now defined in the new gz.h.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS flex *** Adding Shading to the Gz rendering library ***
$25