Incorrectly weighted samples in PMREMGenerator

Description of the problem

I noticed some glb files using PBR materials looked much more metallic in three.js under a particular environment map compared to other viewers (Substance Painter and Unity). After some investigation I believe this is due to PMREMGenerator not weighting lighting samples correctly — each sample is weighted the same which causes HDR environment maps with large variations in intensity to become unsightly when convolved.

Here’s a tonemapped image that shows the problem (notice what happens to the sun in the bottom right of the bottom left face): https://raw.githubusercontent.com/akhosravian/threejs_pmrem_bug/master/pmrem.JPG

Here’s a screenshot of a line of sphere of increasing roughness using the map from that image:
https://raw.githubusercontent.com/akhosravian/threejs_pmrem_bug/master/issue.jpg

Live examples (the assets here are rather large so it takes a bit to load):
https://jsfiddle.net/r07gpq2a/
https://jsfiddle.net/tkqcfraz/

Standalone project: https://github.com/akhosravian/threejs_pmrem_bug

Is there a way to work around this?

Three.js version
  • Dev
  • r94
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, …)

Author: Fantashit

1 thought on “Incorrectly weighted samples in PMREMGenerator

  1. Thanks for the replies y’all. @richardmonette I did try removing those values, but it didn’t make it obviously better. Bumping the number of samples up (as in https://jsfiddle.net/fc47m8pg/) helps with the visual artifacts, but I think causes over brightening.

    I may take a look at applying a better fix using the links in the thread and will send along a PR if I do.

Comments are closed.