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
What I Did:
-
Built a four-level cel shader with view-angle edge darkening
-
Added mouse-driven lighting, a proximity color shift and a reactive grid in a single fragment pass
-
Passed live input from JavaScript to GLSL uniforms every frame
-
Compared vertex perturbation with normal perturbation for bump mapping
-
Kept the whole effect to one draw call with no extra render passes
-
Documented every step in a written lab report with renders and code excerpts
Overview:
This shader turns smooth Phong lighting into a stylized cel-shaded look, then layers an interactive effect on top that reacts to the mouse in real time. It moves from reproducing textbook lighting to making deliberate art-direction choices in code.
The cel shader quantizes lighting into four flat bands with dark outlines at grazing angles. On top of that sit three interactive layers: a light that follows the cursor, a cyan-to-magenta color wave around the mouse, and a grid overlay that brightens as the cursor gets close.
Move the mouse and every layer responds at once, which makes it a good showcase for passing live input from JavaScript to the GPU.



How It Works
The cel shader replaces the smooth diffuse falloff with hard thresholds on dot(s, n). Surfaces facing the light above 0.9 get the brightest band, 0.75 to 0.9 gets a mid tone with 20% of the specular added back, and everything below falls into two darker bands. A separate check on dot(t, n) < 0.4 darkens fragments at grazing view angles, which draws the outline without a second render pass.
For the interactive layer, a mousemove listener normalizes the cursor to the -1 to 1 range and sends it to the shader as a uniform every frame. The light position follows the cursor, a smoothstep falloff around the mouse blends a cyan-to-magenta wave over the toon colors, and a fract() and step() grid on the fragment coordinates fades in as the cursor gets closer.
Before the cel work I compared two ways of adding surface detail. Perturbing the vertices actually moves the geometry and leaves a jagged silhouette, while perturbing only the normals keeps the outline smooth and lets the lighting fake the bumps, which is the idea behind bump and normal mapping.

