Minilight

13 thoughts
last posted July 11, 2014, 10:59 p.m.
0
get stream as: markdown or atom
0

Back in 2009, I took apart an existing Python port of Harrison Ainsworth's amazing minimalistic global illumination renderer, Minilight, and put it back together as my own take on a Python version.

0

For a while I wanted to try to do a port to Go (and I hope to get back to that shortly) but a few days ago I decided to try to do a port to Apple's new language, Swift.

0

There are a lot of design decisions I still want to review as I learn more about Swift but the first step is just getting it working.

0

Two things I immediately discovered:

  • Swift is nowhere near as nice as Python for processing text files and so I actually still haven't written the scene file parsing code yet
  • It's a really pain to work out how to use Cocoa for things like generating an image file. I finally ended up on TIFF output as I could work out how to do that.
0

The first weirdness I noticed, however, when doing an initial (low iteration count) render of a Cornell box. The green wall was completely off.

The Swift output is on the left, the output of my Python version on the right.

0

After a lot of work (it's not easy to debug monte carlo simulations with millions of rays traced) I discovered the problem was I needed to treat a distance of 0 different from a distance of nil in one bit of code.

There's a more detailed description on this card on my Swift stream.

0

There was still an issue though. Notice some faces have one triangle slightly darker than the other?

Below is output from my Swift port but you can also see it in the Python image above.

0

At the right angles, the bug can be quite striking:

0

My first thought (suggest by others on Twitter a well) was that the normals were flipped. I confirmed that in some cases they were. But correcting that didn't fix things. It just in some cases made the difference more subtle:

0

Oddly, the problem on the right wall was fixed when I noticed that some of the coordinates in the scene file didn't quite line up, leading to a slight "fold" in the face.

Correcting that in the scene file fixed the red wall but didn't explain:

  • other faces where the coordinates did line up and the normals were identical
  • why the renders on the official Minilight site don't show this "fold" given the coordinates in the original scene files also don't quite line up
0

There's still something weird going in here, for example, where the coordinates are fully lined up and the normals identical:

0

I did a large 800-iteration render of the daytime Cornell box and here the problem is at its most obvious ever: