2019 Prog 2: culling — due Monday Feb 25

Due: end of day Monday, February 25

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.

BASIC GRADING:
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!

General:
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.

We provide a rasterizing shell in which you can build your code. You can run the shell here, and see its code here. The shell uses WebGL, and runs in javascript. You may use Visual C++ if you like, but in that case you will be working without a matching shell.

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.

Make up office hours today at 1pm

Hi folks,

As promised, I'm holding makeup office hours today at 1pm.

Apologies for not getting the news out sooner.

Profw

2019 Prog 1: global illumination

Due: end of day Monday, Feb 4

Goal: In this assignment you will improve a basic ray tracer to add diffuse reflections.

Submission: Submit your assignment using this Google form.

BASIC GRADING:
The main components of this programming assignment are:
  • 10% Part 0: properly turned in program
  • 30% Part 1: add a colored "Cornell" box
  • 40% Part 2: add one-bounce diffuse reflection
  • 20% Part 3: add Russian Roulette
  • 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!

General:
You will only render spheres 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 spheres and one or more lights using JSON. An example spheres file resides at https://ncsucg4games.github.io/prog1/spheres.json, and an example light file at https://ncsucg4games.github.io/prog1/lights.json. When you turn in your program, you should use these 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.

We provide a Whitted ray tracing shell in which you can build your code. You can run the shell here, and see its code here. The shell does not use WebGL or OpenGL, and runs in javascript. You may use Visual C++ if you like, but in that case you will be working without a matching shell.

All vertex locations are described in world coordinates, meaning they do not require any transformation. The eye is 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]. The window is a distance of 0.5 from the eye, and is 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). A white (1,1,1) (for ambient, diffuse and specular) light at location (0.5,1,0.5).

You should code the core of this assignment yourself. You may not use others' code to determine the direction of reflection, or sum for light integration. You may use 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 10% 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: Add a colored Cornell box, and intersect triangles
Diffuse reflection doesn't work well in an open environment, so add the 1x1x1 box described above into your code, and color one wall red, the other blue. Make sure the light is at (0.5,1,0.5) (just below the box top). You will have to describe the box with triangles, and perform ray-triangle intersection. You may use intersection code you find, and even share your custom intersection code with fellow students. The box should have six sides for reflections, but do not render the side at z=0, so that you may see its interior. Whitted ray tracing is enough to earn this assignment credit.

Part 2: Add one bounce diffuse reflection
Now you will begin sampling the BRDFs at each bounce using path tracing. Sample each pixel 100 times and average the results. Shoot a ray toward one (the only) point light and then sample the surrounding hemisphere once, using a uniform distribution and rejection sampling. At the next intersection, sample the light only, not the hemisphere. Remember to check for shadows when sampling the light. Use the diffuse term (only) of the Blinn-Phong model as your BRDF.

Part 3: Add Russian Roulette
Rather than bouncing once, use Russian Roulette to continue bouncing half the time at each bounce. Weigh the obtained light appropriately.


EXTRA CREDIT GRADING:
Extra credit opportunities include the following:
  • 1% Add multiple lights, and weigh their light appropriately
  • 1% Add area lights, and weight their light appropriately
  • 1% Add the specular term into your BRDF (make sure reflection is always < 1)
  • 5% Add transparency with refraction

Prog 2: culling

Due: end of day Friday, March 3

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.

BASIC GRADING:
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!

General:
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.

We provide rasterizing shell in which you can build your code. You can run the shell here, and see its code here. The shell uses WebGL, and runs in javascript. You may use Visual C++ if you like, but in that case you will be working without a matching shell.

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.

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. 


EXTRA CREDIT GRADING:
Extra credit opportunities include the following. 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% 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% 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.

Prog 1: global illumination

Due: end of day Monday, Feb 13

Goal: In this assignment you will improve a basic ray tracer to add diffuse reflections.

Submission: Submit your assignment using this Google form.

BASIC GRADING:
The main components of this programming assignment are:
  • 10% Part 0: properly turned in program
  • 30% Part 1: add a colored "Cornell" box
  • 40% Part 2: add one-bounce diffuse reflection
  • 20% Part 3: add Russian Roulette
  • 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!

General:
You will only render spheres 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 spheres and one or more lights using JSON. An example spheres file resides at https://ncsucg4games.github.io/prog1/spheres.json, and an example light file at https://ncsucg4games.github.io/prog1/lights.json. When you turn in your program, you should use these 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.

We provide a Whitted ray tracing shell in which you can build your code. You can run the shell here, and see its code here. The shell does not use WebGL or OpenGL, and runs in javascript. You may use Visual C++ if you like, but in that case you will be working without a matching shell.

All vertex locations are described in world coordinates, meaning they do not require any transformation. The eye is 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]. The window is a distance of 0.5 from the eye, and is 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). A white (1,1,1) (for ambient, diffuse and specular) light at location (2,4,-0.5).

You should code the core of this assignment yourself. You may not use others' code to determine the direction of reflection, or sum for light integration. You may use 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 10% 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: Add a colored Cornell box, and intersect triangles
Diffuse reflection doesn't work well in an open environment, so add the 1x1x1 box described above into your code, and color one wall red, the other blue. Move the light to (0.5,1,0.5) (just below the box top). You will have to describe the box with triangles, and perform ray-triangle intersection. You may use intersection code you find, and even share your custom intersection code with fellow students. The box should have six sides for reflections, but do not render the side at z=0, so that you may see its interior. Whitted ray tracing is enough to earn this assignment credit.

Part 2: Add one bounce diffuse reflection
Now you will begin sampling the BRDFs at each bounce using path tracing. Sample each pixel 100 times and average the results. Shoot a ray toward one (the only) point light and then sample the surrounding hemisphere once, using a uniform distribution and rejection sampling. At the next intersection, sample the light only, not the hemisphere. Remember to check for shadows when sampling the light. Use the diffuse term (only) of the Blinn-Phong model as your BRDF.

Part 3: Add Russian Roulette
Rather than bouncing once, use Russian Roulette to continue bouncing half the time at each bounce. Weigh the obtained light appropriately.


EXTRA CREDIT GRADING:
Extra credit opportunities include the following:
  • 1% Add multiple lights, and weigh their light appropriately
  • 1% Add area lights, and weight their light appropriately
  • 1% Add the specular term into your BRDF (make sure reflection is always < 1)
  • 5% Add transparency with refraction