Examples for Assignment 3

Note: You could hover on any images to see the original(high resolution) ones.

Rasterizer

In general, the built-in uniforms and attributes in shaders could be found here. Specially, the variables used in the rasterizer are as follows:

uniform vec3 cameraPosition;
- built-in uniforms: camera position in world space. It's used to calculate the viewer vector "V" in the slide.
uniform vec3 normal;
- built-in uniforms in vertex shader: the normal vector on each vertex
uniform vec2 uv;
- built-in uniforms in vertex shader: the uv vector on each vertex
uniform vec3 ambient/diffuse/specular;
- uniform passed from GUI: the ambient/diffuse/specular color
uniform float shininess;
- uniform passed from GUI: shininess parameter for calculating specular color, the "n" in the slide.
uniform float inflate;
- uniform passed from GUI: parameter used for inflate or other vertex stuff
uniform vec3 lightDir;
- uniform passed from GUI: In raterizer, we assume there is only a directional light in our scene. The lightDir is "L_i" in the slide.
uniform sampler2D texture;
- uniform passed from GUI: For texture, for example, if you want to get the color in the vertex shader, you can use vec3( texture2D(texture,uv) ).

Inflate

Inflate the mesh in the vertex shader by displacing vertices along the vertex normal:
 

inflate = -0.5

inflate = 0.5

Gouraud shading

The fragment shader is provided but you need to write a vertex shader to compute per-vertex lighting.

gouraud

gouraud

Phong shading

The vertex shader is provided but you need to write a fragment shader to compute per-pixel lighting.

phong

phong

Texture

Add this feature in phong shader.

texture

texture

Raytracer

soft shadow

In this scene, we implement the mirror, glass material, we could also see the specular effect in phong model. An example for the checkboard texture, and a background with some noise texture. For sampling in soft shadow, I use the approach described here.

hard shadow

soft shadow