Final submission due: 11:59pm, Monday September 21
Goal: In this assignment you will practice the ray casting methods that we are discussing.Submission: Submit your assignment using this Google Form.
Introductory refs: On javascript.
GRADING:
- 5% Part 0: properly turned in assignment
- 30% Part 1: ray cast the colored ellipsoids in the input file without lighting
- 30% Part 2: color the ellipsoids with Blinn-Phong illumination
- 10% / 5% Part 3: windowing, viewing and lighting
- 10% / 5% Part 4: shadows
- 5%X / 10% Part 5: triangles
- 15% Part 6: make it your own
- Extra credit: be voted most interesting
- Participation: Receive participation credit (outside of this assignment) for posting images of your progress, good or bad, on the class slack!
You will only render ellipses in this assignment, which are described in an input file. We will test your program using several different input files, so it would be wise to test your program with several such files. The input files describe an array of ellipsoids using JSON. An example input file resides at https://ncsucgclass.github.io/prog1/ellipsoids.json. When you turn in your program, you should use this URL in hardcode as the location of the input ellipsoids file — it will always be there. While testing, you should use a different URL referencing a file that you can manipulate, so that you can test multiple ellipsoids files. Note that browser security makes loading local files difficult, so we encourage you to access any input files with HTTP GET requests.
We provide a small shell in which you can build your code. You can run the shell here, and see its code here, and find all supporting files in the progam 1 repo. The correct image for the default input is here. The shell shows how to draw pixels without using WebGL, and how to parse the input ellipsoids.json file. It contains three drawing functions: one that merely draws random pixels, one that loads the ellipsoids file and draws orthographic projections of them using canvas draw functions, and one that loads the ellipsoids file and renders some random pixels in them. The last is probably closest to what you must produce for this program. Some of our programming exercises also contain relevant code.
All vertex locations should be described in world coordinates, meaning they do not require any transformation. Locate the eye at (0.5,0.5,-0.5), with a view up vector of [0 1 0] and a look at vector of [0 0 1]. Locate the window a distance of 0.5 from the eye, and make it a 1x1 square normal to the look at vector and centered at (0.5,0.5,0), and parallel to the view up vector. With this scheme, you can assume that everything in the world is in view if it is located in a 1x1x1 box with one corner at the origin, and another at (1,1,1). Put a white (1,1,1) (for ambient, diffuse and specular) light at location (-0.5,1.5,-0.5).
This is an individual assignment, no exceptions. You should code the core of this assignment yourself. You may not use others' code to determine the location of pixels in the world, to do ray-ellipse intersection, or to color a pixel. You may use math libraries you find, but you must credit them in comments. You may use AI, but your code must be unique, not identical to your fellow students'. You may recommend libraries to one another, speak freely with one another about your code or theirs, but you may never directly provide any code to another student. If you are ever uncertain if the advice you want to give or code you want to use is permissible, simply ask me or the TA.
Remember that 5% of your assignment grade is for correctly submitting your work! For more information about how to correctly submit, see this page on the class website.
Part 1: Using ray casting, render unlit, colored ellipsoids
Use ray casting to render unlit ellipsoids, with every pixel in each ellipsoid having the unmodified diffuse color of that ellipsoid (e.g, if the diffuse color of an ellipsoid is (1,0,0), every pixel in it should be red). You will have to test for depth, to ensure that each ellipse is correctly colored. You should see flatly colored ellipses.
Part 2: Using ray casting, render lit ellipsoids
Now you will have to perform a local Blinn-Phong lighting calculation at each intersection. To do this, you will need the normal vector at the ellipsoid intersection point I. The formula for the normal at a point on the surface of an ellipsoid centered at the origin is [2Ix / a2 2Iy / b2 2Iz / c2]. Generally, ellipsoids are not at the origin, so center the intersection point by subtracting the ellipsoid center C from it: [2(Ix - Cx) / a2 2(Iy - Cy) / b2 2(Iz - Cz) / c2]. As you perform that lighting calculation, don't forget to normalize your vectors. You should now see ellipses with depth revealed by illumination, in the same locations and with the same silhouettes as in part 1. You need not show your results for Part 1, if you have completed Part 2.
Part 3: Windowing, viewing and lighting — (461: 10%; 561: 5%)
Now make your windowing flexible. Accept a new canvas (viewport) width and height through your UI. Size your canvas to match, and change your ray casting interpolation to match. This should affect every part of your assignment.
And make your viewing flexible. Accept new eye location, view up and look at vectors through your UI. Reorient the window to be normal to the new look at vector and centered around the new eye. Render the scene with these viewing parameters. Note that with bad viewing parameters, you will not see the model. This should affect every part of your assignment.
Also, make your projection flexible. Accept new window parameters through your UI. Relative to the viewing coordinates described by the look at and up vectors, these will be two X values (left, right) and two Y values (top, bottom). Adjust your ray casting interpolation to this new window. Render the scene with these new projection parameters. Note that these coordinates will be in view space, not be in world space! Also with bad projection parameters, you will not see the model. This should affect every part of your assignment.
Finally, Read in an additional lights.json file that contains an array of objects describing light location and color. Note that these lights will have distinct ambient, diffuse and specular colors. Render the scene with these lights. During illumination, you will have to sum the colors all the lights. You can find an example lights.json file here. Assume that the input lights file will always reside at this URL when you turn in your code.
When performing lighting during ray casting, shoot an additional ray toward the light to decide if only ambient light reaches the intersection. Make sure to shoot a ray at each light! This should only affect the last part of your assignment.
Part 5: Render triangles — (461: 5% extra; 561: 10%)
Until now, you strove to make your image look "correct". Now you should use the techniques you have learned to make a new image that is "interesting". You may work only with ellipsoids, or with other modeling primitives as well (triangles, boxes, etc), but every pixel must be ray casted. You will half credit if you make your image substantially different from that produced by the shell repo input, and from the imagery of your fellow students. You will earn full credit if your work clearly represents significant effort. Your "interesting" image should appear after you press the space bar.
Extra credit: Voted most interesting






