Lab 6: Volumetric Effects

Assigned: 05/07

Due: 05/21


Introduction

The goal of this lab is explore ways of performing volumetric rendering using shaders.

Shaders

In this lab, you will build a sequence of shaders that render volumetric effects. The lab exercises mirror the topics covered in lecture; you may want to refer to the lecture notes while working on this assignment.

You will write the following shaders:

For each submission you should include the shader code and an example image which illustrates the effect. It should be clear that the later submissions are extensions of the code written for the earlier submissions of this lab.

As with previous assignments, two ZIP archives have been provided for you:

What to Submit

As with previous assignments, please place your solutions in the lab6results folder, as follows:

Create a ZIP archive of your results folder by using the "Compress" entry of the right-click menu for the folder. Submit this ZIP archive on one of the Ubuntu systems with the command

try  wrc-grd  shading-6  lab6results.zip

Important note: because of grading time constraints, there is no late period for this lab - late submissions will not be accepted.


Tasks

Part 1 - Basic

For this first part, you will be implementing a shader that implements a basic uniform fog. Please use the specification mentioned in lecture (i.e. parameters to your shader should be fog color and the constant fog density). Both texts show examples of a fog function.

When implementing this in RenderMan, there are few things to note. First, there is a standard "fog" shader in RenderMan. This means you must name your fog shader something other than fog (myFog, fog2TheSagaContinues, walkingAroundInAFog, etc.)

Another thing to note is that although fog is an atmospheric effect, it must be bound to a particular primitive. In RenderMan, this means that each primitive must have your fog shader defined as the Atmosphere shader for the primitive. This means that it's actually possible to selectively apply fog (e.g., in our classic scene, you could apply fog to the sphere and not to the wall and floor); however, this will probably not give you the resulting effect you're looking for. The RIB file found in the lab6files.zip ZIP archive is an example of proper binding using the standard RenderMan fog shader. The use of the original brick and wood shaders make the fog more noticeable.

To apply your fog shader in GLSL, you simply keep the shaders bound when you draw all three of the objects in the scene Recall that GLSL only knows about verticies and fragments; it does not have the concept of "atmospheric" shaders. Thus, the GLSL shaders must not only implement the fog, but apply it to whatever other surface characteristics the shader is calculating. You should feel free to use whatever past shaders you have written (the tile floor would be interesting).

Finally, you may have to play with the density parameter a bit to get a decent effect. Provide an image using a decent value for this parameter. Playing with the fog color could also prove to be interesting. Experiment; be creative!


Part 2 - Intermediate

For this part, you will be implementing the basic ray marching algorithm and using it to calculate the same fog that you created in Part 1. You may wish to write a general ray marching function since you will be needing one again for Part 3. In this routine, you should call additional functions that determine the density at a point (which is constant for uniform fog) as well as one that does the lighting for a point (which, once again, will be constant for fog).

The ray marching algorithm given in the lecture notes is from Chapter 12 (page 315) of the Advanced Renderman text. The version in that book has two typographical errors: in the Cvol and Ovol equations inside the loop, the subexpression "+ stepsize" should be "* stepsize" (i.e., the expression should use multiplication, not addition). The version of the algorithm given in the lecture notes is correct.

Ray marching is also discussed in Chapter 9 of The RenderMan Shading Language Guide. The algorithm given there is slightly different; you may find it helpful to compare the two.


Part 3 - Advanced

In Part 3, you will have the choice of either creating a Hypertexture or creating stage fog simulating Mie or Rayleigh Scattering.

If you select the Hypertexture option, you will be creating a Hypertexture fireball or cloud. Use the ray marching routine written for Part 2 to implement this. You can use a basic turbulence for the definition of the density function. You can implement this as a surface rather than an interior shader if you prefer. You may want to (re-)read Ken Perlin's Hypertexture paper. Feel free to experiment with different density functions and colorings.

If you select the stage fog option, your goal is to use fog to accentuate a beam coming from a spotlight. Use either a constant density or a noise based density function, and use the Mie Scattering or Rayleigh Scattering model to simulate the scattering. Once again, be creative! (See the lecture notes for equations for the Mie and Rayleigh Scattering models.)


RenderMan® is a registered trademark of Pixar.