Ray Tracer : in the weeds

I’ve spent the past week fighting minor math errors in my ray tracer.

In order to confirm that my surface normals were being calculated correctly, I added boxes (axis aligned only at this point) as an additional primitive type. That required a couple days of debugging the normals calculation for the boxes too.

Then I added checkerboards, to confirm that I was getting proper reflections, and found that all my reflections seem to be upside-down.

I was also being driven nuts by the original datafile format, which was leading to a lot of “did I set that or not” type errors, so I switched to a hand-tooled JSON format. With only minor tweaks, the JSON file format is working! It’s about little successes right now.

I think there’s a basic error somewhere early in the process — I suspect that I’m having trouble distinguishing when something should be a “point” (a non-normalized 3D position in space), and when it should be a “vector” (a probably-should-be-normalized direction); and most particularly, when things should be pointing “at” the intersection point, and when they should be pointing “away” from the intersection point. I feel like I need to go through the whole thing with a fine-toothed comb, and rename variables to help me understand what’s going on. It would be nice if I could figure out a way to draw all the vectors visually, as well — I think that would really help the debugging process.

Anyway, I’m limping toward a solution, but it’s all going very slowly right now.

I’d love to be able to move on to transformations, texturing, and triangle intersection, but for now I’m stuck on kind of the basics: Am I even shooting a vector in the right direction? and How do I characterize what it is that I hit? and What do I do then?

More vectoring.

This entry was posted in Computers, Knowledge, Making, Science and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *