Due: end of day Monday, March 20
Goal: In this assignment you will gain experience with heads up display, basic level modeling, frustum culling and portal culling.
Submission: Submit your assignment using this Google form.
The main components of this programming assignment are:
- 5% Part 0: Properly turned in assignment
- 20% Part 1: Create and render a level
- 20% Part 2: Create and render a heads up display
- 20% Part 3: Implement frustum culling
- 35% Part 4: Implement portal culling
- Participation credit: You can receive participation credit (outside of this assignment) for posting your resulting imagery and video, good or bad, on the class forum!
The room environment you render is described by a simple JSON file. An example room file is located at https://ncsucg4games.github.io/prog2/rooms.json. This example is a simple two-room, two-portal environment. The file contains a 2D rectangular grid of tokens, each representing a 1x1 cubic environment cell. Tokens may have the following values:
- number. Represents a cell in room number.
- p. Represents an open portal cell viewers can move or see through.
- s. Represents a solid cell viewers cannot move or see through.
Cells may contain additional geometry, as described in accompanying sphere and triangle files (as used in the previous semester). The rooms.json file contains an additional array that locates this geometry. Each entry in this array has the following format:
- number. The number of the room in which to locate the geometry
- x. The room relative cell column in which the geometry is located, 0 at left
- y. The room relative cell row in which the geometry is located, 0 at top
- type. Either "sphere" or "triangleset", depending on which type of geometry to use
- item. The number of the sphere or triangle set to use, as described in spheres or triangles.json
Each cell has a local coordinate system, with (0.5,0.5,0.5) at the center of the cell cube. Sphere and triangle set coordinates are given in this local system.
We will test your program using several different input files, so it would be wise to test your program with several such files. When you turn in your program, you should use the above URLs in hardcode as the location of the input files — they will always be there. While testing, you should use different URLs referencing files that you can manipulate, so that you can test multiple input files. Note that browser security makes loading local files difficult, so we encourage you to access any input files with HTTP GET requests.
You should code the core of this assignment yourself. You may not use others' code to render a level, determine frame time, or cull. You may use text and math libraries you find, but you must credit them in comments. 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 what you are contemplating is permissible, simply ask me or the TA.
Part 0: Properly turned in assignment
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: Create and render a level
Render the multi-room environment described by the input JSON file described above. The initial viewpoint should be the central cell (or one of the four central cells) of room 0, looking toward a portal. That cell should also contain a white light source at the ceiling, as should a central cell in every room. Support navigating the viewpoint through the level with arrow keys. Every open (numbered) cell will have a ceiling and a floor. Any cell side next to a solid (s) cell will have a wall at the solid cell's boundary. Any portal cell (p) will have two walls against ajacent solid cells, a ceiling, and a floor. All walls should be textured, using a texture you find. Render any additional geometry contained in each cell. We suggest parsing the JSON file and generating matching vertex and triangle buffers for the level during initialization.
Part 2: Create and render a heads up display
Overlay a textual display of the count of rendered triangles and frame time on top of the current view. A simple method for measuring frame time is to record the beginning and ending times of each frame callback, and average their difference over the last ten frames.
Part 3: Implement frustum culling
Implement frustum culling as described in class to reduce rendered triangles and frame times, comparing each triangle against the frustum planes. Confirm that both triangles and times decline in your heads up display. You may have to have a fairly large model to see this effect (i.e. the default model we provide may not do). Render without culling when "1" is pressed, with frustum culling when "2" is pressed.
Part 4: Implement portal culling
Implement portal culling as described in class. Extract the graph you need from the input room environment: each numbered room is a node, and each portal cell p is a link. Confirm that both triangles and times decline further in your heads up display. Render with portal culling when "3" is pressed.
EXTRA CREDIT GRADING:
Extra credit opportunities include the following, with values in format (462, 562). Others are possible with our approval:
- (1,½)% Add collision detection. Detect when the user moves through a room wall, ceiling or floor. Revert to the previous view to respond to the collision.
- (1,½)% Add sound. A walking sound, and if you implement collision, a bumping sound.
- (1,½)% Add standard models. Add an additional geometry type using a standard model format like obj or the json format. Display a few more interesting objects in the rooms.
- (3,1)% Implement a top down visualization of portal culling. Use the floor plan view in the portal culling paper. The visualization should show the room layout, and interactively update the eye position and the portal-cultured frustum boundaries.
- (3,1)% Add hierarchy. Cull at least per room, then per cell, and finally per triangle. Switch between per-triangle and hierarchical culling with the "h" key.