- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 36.1k
WebGPURenderer: Implement GGX VNDF importance sampling for PMREM #32134
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
Conversation
8002744    to
    38007c4      
    Compare
  
    | 📦 Bundle sizeFull ESM build, minified and gzipped. 
 🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies. 
 | 
38007c4    to
    4511210      
    Compare
  
    | @sunag What do you think? | 
912b121    to
    0e004ba      
    Compare
  
    Port the GGX VNDF (Visible Normal Distribution Function) importance sampling implementation from WebGLRenderer's PMREM to WebGPURenderer's TSL-based PMREM generator. This implementation provides more accurate environment map prefiltering by using Monte Carlo integration with VNDF importance sampling to represent the GGX BRDF for physically-based rendering. Changes to PMREMUtils.js: - Added GGX VNDF sampling helper functions: - radicalInverse_VdC: Van der Corput radical inverse - hammersley: Hammersley sequence for quasi-Monte Carlo sampling - importanceSampleGGX_VNDF: GGX VNDF importance sampling (Heitz 2018) - ggxConvolution: Main convolution function using VNDF sampling - Optimized shader code by removing unnecessary .toVar() calls Changes to PMREMGenerator.js: - Added GGX_SAMPLES constant (1024 samples, optimized for performance) - Removed _axisDirections (no longer needed with GGX filtering) - Added _ggxMaterial property - Replaced blur-based _applyPMREM with GGX filtering - Added _applyGGXFilter method for incremental roughness filtering - Added _getGGXShader function to create GGX material - Updated documentation to reflect GGX VNDF usage Technical notes: - Uses texture() instead of texture(null) for EmptyTexture default - Helper functions don't use setLayout (TSL pattern for nested Fn) - Implements incremental roughness filtering to avoid over-blurring - Applies blur strength mapping (0.05 + roughness * 0.95) for quality - Performs two-pass rendering: pingPong target then back to cubeUV - Reduced sample count to 1024 (vs WebGL's 2048) for better performance
0e004ba    to
    8541cd1      
    Compare
  
    | Oh, it may be unstable now. Trying to make it perform faster so the e2e doesn't timeout. | 
| 
 The implementation seems perfect. 👏 | 
| 
 It seems that the material is being compiled multiple times even with the ggx material cache 🤔 | 
| Feel free to continue the PR. It's sleep time for me 🤓 | 
Performance optimization: removed .toVar() from the s variable in importanceSampleGGX_VNDF as it is never reassigned and only used for reading on the next line. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
…0.0.1:27907/git/mrdoob/three.js into claude/session-011CUZfd82vQUmMrBBmDS1CQ
| I'm still investigating, but the performance issue isn't related to the code but to the caching system associated with  | 
| Seems like 2048 is too much for  I'll set it back to 1024 and next month I'll try to profile the renderer and see if I can find any performance improvements. | 
Related issue: #32114
Description
Port the GGX VNDF (Visible Normal Distribution Function) importance sampling implementation from WebGLRenderer's PMREM to WebGPURenderer's TSL-based PMREM generator.
This implementation provides more accurate environment map prefiltering by using Monte Carlo integration with VNDF importance sampling to represent the GGX BRDF for physically-based rendering.
Changes to PMREMUtils.js:
Changes to PMREMGenerator.js:
Technical notes: