# CMSC 381: Intro to graphics programming

## Prof. Blaheta

Computers have been creating graphics since at least the 1960s, but in the last few decades an exponential increase in computing power has meant that computer graphics are now capable of incredibly high-definition photorealistic graphical output at high speeds---which in turn means that we all now see computer-generated images and video on a daily basis. Games, movies, print media, and most professional websites are all but guaranteed to make use of some sort of generated graphics.

In this course, we'll write programs to create graphics and better understand some of the math and theory that makes them work.

This class meets 2:00pm on MWF in Ruffner 352.

The textbook is Edward Angel and Dave Shreiner, Interactive computer graphics: a top-down approach with WebGL, 7e (ISBN 978-0-13-357484-5).

### Homework

• For 25 Jan: finish exercises from 23 Jan: draw a shape in outline; draw a quadrilateral; make multiple shapes side-by-side; and draw a circle. Try using separate files for each one!
• For 27 Jan: experiment with the javascript in the files we've been working with, and get it to draw a circle (programmatically, i.e. don't just type in a bunch of coordinates).
• For 1 Feb: Convert circle into a beachball.
• For 3 Feb: Make your beachball spin.
• For 20 Feb: Draw a single triangle (like in our first examples), and animate it to rotate about an apex that's not at (0,0). Do it using matrices for all the affine transforms; don't do it by just starting the apex at (0,0) and moving it later. Also, bring your laptops on Monday.
• For 22 Feb: Keep with the triangle and once you've got it rotating, make it move around the canvas (still rotating about the apex, but now the apex is moving). Bounce off the edges, but no worries about gravity or if it hangs off the edge (as long as it doesn't get stuck there). All the work (translation, rotation, and scaling if you do it) should be done via matrices multiplied together.
• For 15 Mar: Reuse or build a small scene with one or two "solid" objects, and use lookAt and ortho to build an orthographic camera to view the scene. (and bring your laptop to show it to us/ask questions if it's not working)
• For 17 Mar: Adapt your scene from Wednesday to use perspective instead of ortho. Try different values and see what they do. If any look particularly interesting or unusual, make note of the parameters and bring them up in class.
• For 22 Mar: By choosing different lookAt orientations and different ortho and perspective parameters, inspect a variety of different model-view and camera matrices and write down a few that seem to have interesting properties ("this one is just like a rotation matrix", etc). Also, bring your laptops.
• For 27 Mar: Do the exam!
• For 29 Mar: Explain why a full moon (on a clear night) is much more than twice as bright as a half moon. Bring your explanation with you to class. Also, keep your eyes open for good examples of deceptive coloration, interesting differences between diffuse and specular reflection, or anything like that, and try to get a good photo of it if you can.
• For 31 Mar: Copy the files for today's work (lighting-1) into your own directory and play with them; try editing the shaders to set up an ambient and a diffuse component for a Phong shading model (specular will come later).
• For 3 Apr: Copy today's files (lighting-2) into your directory and try to compute the vectors appropriately, and get diffuse lighting working. (Look for the TODO in the code we've already written.)

### Projects etc

• Due 13 Feb at 4pm: Project 1
• Due 24 Apr at 4pm: Project 2
• Due 8 May at 5:30pm (final): Project 3 (Edited 2 May 2:30pm) (Edited 7 May 4:50pm)
• strip.txt, teapot.txt; Note: tweaked as of 2 May 2:30pm, although the old files are still valid if you already have them; see edited handout for a couple clarifications about the data in the files.

### In-class demos

All these files can be accessed directly on the server (torvalds itself) in /srv/http/htdocs/courses/cmsc381/s17/class/.