Due: Tuesday, May 9, 10:30am


In this assignment, you'll write several shaders. Write your shaders using the methodology described in the Writing Shaders section of RManNotes . The shaders you'll write in this assignment will only have 1 layer -- except for problem #4 which will have 2 layers.
Use the tester.rib rib file to render your shaders.
Create a shader called horizon.
The shader should have one parameter (instance variable) called
location of type string
which specifies the type of horizon desired.
Use the spline() function to generate simple
vertical washes which have a color scheme based on the
location parameter. For example,
if the location is "desert" the color might go from sienna, to tan,
to light blue, to deeper blue from the bottom of the surface to the top.
Your shader should handle the following locations: "desert," "arctic," and "sunset." You may add others if you like. Your shader should have some well-defined action if an invalid location is specified by the user and you are not required to perform any illumination calculations in this shader.
To get you started, the shader declaration should look like:
surface horizon(string location = "desert")
{
/* your code here */
}
cornwash which has the following declaration:
surface cornwash(color upleft = color (1,0,0), upright = color(0,0,1),
lowleft = color (1,1,0), lowright = color(0,1,0))
Your shader should interpolate (linearly) between the colors at all
four corners to compute the color at the current point. You can change
the default values to your liking.
Big hint: use the mix() function 3 times.
![]() | ![]() | ![]() | ![]() |
background | foreground | foreground[3](alpha) | "imatte" on a patch |
Write a shader called imatte which composites one
foreground image over a background image
AND allows the foreground texture to be repeated an
arbitrary number of times. This shader should also have the "plastic"
illumination model.
Your shader should have parameters for the following:
Your foreground image must have an alpha channel which varies (you can look at the alpha channel of an image using xpost or PhotoShop or Amazon or iplay). Most rendered images will automatically have a varying alpha channel (opaque where objects are and transparent where the background is). Most scanned images will not have a varying alpha channel (either completely opaque/white or completely transparent/black) -- this type of image will have to be manipulated (image processing-wise) to generate a useful alpha channel. Here is the TIFF file for the yellow ball used in the images above. It already has a valid alpha channel. You may use it for testing your shader.
If the alpha channel in the foreground image (top[3]) for
a particular surface point is 1 (ie. the foreground image is opaque at that
point), we should only see the foreground image.
If the alpha channel is 0 (ie. the foregound image is transparent at that
point), we should only see the background image. Finally, if the alpha channel
is x% we should see 100 - x% of the background image blended with
x% of the foreground image.
For each of the above shaders submit as many images as you need to show the range of parameters your shader uses (e.g. for the horizon shader, demo each possible location). Each image should be a jpeg of around 200 x 200 resolution (big enough to see... small enough to fit on one page so they can be compared side by side). Make sure that each file is world-readable and in the requested format. To make a file called 'image.jpg' world readable, type "chmod a+r image.jpg" in a UNIX shell.
To hand in your assignment, in ~mlewis/HTML/Light/Hw/2000/, in the subdirectory with your username, create a directory called Hw5. Place a web page called hw5.html in this directory. Also place your JPEG image files in this directory. The web page should display your three images. Remember to pay attention to capitalization of file and directory names as well as file permissions. Test the link from the class student work web page and make sure there are no problems.
In the web page, explain briefly (a few words) what each image is showing.
Last updated: 05/04/00 by
mrl
Steve May (smay@cgrg.ohio-state.edu)