Commits on Feb 2, 2016
  1. Data files for easy project #4 (Beer's law)

    anrieff committed Feb 2, 2016
    When rendering the scene, the parser complains about
    missing properties (insideColor, absorption, etc.).
    This is because these are te properties you have to implement.
  2. Implement adaptive anti-aliasing.

    anrieff committed Feb 2, 2016
    The anti-aliasing in plain render mode (no DOF, no GI) is no longer
    fixed 5 samples (or 1 sample, if wantAA = false). Instead, the
    smart autodetection scheme from Lecture 4 is used. A quick 1 sample
    per pixel render pass is done (multi-threaded), then a difference
    finder is run (single-threaded), and finally a multi-threaded pass
    is done on the remainder of pixels that need to be anti-aliased.
    Progress is delightfully shown on-screen.
    data/boxed.qdmg: re-enable AA there.
  3. Fix crashes in interactive mode (missing render locks).

    anrieff committed Feb 2, 2016
    The render lock we were using in SDL function was not really created.
    Instead of crashing on trying to acquire a NULL lock, SDL apparently
    goes on... but that causes other crashes as multiple threads try to
    update the screen at once.
    Also add a marking function, which paints the screen in yellow by mask.
    Used to show which pixels need anti-aliasing.
Commits on Jan 14, 2016
  1. Small changes to interactive mode

    anrieff committed Jan 14, 2016
    - Add 'fullscreen' flag to GlobalSettings. This way, going fullscreen
      in interactive mode is optional, and actually defaults to false.
    - The movement/rotation parameters in the interactive mainloop aren't
      fixed, so your "movement speed" no longer depends on how long it
      takes for a frame to render. Instead, the last frame render time is
      used to scale the constants, so now movement/lookaround behaves
      more predictably.
Commits on Jan 13, 2016
  1. A slight optimization (~1%): compute H^D only once in intersectTriangle.

    anrieff committed Jan 13, 2016
    The det() function is heavy; by precomputing H^D, further determinant
    computations can be faster (they are reduced to just one dot product).
  2. Raw code from Lecture 13.

    anrieff committed Jan 13, 2016
    - Multi-threaded rendering, via CXXPTL.
    - Interactive mode (can be used for look-around at the moment).
      Camera commanded by keys, keypad keys, and mouse.
    - Setup SDL to be tolerant to multi-threaded updates to the
      screen (SDL_ASYNCBLIT).
    - Trim down meshes.qdmg - remove AA, remove wineglass and the
      glossy balls.
  3. Eliminate some divisions in BBox intersection methods.

    anrieff committed Jan 13, 2016
    Since divisions by ray.dir.(x|y|z) happen a lot, it's beneficial to
    compute the reciprocal of ray.dir before the intersection calculation.
    This is made with a special, augmented Ray class (RRay).
    The same kind of optimization can be implemented in other parts of the
    raytracer, but doing it globally makes no sense: RRay::dir and rdir have
    to be kept in sync, which is too much work to do (esp. through
    model-view transformations).
    This optimization sheds about 1.5% of the render time.
  4. Optimize calculation of Fresnel coefficients.

    anrieff committed Jan 13, 2016
    - Don't compute dot products three times; we only need it once, but
      we need to manipulate the sign.
    - Use floats all over, double precision is not required for a fresnell
      coefficient computation.
    - Replace pow(x, 5.0f) with (x * x * x * x * x).
  5. Optimize Mesh::intersectTriangle() (~12% speedup)

    anrieff committed Jan 13, 2016
    - Precompute AB, AC and AB^AC in members of Triangle, to avoid
      calculating them each time in intersectTriangle.
    - Reorder exit checks a bit, to enable quicker culling of
      triangles we don't intersect.
    - Precompute 1/Dcr to avoid divisions.
