Fix MIS (Multiple Importance Sampling) Implementation for Environment Map Sampling#4
Draft
Fix MIS (Multiple Importance Sampling) Implementation for Environment Map Sampling#4
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…obian correction, enable importance sampling Co-authored-by: umar-ahmed <8302959+umar-ahmed@users.noreply.github.com>
Co-authored-by: umar-ahmed <8302959+umar-ahmed@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix MIS implementation for environment map sampling
Fix MIS (Multiple Importance Sampling) Implementation for Environment Map Sampling
Aug 7, 2025
Owner
|
@copilot There's an error in the browser console: |
…ectly Co-authored-by: umar-ahmed <8302959+umar-ahmed@users.noreply.github.com>
Author
... Fixed the WGSL compilation error. The issue was trying to reassign an immutable The build now passes successfully. Commit: 2abe773 |
umar-ahmed
reviewed
Aug 7, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses critical issues in the pathtracer's Multiple Importance Sampling (MIS) implementation that were causing suboptimal convergence and noise, especially for environment maps with small bright light sources.
Issues Fixed
1. Binary Search Precision
The environment map importance sampling was using only 8 iterations in binary search, providing insufficient precision (~8 bits or 1/256). This caused visible noise and sampling artifacts.
Fixed: Increased iterations from 8 to 18, improving precision to ~18 bits (1/262,144).
2. Missing Jacobian Correction
The PDF calculation didn't account for the spherical-to-UV coordinate transformation, missing the critical
sin(θ)term that corrects for area distortion in spherical mappings.Fixed: Added proper Jacobian correction to
getEnvironmentMapPDF():3. MIS Not Actually Implemented
The pathtracer had importance sampling and PDF correction code that was commented out, meaning it was only using BSDF sampling without proper MIS weighting.
Fixed: Enabled importance sampling with MIS:
Technical Implementation
The solution implements a hybrid approach that:
Expected Improvements
Performance Impact
The changes are surgical and minimal (72 insertions, 47 deletions) focused entirely in the raytracing shader, maintaining full compatibility with the existing WebGPU pathtracer architecture.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.