CS 651-4/551-3: Real-Time Rendering
Assignment #3
Synopsis: Experiment with Cg and do something interesting with particle systems, optionally using the capabilities of the NV30 emulator.
Due:
Sun Nov 10, 11:59 PM - Checkpoint: do the Cg
tutorials.
Sat Nov 16, 11:59 PM - Final assignment due.
Details: The goal of this assignment is to get you to experiment with writing shaders in the Cg language. Ideally, you will be able to integrate Cg into your rendering engine; this will let you use not only your own shaders but the many other shaders available at http://developer.nvidia.com/cg and http://cgshaders.org. However, for the purpose of this assignment you may simply demonstrate your shader on whatever codebase you like. For example, you may wish to simply build on the Visual Studio projects that come with the tutorials.
Your first task is simply to run through the tutorials (we did the first one in class) These are quite simple; the main point is to give you an infrastructure for compiling Cg and programs that use the Cg runtime for shaders. Modifying these shaders and the Visual Studio workspace containing the tutorials should give you an easy way to experiment with your own shaders. You don't need to turn in anything for this checkpoint, except to send me e-mail announcing that you successfully used Cg and did the tutorials (since the solution is included, this should be hard). Plus, if you want to do something besides a particle system for the final assignment (see below), you must propose it in your checkpoint e-mail.
Your next task is to build a particle system using vertex programs. Since vertex programs can calculate the vertex position as a function of time, they can be used to implement simple physical or non-physical particle systems. For example, a vertex shader can compute the effects of gravity and wind on falling sparks. Games use this technique frequently to implement explosions, fire, water, grass blowing in the wind, hair, "swarming points of light" magic effects, and yes, splashing blood. You will probably want to combine such particle systems with the NV_POINT_SPRITE extension, which allows you to draw each vertex as a screen-aligned quadrilateral with a (possibly animated) texture applied. You may optionally use fragment programs and/or the NV30 Cg profile as well. Where will you get ideas for this? Look over the sample shaders in the Cg users guide and at the above web sites, read the book, search the web, ponder the capabilities of the NV30 hardware (your shaders need not use the NV30 emulator, but it will be a lot easier to write interesting shaders using NV30, especially fragment shaders).
I want to leave open the possibility of doing something else interesting with the exciting capabilities of Cg and the NV30 architecture, so if you would prefer to implement something besides a particle system, you may propose your idea(s) to me at the checkpoint and I will (quickly) give you feedback on their feasibility, on possible approaches, and on useful resources you may wish to consult. Here are some example ideas to get you thinking:
Once you commit to working on a particular effect, you are committed: no changing your mind at the eleventh hour and trying to whip out a mediocre particle system. I will work with you to make sure that you don't bite off more than you can chew.
Resources:
Policy on code reuse: The usual. You may use your own code or code from outside sources as long as you attribute exactly what you used and where you found it, and share any particularly valuable finds with the rest of the class. Obviously if you reuse a significant amount of code that raises the bar for the assignment, and you will be expected to do additional work to get the same grade that you would get if you did all the coding yourself. As always, if you have any questions about code reuse or attribution, please ask me.
Platform: As before, I expect that your code will compile and run on the machines in 002a, either in Windows or Linux.
Turning in the assignment: Put all your code and models in a folder, along with a detailed README.txt file that describes what you did, what code you wrote and what code you used from elsewhere, and how to run your assignment. Zip up the file and e-mail it to me, or put it somewhere I can download it. Be sure to include workspace and project files so that I can compile your code. I will read (and grade you on) your source code, so follow good programming practices. Naming convention: for (my) convenience, please name the zip file and the enclosing folder of your project with just your last name, e.g. "luebke.zip".
Advice: Start with a simple Cg shader that implements sinusoidal motion: given a starting position of the vertex (varying parameter) and the current time (uniform parameter), calculate the current position. Then implement initial velocity (varying parameter) and gravity, for firework-like effects. Make it pretty by using NV_POINT_SPRITE and fancy textures. Then go crazy.