Final Report: MIS & ML-guided Adaptive Sampling

CS184/284A – Final-Project Report

AI Acknowledgement

⚠️ This final report was created with assistance from ChatGPT by OpenAI for organization, editing, and styling.

Project Video

https://drive.google.com/file/d/1tXc5aLS2BewgGELY8hF3GIsj-xs4jonW/view

Abstract

In this project we extended our HW3 path tracer with three key additions:
  1. We implemented advanced BSDFs for mirror, glass, and microfacet (conductor), enabling sharp specular and realistic metallic looks.
  2. We improved direct-light estimation with Multiple Importance Sampling (MIS): we added a BSDF-sampling branch and blended it with explicit light sampling via the two-sample power heuristic. We also included a delta-aware tweak for specular cases.
  3. Adaptive sampling with a ViT saliency prior. We precomputed a CLIP/ViT saliency heatmap and biased per-pixel budgets and convergence thresholds so that high-saliency regions (faces, silhouettes, highlights) got more samples and tighter confidence intervals, while low-saliency regions (flat walls, empty background) stopped earlier. This played nicely with MIS + advanced BSDFs: caustics and microfacet highlights retained quality, but larger uniform areas converged quickly. We reported speed/quality on two scenes: CBspheres_tex (glass + metal spheres in a Cornell box) and CBdragon_microfacet_au (gold dragon).

1. Technical Approach

2. Challenges

Challenge 1: Debugging the Glass BSDF — From Black Patches to Correct Transmission

Issue. The initial glass implementation produced black spots, inverted shadows, and reduced transparency.

Cause. In several lighting estimators, the geometric term was computed as max(0, z), which incorrectly zeroed valid refracted paths. For transmission, the correct form is $|\cos\theta|$, allowing directions across hemispheres.

Fix. Replaced all std::max(0.0, ...z) with fabs(...z) in:

Why it works. The rendering equation’s geometry term uses $|\cos\theta|$, not a clamped cosine. Clamping removes valid transmission contributions, causing energy loss and artifacts.

Additional stability measures. Exact dielectric Fresnel with TIR fallback, $(\eta_i / \eta_t)^2$ energy scaling, delta-lobe tolerance $10^{-3}$, EPS-offset shadow rays, and delta-aware MIS weighting.

Result. The black spot and ghosting disappeared, transparency was restored, and no new fireflies appeared.


Challenge 2: Handling Delta Distributions in MIS to Reduce Fireflies

One challenge was managing delta-distribution BSDFs (such as perfect specular reflection and refraction) during Multiple Importance Sampling (MIS). In the initial implementation, assigning equal weights to light sampling and BSDF sampling sometimes caused severe fireflies, especially on reflective glass surfaces. To address this, I adjusted the MIS weight calculation when isect.bsdf->is_delta() is true, biasing the combination towards BSDF sampling:

This change increases the BSDF sampling weight to 0.8 and reduces light sampling to 0.2. It significantly reduced noise and improved highlight stability on mirror and glass surfaces without introducing noticeable bias in the final rendering.


Challenge 3: Using an Imperfect Saliency Map Without Hurting Adaptive Sampling

Our ViT-based saliency is imperfect: it can miss specular effects (caustics, glossy lobes), over-mark flat backgrounds, or shift under different FOVs. The challenge was to extract useful guidance from this noisy prior while still letting adaptive sampling (variance-driven) do its job. A naïve approach (e.g., fully trusting the mask) either oversamples empty regions or starves hard transport like caustics.

What we tried & where we landed. During development, we experimented with extra checks for caustics and low-variance background suppression, but found they introduced too much processing overhead to justify the gains. In the end, we kept a streamlined version where the saliency mask biases the initial per-pixel sample allocation, and the adaptive sampler’s variance-based stopping criteria takes over naturally.

