CS184 AS8: Textured Smooth Surfaces
DUE DATE: Wednesday April 15th, 11:00pm
You may work with a partner for this assignment.
Aim
In
this assignment we use the track generator part of As#7 to create
ribbons, sculptures, worms, or snakes with textured surfaces.
You will learn how to make smooth -- or smooth-looking surfaces, and
how to make these surfaces more interesting with texture-mapping and
with bump-mapping.
Minimum Specifications
We will provide you with a reduced rollercoaster generator/renderer
that has the supporting columns stripped out. We will use the remaining
sweep generator to accomplish the following:
- Creating an interesting shape: by modifying
the spline control points and using an interesting cross section. For
instance try to bend a thick worm into a tightly knotted, tangled ball
... BE SURE TO MODIFY the provided curve shape and cross section!
- Create a really smooth surface:
by replacing the polygonal cross section with a closed B-spline and
rendering the whole sweep as a finely sampled B-spline surface.
- Write GLSL shader code to render your shape with phong interpolation.
Use a phong illumination model (not blinn-phong) and perform your lighting calculations in
eye space (not tangent space).
You may customize your shader to the specific lights in your scene. Pressing 'F' should toggle
between your Phong interpolation and the fixed function pipeline's
gouraud interpolation.
See the implementation tips section for more information on GLSL shaders.
- Texture-map this surface: Use
one or more texture tiles and place them on your surface to create a
seamless patterning. Support the texture mapping in your shader, and
use a uniform input variable to toggle it on and off when 'T' is
pressed.
- Bump-map this surface: Add
support for bump mapping to your shaders and use one or more bump-map
tiles to decorate your surface. Use a uniform input variable to toggle
the bump map on and off when 'B' is pressed.
- Combine texture-mapping and bump mapping: pick two maps
that yield correllated results, e.g. something like a stained-glass
window: enhanced, raised, gray lead-beads that separate facets of
bright colors.
Extra Credit ideas:
- Experiment with different shaders: Try implementing a parallax bump mapping shader or a toon shader.
- Implement displacement mapping.
- Create a surface of genus > 1, and texture map it.
Sweep File Format
We provide a simple custom file format to specify a (closed) sweep, an
example of which is provided with the framework. The format provides
the following commands:
- p x y: Define a control point of the cross section's b-spline.
- v x y z [az]:
Define a control point of the sweep curve's b-spline. [az] is a last optional
parameter, which specifies a local azimuth value on the spline. Note
that these azimuth values are smoothed by the b-spline function just
like the x, y, z.
- twist tw: Specify a global twist for the track
- azimuth az: Specify a global azimuth for the track
- texture "texturefile.png" [rl] [rw]: Specify a texture for the track.
- bump "bumpfile.png" : Specify a bump map for the track
- -- pattern repetition: The optional integer parameters [rl] and [rw]
specify how many times the texture repeats in the longitudinal (length)
direction [rl] , and in the lateral (width) direction [rw] over the
whole tubular surface. The default for these values is 1.
- # comment: Lines beginning with '#' are comments
Example Sweep File
# basic sweep example
# global azimuth of 45 degrees everywhere - as a starting base for further modifications.
azimuth 45
# global twist 360 degrees - i.e., a linearly increasing azimuth, starting at 0 degrees and ending at 360 degrees.
twist 360
texture "tracks.png" 30 2
bump "tracksBumps.png"
# a simple cross section
p -1 1
p 1 1
p 1 -1
p -1 -1
# a simple knotted loop (trefoil knot).
v 10.0 -2.0 4.0
v -6.732 7.66 -4.0
v -6.732 -7.66 4.0
v 10.0 2.0 -4.0
v -3.268 9.66 4.0
v -3.268 -9.66 -4.0
Submission
To submit this project, all of the following needs to be done by the deadline:
- Submit using the submit as8 command on the INST machines:
- A copy of your code, including the whole framework, the compiles on the platform you developed on.
- All shaders and textures you used.
- A README.txt containing: Your name, SID, Login and a description of the platform your code compiles on.
- FOUR
images of the shape you have designed from a view which allows the
whole thing to be seen: with Gouraud interpolation, then with Phong
interpolation, then with Phong interpolation and texture, and finally
with Phong interpolation, texture and bump mapping
- ONE animated GIF of your shape rendered with all features enabled. Show how the shading changes as it rotates.
- The trk file for your custom sweep
- Put on your class instructional website:
- A separate page for this assignment.
- On this page, the images you are turning in, as well as the coaster track files for them.
Windows Users: The grader should ONLY have to open your .sln file and press F5 to build and run your solution.
*Nix Users: The grader should ONLY have to run make with the appropriate makefile to build your project. Thus, for Mac and Linux
make
and for solaris
gmake
.
Note:
The submit program retains the directory structure of what you send it.
Thus, we recommend making a new directory for your assignment on the
server, cd'ing into that directory, copying the whole framework with
your code into this directory, and running
submit as8
to easily submit the whole project to us.
Framework
See the
Framework
page here. Version 6 of the framework provides code to load and display
sweeps, as well as code to load textures and GLSL shaders. Note that
this assignment does require more powerful graphics hardware than
previous assignments; if your computer doesn't support pixel shaders,
the computer in the labs should work.
Implementation Tips
- Dimensions of image sizes for textures should be a power of two along each axis to play nice with your graphics card memory.
- Chapter 17.3.4 includes an example fragment shader which implements phong interpolation. Note that the code is incorrect (missing a normalization, uses blinn-phong model instead of phong despite saying phong). However, you can use this to get a feel for the language.
- GLSL documentation is also available at http://www.opengl.org/documentation/glsl/
- Hints and suggestions are spread throughout the code, search for HINT and TODO in the shaders and the cpp files.
- Most of your code can go in the shaders and the renderSweep function.
- Don't worry much about making the lighting for the shader and the fixed function pipeline match, just use some reasonable illumination for both.
It's fine to hardcode light information in the shader for this assignment.