CS 398: Introduction to Graphics Programming

Assignment: Animation


In this assignment, you will implement physics-based animation on GPUs. Completing this assignment lets you understand how to utilize GPUs for certain animation tasks.

Base Code

Once you downloaded the base code from Piazza and started a local web server, click here to open c_animation.html. Make sure to start a local web server if the link does not work. You will need to extend this base code to implement the tasks outlined below using GLSL (i.e., you don't need to do any computation outside shaders, except for setting up shaders, initializing textures, setting up uniform variables, etc). All of the animation should be done in 2D.

Task 1: Particles

Implement a particle dynamics simulator as explained in the lecture. Add the gravity force so that the particles are falling down and accelerating downward. When a particle went below the simulation domain as specified in the base code, it should come back to the location of the mouse cursor with its initial velocity given by randVel in the code. Your code should run this simulation when uniforms.animationType == 0.

Task 2: Connected Particles

Implement a dynamics simulator of a string of particles as explained in the lecture. Pick the number of iterations for the constraint, the number of particles, and the length of the entire string properly to demonstrate your result (you may need to try out different values to see reasonable results). It is generally recommended that you consider a few tens of connected particles with several tens of iterations (i.e., not 3 or 300 particles, or not 7 or 700 iterations). Connect one end of the string at the location of the mouse cursor, so that you can move it around by moving the mouse. Note that particles do not need to be reset as in Task 1 when they are outside the simulation domain. Your code should run this simulation when uniforms.animationType == 1.

Task 3: Collision

Implement a collision detection and response system for particles against a circle. You need to add it to the code of Task 1 and/or Task 2 so that collisions of particles are clearly visible in your result. You can implement it by detecting if a particle is inside the circle or not, and if so, push it back outside the circle in the position-based dynamics approach.

Task 4: Waves

Implement a wave simulation based on a numerical solution of the wave equation in on a fragment shader. You can use finite difference methods to approximate the wave equation over a grid of points as explained in the lecture. Keep the boundary condition and the source term in the base code to simulate a double-slit experiment. Visualize the wave propagation in two dimensions as interactive animation. Your code should run this simulation when uniforms.animationType == 2.

Task 5: Demo

Take the implementations from the previous tasks to create something interesting. Consider adding user controls to manipulate the simulation in real-time, such as changing parameters, adding new particles, or modifying the environment. Document your process and the features you implemented in your README file, and ensure that your final demo showcases the capabilities of the program you have made. Feel free to expand your code as needed.

Submission

The submission process for this assignment is basically the same as the one for Assignment: Warm-up. See Assignment: Warm-up for instructions about how to prepare your submission. If you are doing something extra, be sure to document them in your README file. If your changes are so radical that your modified program is incompatible with the original specification for each task, you must include a "compatibility mode" that makes the interface behave like the requirements here, or consider creating an entirely separate code.