Commits on Jan 12, 2016
Commits on Jan 10, 2016
  1. path tracing: add explicit light sampling and AA.

    anrieff committed Jan 10, 2016
    Some other changes:
    - BRDF::spawnRay now emits Rays, instead of Vectors.
    - Ray::debug property replaced by Ray::flags, a bitmask.
    - Use said bitmask to mark diffuse reflections in path tracing,
      so lights cannot contribute to paths after a spawnRay from
      a diffuse surface accidentially hits a light. If we don't
      forbid such contributions, we won't account for them and
      the scene will be brigther than it should.
  2. hemisphereSample: fix wrong spherical coordinates parametrization.

    anrieff committed Jan 8, 2016
    The point picking algorithm from mathworld assumed a specific
    meaning of the phi coordinate, while our code to transform from
    spherical coordinates to xyz another meaning. The result was a heavy
    bias towards generating rays in the ±Y direction.
  3. Lecture 12, hours 1&2: super basic path tracer, a-là smallpt.

    anrieff committed Jan 6, 2016
    No explicit light sampling, we just extend paths, hoping to hit
    a light eventually. Quite noisy render even at 512 paths per pixel.
Commits on Jan 6, 2016
  1. Speed up K-d tree intersection.

    anrieff committed Jan 6, 2016
    Add BBox::intersectWall() method, which is used in intersectKD().
    The speedup is as much as 30% (see
    for thorough explanation).
  2. Two scenes, to be used in demonstrations of the path tracing GI algor…

    anrieff committed Jan 6, 2016
    smallpt.qdmg:     recreation of Kevin Beacon's 'smallpt' path-tracer example.
    cornell_box.qdmg: a Cornell Box scene, converted in our format by
                      Ivaylo Dankolov of the RTBG2011-2012 course.
  3. Light are now intersectable. raytrace() checks for intersections with…

    anrieff committed Jan 6, 2016
    … lights.
    If an intersection is found, that is closer to the nearest geometry - the
    light's color is returned for that point.
  4. Add wantPrepass option to GlobalSettings.

    anrieff committed Jan 6, 2016
    When enabled, a low-res prepass is done before the main rendering.
    The prepass resolution is 256 times lower (a single ray is traced
    and painted for 16x16 square), which allows you to quickly judge
    how the final rendering could look like, and thus abort it early
    if the scene is VERY wrong :)
  5. Implement bilinear filtering in the environment sampling, too.

    anrieff committed Jan 6, 2016
    Fix light definitions in scenes.
  6. Replace calls to randomFloat() and genDiscPoint() with the Random class.

    anrieff committed Jan 6, 2016
    As commented earlier, the randomFloat() and genDiscPoint() functions were
    meant to be replaced by better alternatives, now implemented as methods
    of the Random class. The reasons for this are,
    1) Previous funcions depended on rand(), which is a C library function,
       that is not bound to use any specific algorithm by the C standard
       A lot of libraries (e.g., the Microsoft Visual C++'s MSVCRT) use
       a LCPRNG, which is known to have serial correlation between
       successive samples and is  unsuitable for Monte-carlo simulations.
       The Random class uses the Mersenne Twister, which is widely recongized
       for having excellent randomness properties.
    2) Calls to rand() implicitly modify a global variable. This could
       cause us problems later on, when we multi-thread our renderer.
       Multiple threads will be calling rand(), causing contention,
       race conditions and unnecessary cache coherence traffic.
       All calls to the Random class are now done after the code initially
       obtains a specific Random object instance by calling getRandomGen().
       This selects a Random object to be returned from an array of Random
       objects, whereby the caller's thread ID is used to select the
       specific Random object. The overhead from calling getRandomGen()
       (with its hashtable mapping of threadID to Random instance) is
       tested to be quite minimal.
  7. Changes in lectures 10 and 11.

    anrieff committed Jan 6, 2016
    - Lights (we can have multiple lights).
    - Light sampling (soft lights), used in RectLight.
    - Depth-of-field (camera effect).
    - Stereoscopy (camera effect), for use with anaglyph glasses.
Commits on Dec 30, 2015
Commits on Dec 16, 2015
  1. Test scenes for Lecture 10.

    anrieff committed Dec 16, 2015