-
Notifications
You must be signed in to change notification settings - Fork 2
Fix MIS (Multiple Importance Sampling) Implementation for Environment Map Sampling #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…obian correction, enable importance sampling Co-authored-by: umar-ahmed <[email protected]>
Co-authored-by: umar-ahmed <[email protected]>
@copilot There's an error in the browser console:
|
…ectly Co-authored-by: umar-ahmed <[email protected]>
... Fixed the WGSL compilation error. The issue was trying to reassign an immutable The build now passes successfully. Commit: 2abe773 |
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.