x-ray example

Before you start

This assignment (again) builds on the previous one. If yours worked, I strongly recommend using your own code as a starting point for this assignment. If not, you will find my sample solution in the "a5sample" directory of your GitHub repository. If you need it, you are free to use that code either to figure out what was wrong with your assignment, or use it as a base for this one. Whichever you choose, be sure to do all of your work for this assignment in the "GLapp" directory of your repository (i.e. copy my code over to that directory if you are going to use it as a base).

This assignment will require assembling several of the tools from prior assignments, along with some you will find in sources online, and using them in a new way to achieve an x-ray view effect.

The Assignment

The goal of this assignment is to create an x-ray view effect for one object in the scene. Specifically, we'll add the moving sphere model from the original assignment 3 GLapp sample code to the castle. Change the sphere radius to 500 modify the Sphere.cpp code so it circles at a height of 1000 in a path with radius 1000. If the sphere is visible, it should be rendered normally, but if it is hidden behind a wall, you should see a yellow outline.

The basic idea is to render the sphere with the castle in the initial G-buffer rendering pass to handle when it is visible. Then, add a new x-ray pass, rendering just the sphere, storing the position (or just depth if you used depth instead of position in assn4 and assn5). In the final rendering pass, figure out the potential outline pixels by computing a Sobol edge detection on one or more channels of the x-ray pass buffer. Consider any pixel with a Sobol value above some threshold to be an x-ray edge pixel. To figure out whether to draw the edge color or the regular deferred shading color, compare the G-buffer pass position or depth x-ray pass pixel or depth. If they are close enough (within floating point error), they are likely the same object, and the x-ray object is visible normally at that pixel. If the difference is too large, they are likely different objects, and the x-ray outline should be shown.

The Sobol edge detection uses a weighted sum of your eight neighbor pixels. You can make the edge wider by using "neighbors" more than one pixel away. The sample image above uses this to make a wide outline, while the stylized example below uses an outline that is only one pixel wide.

stylized x-ray example

Extra Credit

For up to 15 points of extra credit, stylize the x-ray outline by offsetting the position for the Sobel edge check using Perlin noise. You can use a Perlin noise implementation from ShaderToy (be sure to note your source). The trickiest part of this will be making sure the stylized outline is not visible when it should not be.

634 only

Use clip-space depths rather than 3D position.

What to turn in

Turn in this assignment electronically by pushing your source code to your class git repository by 11:59 PM on the day of the deadline and tagging the commit assn6. Do your development in the GLapp directory so we can find it. See the assn0 project description if you accidentally tag the wrong commit and need to retag.

Also include an assn6.txt file at the top level of your repository telling us about your assignment. Tell us what works, and what does not. Also tell us what (if any) help you received from books, web sites, or people other than the instructor and TA. Finally, if you did anything toward the extra credit, be sure to tell us about it in this file. For the extra credit, be sure to tell us about the algorithm you used and where you found it.

You must make multiple commits along the way with useful checkin messages. We will be looking at your development process, so a complete and perfectly working assignment submitted in a single checkin one minute before the deadline will NOT get full credit. Individual checkins of complete files one at a time will not count as incremental commits. Do be sure to check in all of your source code, but no build files, log files, generated images, zip files, libraries, or other non-code content.