Program 6 - Monte Carlo Ray Tracing

This assignment is due on Sunday 6/10.


Goals for assignment 6:

For this portion of your ray tracer, your program needs to:

You will also need to create your own visually interesting scene that you render and submit the .pov file.

Program execution:

Your program should have the following syntax:

raytrace render <input_filename> <width> <height> [-fresnel] [-ss=N] [-sds] [-gi]

assuming that your executable is named raytrace where the options are:

I also recommend that you support the following commands to control gi parameters:

Here are some string utility functions that can be used to handle the -gi_samples argument above:

bool StringBeginsWith(const std::string & s, const std::string & prefix, std::string & remainder)
  if (s.size() < prefix.size())
    return false;

  if (s.substr(0, prefix.size()) == prefix)
    remainder = s.substr(prefix.size());
    return true;

  return false;
std::vector<string> StringExplode(const std::string & str, const char delimiter)
  std::vector<string> words;
  std::istringstream stream(str);

  std::string word;
  while (std::getline(stream, word, delimiter))

  return words;
std::vector<int> sampleCounts;

std::string remainder;
if (StringBeginsWith(argument, "-gi_samples=", remainder))
  std::vector<string> words = StringExplode(remainder, ',');
  for (const std::string & s : words)


In addition to the normal execution syntax, your program should support the following diagnostic/testing syntaxes with the given commandline arguments. You must also continue to support all Diagnostic/Testing syntaxes from the previous iteration(s) of the project.

No new commands (yet!)

If I can come up with a new diagnostic command that will be helpful in solving spatial data structure problems, I will post it here.

Grading breakdown: