Tuesday, November 15, 2011

Boxed In...


November 5, 2011


  • Made BVH and Boxes independent.
  • Verbose Variable names
  • Recursion Recursion Re…
  • Modular approach



November 7, 2011


Errors / Issues / Progress:

  • Traverse - Used wrong root node (BvhRecord did not need one in it)
  •  Leaf nodes not sure what to do with themselves (wasn't boxing them)
  • visualized by level
  • Weird container boxes (not containing by level)
  • Added keyboard detection (press "l" for new level)


Levels 1 - 8 (Progressively)


November 8, 2011



 There IS A DIFFERENCE between " ++a " and " a + 1 "... I was incrementing the levels in my recursive MakeBVH function twice as often as I wanted because I was using ++a. 

Discovery and Progress:
  • Repost re-runs display function. (This is why it is re-making the tree every time I hit "l")
  • Brought sphere and plane intersect into header "Definitions.h" file. 
    • intersect must know members of sphere and plane, but sphere and plane contain definition file. 
    • Tried forward declarations, but need members not just pointer to class
    • Finally just passed in necessary info in basic datatype form (vec, int, float, etc.)


Statistics : 


Main Loop Duration Method Number Spheres Number Intersections
5 seconds Trace All 80 20.9 M
3 seconds BVH 80 2.9 M
23 seconds Trace All 356 29.8 M
6 seconds BVH 356 7.6 M
Unknown Trace All 1024 Est: 536.8 M
8 seconds BVH 1024 9.9 M




The time benefit of BVH increased with the number of spheres in the scene. Trace All crashed with 1024 spheres, but I estimated intersections were :


Num_Rays (imgH x imgW = 512 x 512 ) X Num_Spheres X 2 (1024 x 2 --> doubled b/c front and back hitPts) = approx 536.8 M






Some Resources used Along the Way: 


http://stackoverflow.com/questions/529071/xcode-automatically-deactivating-breakpoints


http://msdn.microsoft.com/en-us/library/windows/desktop/ms740560(v=vs.85).aspx
http://www.cplusplus.com/forum/beginner/4471/
http://pubs.opengroup.org/onlinepubs/7908799/xsh/systime.h.html
http://web.me.com/haroldsoh/tutorials/technical-skills/microsecond-timing-in-cc-wi.html


    Saturday, November 12, 2011

    Restructuring

    November 10, 2011
    • Implemented Singleton on Enviro class
    • Used Strategy for Shader, Tracer classes
    • Allowed Shader to use BVH tracer ....  Expected speed up. Instead, reflections broke.
      • Still going through traverse function (run time is the same)
      • No visible sign of reflections

    Thursday, November 10, 2011

    Random Spheres

    November 8, 2011

    Not so great for testing BVH... They're all squished in the same vicinity! 


    November 10, 2011


    Clipping...
    Fixed clipping! (Was using slight epsilon to decrease box size for easier debugging.)


    Tuesday, October 25, 2011

    Viewing Tree Depth

    This version of my program partitions a unit cube and places them in a BVH tree. It renders the resulting bounding boxes (cubes) whose nodes have the desired tree depth.




    I used this for timing. When generating and rendering a tree with a total depth of 6, it took ~14 - 20 seconds (for rendering boxes of depth one vs. depth six). A total depth of three took about 2-3 seconds, regardless of how many boxes I rendered. It seems strange that it should take so long.

    I believe the ability to view by layer will help me debug my code as I develop an algorithm to group geometric shapes.

    Silly Errors Along the way:

    • Swapping min and max corners when declaring boxes
    • Not overloading operators (like = )
    • Not returning anything for a non-void function.

    Wednesday, October 12, 2011

    Operator Overload

    October 12, 2011

    I was receiving the EX_BAD_ACCESS error because I had not defined the = operator for BoundingBoxes.

    I discussed the possibility of using pointers to bounding boxes instead of the actual thing, but the easiest solution at present seems to be overloading the = operator.

    This site proved helpful in explaining the process.

    Edit/Update


    Rather than overloading the operator, I set the elements individually equal to each other (setting minCorner and maxCorner manually.) This was an easy option because so few elements make up a bounding box. For larger complex objects, = or pointers would be more ideal.

    Tuesday, October 11, 2011

    Preparing for BVH

    Step One : Hit a Box Square


    Silly Error # 0: Not checking all necessary boundaries:

    I forget what caused the speckled/noisy consistency. I think I was making normal t values negative, which later caused me to disregard them...

    Success:

    The slight distortion is correct because the eye is at (0,5,2). +Z is up.

    Step Two: Hit a Box



    Silly Error # 1: Checking wrong Axes-




    Silly Error # 2: Adding negative signs to t value for the...fun of it.


    Finally successful:

    I chose to shade according to axis. Faces with a normal parallel to X got red, Y got green, and Z got blue.
    I was worried that I was missing the sides, so I changed the eye position to (3,5,2). This verified I was getting all sides.

    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?