CS 488: Lab 12 – Flashlight
Welcome to lab, which is a place where you and your peers complete exercises designed to help you learn the ideas discussed in the preceding lectures. It is intended to be a time where you encounter holes in your understanding and talk out loud with your peers and instructor.
Your instructor will bounce around between breakout rooms to check in with you. However, you are encouraged to request assistance if you find your progress blocked.
Designate one of your group to be the host. This individual will be responsible for setting up a Live Share session in Visual Studio Code and submitting your work. No team member should dominate or be expected to carry the group. All members should be writing code and contributing ideas.
Setup
Host, follow these steps:
- Open Visual Studio Code.
- Click File / Open Folder, create a new folder, and open it.
- With the Live Share extension installed, select View / Command Palette, and choose Live Share: Start Collaborative Session.
- Copy the invitation link to your chat.
Non-hosts, join the session.
Task
Your task in this lab is to use Perlin noise to make a torus appear to be made of glossy marble. Follow these steps to complete this lab:
- Render a wall using a 4-vertex square. Orient it an XY plane, but push it down the -Z axis away from the origin. (Don’t use a camera for this lab. Without a camera, the eye is effectively at the origin. We don’t want the wall and implicit eye to be coincident.)
- Texture and shade the wall using standard diffuse shading. Apply these two textures. Grab the albedo from the color texture and the normal from the normal map texture. If your wall is in an XY plane, then the RGB values of the normal map can be used directly as normals.
- Project a flashlight from the origin onto the wall. Apply this lens texture: Use the RGB channels of the texture as the light color, which is modulated (multiplied) by the diffuse term.
- Allow the flashlight’s direction to be modified by the mouse. I recommend you track the flashlight’s
to
property and update it when the pointer is locked using these event handlers:window.addEventListener('mousedown', () => { document.body.requestPointerLock(); }); window.addEventListener('mousemove', event => { if (document.pointerLockElement) { // update flashlight using event.{movementX,movementY} render(); } });
- Submit your
index.js
on Crowdsource. Enter the eIDs for your team members. If you need to make changes after you’ve already submitted, just reload the page and resubmit. If you haven’t finished by the end of the scheduled lab time, you are free to continue working. However, the submission must be made before the end of the day to receive credit.