top of page

Course

QMUL Computer Graphics (ECS610U), Fall 2025

 

Completed: December 2025

 

Graphics API: WebGL 1.0, GLSL ES 1.0

 

Platform: Web browser

 

Role: Graphics programmer (solo coursework)

​

Software Used: JavaScript, GLSL, VS Code

Lighting Models is a set of real-time shading experiments built in WebGL and GLSL with no engine underneath. Starting from a bare render loop, I set up model-view transforms for loaded OBJ meshes, then wrote ambient, diffuse and specular lighting in the fragment shader and compared three classic reflection models side by side.

 

Phong computes specular highlights from the angle between the reflected light vector and the view vector. Blinn-Phong swaps that for the half vector between the light and view directions, which gives wider, softer highlights and is still the baseline most real-time engines build on. Gouraud shading moves the whole calculation into the vertex shader and interpolates the result, trading image quality for speed.

​

The comparison below runs all of these on the same gold-material Suzanne head, lit by a single point light, so the only thing that changes between images is the shading model.

​

​

Overview:

What I Did:

​

  • Composed scale, rotation and translation matrices to place and animate 50 independently transformed OBJ meshes

  • Implemented Phong and Blinn-Phong reflection in a GLSL fragment shader

  • Wrote a separate per-vertex (Gouraud) shader pair to compare its quality and cost against per-pixel lighting​

  • Passed material and light properties from JavaScript into GLSL uniform structs

  • Loaded OBJ meshes (Suzanne, banana) into vertex, normal and index buffers

  • Documented every step in a written lab report with renders and code excerpts

Ambient and diffuse, Phong and Blinn-Phong shading compared on the same Suzanne head
Per-pixel Phong versus per-vertex Gouraud shading on Suzanne
Hundreds of instanced banana models rendered with Blinn-Phong lighting

How It Works

About

Each fragment receives an interpolated surface normal (m), a vector toward the light (s) and a vector toward the camera (t). The fragment shader renormalizes the normal, and it then adds ambient light that reaches everything equally, diffuse light which is scaled by max(dot(s, n), 0), and a specular term raised to the material's shininess exponent. Material values come from a measured gold table (shininess 51.2), passed in from JavaScript as uniform structs.

​

Switching from Phong to Blinn-Phong is a two-line change, but the visual difference is obvious. The angle between the half vector and the normal is smaller than the angle between the reflection and view vectors, so highlights spread further across the surface. Multiplying the exponent by 4 pulls them back to a tighter, glossier look.

​​

For Gouraud shading I wrote a second shader pair that evaluates the full lighting equation per vertex and hands a single color to a pass-through fragment shader. On the back of the head the difference is clear: highlights jump between triangles instead of following the curve of the surface, because per-vertex lighting can't represent detail smaller than the spacing between vertices.

Blinn-Phong shading on Suzanne at the default shininess exponent
Blinn-Phong highlight with the shininess exponent multiplied by four
My Role
bottom of page