Policy sketch (pseudo):


            // Inputs: saliency s in [0,1], variance stats (mu, sigma), CI half-width I,
            //         global caps: min_spp, max_spp
            int budget_from_prior = lerp(min_spp, max_spp, s);
            
            // Anneal prior influence over time
            budget_from_prior = mix(budget_from_prior, ns_aa, anneal_factor);
            
            // CI gating: stop early if converged
            while (n < budget_from_prior) {
                take_batch();
                if (n >= 2 && I <= tol * mu) break; // variance wins
            }
            

Outcome. This simpler integration preserved most of the performance benefit without slowing down the render loop. In our tests, it consistently reduced wasted samples on low-detail areas while maintaining image quality for challenging regions like glass and metal.


// For delta-distribution materials, adjust MIS weights to improve reflection results
if (isect.bsdf->is_delta()) {
    // Increase BSDF sampling weight, reduce light sampling to mitigate fireflies
    double weight_bsdf = 0.8;
    double weight_light = 0.2;
    return L_out_lighting_sample * weight_light + L_out_bsdf_sample * weight_bsdf;
}

3. Results

dragon_step_1
Rendering of microfacet surface CBdragon with no Microfacet BSDF implemented.
spheres_step_1
Rendering of CBspheres with no advanced BSDFs implemented.
dragon_step_2
CBdragon_microfacet_au with Microfacet BSDF implemented without MIS adaptive sampling.
dragon_step_3
CBdragon_microfacet_au with Microfacet BSDF implemented and with MIS adaptive sampling.
glass_spheres_step_2
CBspheres with Glass BSDF implemented without MIS adaptive sampling.
glass_spheres_step_3
CBspheres with Glass BSDF implemented and with MIS adaptive sampling.
microfacet_spheres_step_2
CBspheres_microfacet_al_ag with Microfacet BSDF implemented without MIS adaptive sampling.
microfacet_spheres_step_3
CBspheres_microfacet_al_ag with Microfacet BSDF implemented and with MIS adaptive sampling.

Saliency-Biased Adaptive Sampling (SBAS) — 4096 spp Results

We compare baseline adaptive sampling (with MIS) against our ViT Saliency-Biased Adaptive Sampling (SBAS). For each scene we show: the rendered image, per-pixel sampling rate heatmap (_rate), and the saliency map & mask used to guide sampling.

CBdragon — Gold Microfacet Dragon in a Cornell Box (4096 spp)

Expect SBAS to concentrate samples on high-frequency geometry (spines, face) and bright specular regions, while de-emphasizing flat background.

CBdragon baseline 4096spp
Baseline (adaptive + MIS)
CBdragon baseline sampling rate
Baseline sampling rate visualization
CBdragon SBAS 4096spp
SBAS (ViT-guided) render
CBdragon SBAS sampling rate
SBAS sampling rate visualization
CBdragon saliency map
Saliency map (continuous)
CBdragon saliency mask
Saliency mask (thresholded)
Timing & quality (fill these after measuring)
  • Baseline time (4096 spp): 3693.3846 s
  • SBAS time (4096 spp): 2197.6018 + 40 s  (165.06% speed-up)
  • Notes: SBAS allocates more samples to the head/spines and bright specular ridges; background receives fewer.

CBspheres — Glass & Metal Spheres in Cornell Box (4096 spp)

SBAS emphasizes glass caustics and metal highlights while reducing effort on walls/ceiling. Useful for testing specular transport + MIS.

CBspheres baseline 4096spp
Baseline (adaptive + MIS)
CBspheres baseline sampling rate
Baseline sampling rate visualization
CBspheres SBAS 4096spp
SBAS (ViT-guided) render
CBspheres SBAS sampling rate
SBAS sampling rate visualization
CBspheres saliency map
Saliency map
CBspheres saliency mask
Saliency mask
Timing & quality (fill these after measuring)
  • Baseline time (4096 spp): 1122.1510 s
  • SBAS time (4096 spp): 443.9791 + 40 s  (231.86% speed-up)
  • Notes: SBAS increases samples under the spheres (caustics) and on specular highlights; reduces on planar walls.

4. References

Tools & Frameworks:

5. Team-member Contributions (alphabetical)