CS 519 -- Spring Quarter 2009

Project #4

Interactive Noisy Elliptical Polka-dots

100 Points

Due: April 30


This page was last updated: March 19, 2009


Requirements:

  1. The goal of this project is to beat the elliptical shader thing to death, but this time make it interactive using the OpenGL Shading Language and glman.

  2. Create a GLIB file that produces parameter sliders for:

    ParameterWhat It Does
    AdEllipse radius #1
    BdEllipse radius #2
    NoiseAmpNoise Amplitude
    NoiseFreqNoise Frequency
    TolWidth of the blend between ellipse and non-ellipse areas

  3. The NoiseAmp parameter is the amplitude of the noise function, i.e., it multiplies the noise value.

  4. The NoiseFreq parameter is the frequency of the noise function, i.e., it multiplies what goes into the noise function.

  5. The effects of the NoiseAmp and NoiseFreq parameters should look something like this:
      NoiseAmp NoiseFreq

  6. The Tol parameter is the width of a smoothstep( ) blend between the ellipse and non-ellipse areas, thus smoothing the abrupt color transition.

    Tol

  7. You can have as many other slider-based uniform variables as you wish.

  8. Apply lighting.

  9. This must be done procedurally, i.e., with equations in a Fragment Shader program.

  10. The choice of geometry is up to you. You are allowed to contrive the size to make it work.

Extra Credit #1 (+5 points)

Add an Alpha parameter that changes the opacity of the non-ellipse areas. When Alpha == 0., do a discard( ) instead of setting alpha.

ParameterWhat It Does
AlphaOpacity of non-ellipse areas

Alpha

Extra Credit #2 (+5 points)

Add a ChromaDepth feature that colors the scene in color gradations: Red in the front, Blue in the back, and Green in the middle. At the least, include a new slider called Blend which turns ChromaDepth on and off. Also feel free to add sliders to control at which depths Red and Blue appear.

ParameterWhat It Does
BlendBlend between no-ChromaDepth and using ChromaDepth.

ChromaDepth

If you normalize a distance t so that it is t=0. in the front of the object and t=1. in the back, here is code to assign the colors. (It is actually just the hue-only part of the rainbow color scale.)


vec3
ChromaDepth( float t )
{
	t = clamp( t, 0., 1. );
	t *= (2./3.);

	float r = 1.;
	float g = 0.0;
	float b = 1.  -  6. * ( t - (5./6.) );

        if( t <= (5./6.) )
        {
                r = 6. * ( t - (4./6.) );
                g = 0.;
                b = 1.;
        }

        if( t <= (4./6.) )
        {
                r = 0.;
                g = 1.  -  6. * ( t - (3./6.) );
                b = 1.;
        }

        if( t <= (3./6.) )
        {
                r = 0.;
                g = 1.;
                b = 6. * ( t - (2./6.) );
        }

        if( t <= (2./6.) )
        {
                r = 1.  -  6. * ( t - (1./6.) );
                g = 1.;
                b = 0.;
        }

        if( t <= (1./6.) )
        {
                r = 1.;
                g = 6. * t;
        }

	return vec3( r, g, b );
}

Note that this code implements the full (H,S=1.,V=1.) to (R,G,B) conversion. You need to keep t between 0. and (2./3.) because you are only interested in the Red-Green-Blue color range. This code is good to keep around. There are lots of good visualization uses for it too.

Letting Me Know to Test the Extra Credits

It would be a big help to me if you would use the GLIB MessageBox command to let me know if you have implemented one or more Extra Credits. For example:

MessageBox This implements the Alpha and ChromaDepth extra credits

Hints:

The Turn-In Process:

  1. Your electronic turnin will be done at http://engr.oregonstate.edu/teach and will consist of:
    1. At least 4 image files showing the original image and images representing different values for (Ad,Bd), NoiseAmp, and NoiseFreq. These can be submitted individually, or placed into a PowerPoint file.
    2. If you do the Extra Credit, then also show files exhibiting changes in Tol and Alpha.
    3. Source files (.glib, .vert, .frag)

    Electronic submissions are due at 23:59:59 on April 30.

  2. Your paper turnin will be a stapled bundle consisting of:
    1. A cover page (name, Project #4)
    2. Images showing what you did (color preferred, grayscale accepted)
    3. Source listings (.rib, .sl)
    4. A prose explanation of what you did and why it worked. (Your submission will not be considered valid unless you can explain why it works.)

    The paper turnin is due the class period following the electronic copy due date, May 1.

Grading:

FeaturePoints
Correct changes in Ad and Bd20
Correct changes in NoiseAmp30
Correct changes in NoiseFreq30
Correct changes in Tol20
EC #1: Correct changes in Alpha5
EC #2: Correct ChromaDepth5
Potential Total110