Monday, October 10, 2011

Debugging Recursion, Reflections, and Shadows

Attempt #[BIG_NUM_HERE] at Reflections and Shadows: 
Using four bounces:
Using Two Bounces: 






Things that don't seem right to me:

  • They look exactly the same, regardless of bounce number. (Time to dig up Image Magick's compare functions...)
  • Vibrantly red speck on green sphere
  • Speckles on plane
I wanted to see what it looks like without Shadows, so I disable them and get a "EXC_BAD_ACCESS" error unless I am at two bounces or less... In which case I get: 


Smeared color. I'm not sure what to make of this yet... and how do you visually debug in the midst of recursion?

1 comment:

  1. Speckles are because I was not using a slight offset between bounces. The ray is intersecting the same point.

    Fix: After finding hitpoint, place new startPos at OLD_hitpoint + REFLECT_direction * small_EPSILON

    Notice it's REFLECT_direction used above, not OLD_direction (which would, yet again, have the ray intersecting the same object).

    ReplyDelete