HW 4 Interpolation Modes
• App sets GZ_INTERPOLATE flag
• GZ_FLAT : flat shading (default – Shade using first vertex normal) • GZ_COLOR : vertex shading and color interpolation (Gouraud)
• GZ_NORMALS : normal interpolation and pixel shading (Phong)
• App sends triangle
– Transform norms with Xn (transform all of the norms)
• If GZ_FLAT :
• Compute color based on 1st vertex normal
• AsinHW3–usethesamecolorforalltrianglepixels
• Else:
• IfGZ_COLOR:
– compute color at verts, rasterize while interpolating RGB vertex colors
• IfGZ_NORMALS:
– rasterize while interpolating Normals and compute color at each pixel
– NOTE: MAKE SURE YOU “NORMALIZE” THE LENGTH OF THE INTERPOLATED NORMAL VECTOR AT EACH PIXEL BEFORE YOU EVALUATE THE SHADING EQUATION
Interpolation Examples
Image courtesy of Watt & Watt, Advanced Animation and Rendering Techniques
More Interpolation Examples
HW4 Details
● Add a shader to your Gz rendering library to support Flat -shading, Gouraud shading, and Phong shading
● The shading mode is set by selected an interpolation mo de
● The GZ_INTERPOLATE flag selects between flat shadin g (no interpolation), vertex color interpolation, and norm al interpolation.
● You will support two light types GZ_AMBIENT_LIGHT an d a directional light specified by GZ_DIRECTIONAL_LIG HT
● Both are of type GzLight (in Gz.h)
● The direction vector is only valid for directional lights and it is t he vector from the scene to the light in image-space
● Ambient light direction has no meaning – so it is ignored
HW4 Details (2)
● Only one ambient light is supported, but multiple directional lights are possible (u p to 10)
● Lights are specified by a call to GzPutAttribute()
● GzPutAttribute() must accept the following tokens/values:
● GZ_RGB_COLOR GzColor default flat-shade color
● GZ_INTERPOLATE int shader interpolation mode
● GZ_DIRECTIONAL_LIGHT
● GZ_AMBIENT_LIGHT
● GZ_AMBIENT_COEFFICIENT
● GZ_DIFFUSE_COEFFICIENT
● GZ_SPECULAR_COEFFICIENT
● GZ_DISTRIBUTION_COEFFICIENT
GzLight
GzLight (ignore direction) GzColor Ka reflectance GzColor Kd reflectance
GzColor Ks coef’s float spec power
HW4 Details (3)
●Values for GZ_INTERPOLATE
● GZ_FLAT 0 ●GZ_COLOR 1 ●GZ_NORMALS
/* flat shading uses first vertex normal */ /* interpolate vertex color */
2 /* interpolate normals */
●Gz.h defines a GzLight type since the application has to set up light s
●*** Note that you can use your existing LEE or DDA interpolation me thods for color or normal interpolation
● No need to invent a new method
HW4 Shading
Camera set
Color interpolation
Normal interpolation
Default camera
HW4 Flat Shading
Default camera
Camera set
HW4 teapot
● Modeling errors in the teapot normals ● Normals have inconsistent signs
line 2593
triangle
0.000281 3.000000 0.000844 0.000000 1.000000 0.000000 0.250000 0.000000
0.000750 3.000000 0.000750 0.000000 -1.000000 0.000000 0.500000 0.000000
0.242477 2.950782 0.242477 0.423818 0.800473 0.423818 0.500000 0.250000
similar issues at lines 2625, 2629, 2721, 2753, 2849, 2881, 2977, 3009
HW 4 Interpolation Modes
• App sets GZ_INTERPOLATE flag
• GZ_FLAT : flat shading (default – Shade using first vertex normal) • GZ_COLOR : vertex shading and color interpolation (Gouraud)
• GZ_NORMALS : normal interpolation and pixel shading (Phong)
• App sends triangle
– Transform norms with Xn (transform all of the norms)
• If GZ_FLAT :
• Compute color based on 1st vertex normal
• AsinHW3–usethesamecolorforalltrianglepixels
• Else:
• IfGZ_COLOR:
– compute color at verts, rasterize while interpolating RGB vertex colors
• IfGZ_NORMALS:
– rasterize while interpolating Normals and compute color at each pixel
– NOTE: MAKE SURE YOU “NORMALIZE” THE LENGTH OF THE INTERPOLATED NORMAL VECTOR AT EACH PIXEL BEFORE YOU EVALUATE THE SHADING EQUATION
Interpolation Examples
Image courtesy of Watt & Watt, Advanced Animation and Rendering Techniques
More Interpolation Examples
HW4 Details
● Add a shader to your Gz rendering library to support Flat -shading, Gouraud shading, and Phong shading
● The shading mode is set by selected an interpolation mo de
● The GZ_INTERPOLATE flag selects between flat shadin g (no interpolation), vertex color interpolation, and norm al interpolation.
● You will support two light types GZ_AMBIENT_LIGHT an d a directional light specified by GZ_DIRECTIONAL_LIG HT
● Both are of type GzLight (in Gz.h)
● The direction vector is only valid for directional lights and it is t he vector from the scene to the light in image-space
● Ambient light direction has no meaning – so it is ignored
HW4 Details (2)
● Only one ambient light is supported, but multiple directional lights are possible (u p to 10)
● Lights are specified by a call to GzPutAttribute()
● GzPutAttribute() must accept the following tokens/values:
● GZ_RGB_COLOR GzColor default flat-shade color
● GZ_INTERPOLATE int shader interpolation mode
● GZ_DIRECTIONAL_LIGHT
● GZ_AMBIENT_LIGHT
● GZ_AMBIENT_COEFFICIENT
● GZ_DIFFUSE_COEFFICIENT
● GZ_SPECULAR_COEFFICIENT
● GZ_DISTRIBUTION_COEFFICIENT
GzLight
GzLight (ignore direction) GzColor Ka reflectance GzColor Kd reflectance
GzColor Ks coef’s float spec power
HW4 Details (3)
●Values for GZ_INTERPOLATE
● GZ_FLAT 0 ●GZ_COLOR 1 ●GZ_NORMALS
/* flat shading uses first vertex normal */ /* interpolate vertex color */
2 /* interpolate normals */
●Gz.h defines a GzLight type since the application has to set up light s
●*** Note that you can use your existing LEE or DDA interpolation me thods for color or normal interpolation
● No need to invent a new method
HW4 Shading
Camera set
Color interpolation
Normal interpolation
Default camera
HW4 Flat Shading
Default camera
Camera set
HW4 teapot
● Modeling errors in the teapot normals ● Normals have inconsistent signs
line 2593
triangle
0.000281 3.000000 0.000844 0.000000 1.000000 0.000000 0.250000 0.000000
0.000750 3.000000 0.000750 0.000000 -1.000000 0.000000 0.500000 0.000000
0.242477 2.950782 0.242477 0.423818 0.800473 0.423818 0.500000 0.250000
similar issues at lines 2625, 2629, 2721, 2753, 2849, 2881, 2977, 3009
More teapots
Reviews
There are no reviews yet.