Skip to content
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

HDR and HDRJPG environment maps produce different lighting #28071

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

mrdoob
Copy link
Owner

@mrdoob mrdoob commented Apr 4, 2024

@WestLangley
Copy link
Collaborator

Good. The rotation obfuscates rendering quality, artifacts, and errors.

I'd make the change permanent. And you will no longer need a render loop.

@Mugen87
Copy link
Collaborator

Mugen87 commented Apr 5, 2024

The rotation obfuscates rendering quality, artifacts, and errors.

True but a rotation or in general animations make the examples visual more appealing and engaging. Maybe a checkbox that allows to disable the rotation could be a compromise?

@mrdoob
Copy link
Owner Author

mrdoob commented Apr 5, 2024

I'd make the change permanent. And you will no longer need a render loop.

Removing the renderloop is annoying...
Because then we need to track all the places where a render() call is needed.

Makes the example more fragile...

@mrdoob
Copy link
Owner Author

mrdoob commented Apr 5, 2024

@elalish You were right!

The reason the HDR JPG and HDR renders look different when roughness: 1 seems to be caused by the texture size.
If I convert the HDR 1k to HDR JPG the render is identical (yet Chrome still shows the image weirdly)

So I don't think the converter is the problem. My next suspect is PMREM...

spruit_sunrise_1k.hdr:

Screenshot 2024-04-05 at 7 19 20 PM

spruit_sunrise_4k.hdr.jpg:

Screenshot 2024-04-05 at 7 19 26 PM

You can open both images in different tabs to compare.

@mrdoob mrdoob changed the title Update webgl_loader_texture_hdrjpg.html HDR and HDRJPG environment maps produce different lighting Apr 5, 2024
@elalish
Copy link
Contributor

elalish commented Apr 12, 2024

Ooh, interesting! I have a thought - my PMREM uses lat-long blurs where the axis changes each time to hide artifacts. When the texture is larger, it'll go through more axis shifts, but critically, they might be in a different order per roughness level. That might be a simple fix. I need to take a look.

@elalish
Copy link
Contributor

elalish commented Apr 19, 2024

Hmm, okay that helps a little, but it doesn't fix the overall brightness difference. With the above change, we know that the mip level blurs of the PMREM are identical for every layer once we get to where the smaller environment starts. Therefore the differences can only be in the first two PMREM blurs (going from 4k to 1k) or in whatever external tool converted the original 4k into a 1k equirect.

Assuming the external reduction is done by simple mipmap-style pixel averaging, that has the possibility to introduce error itself since the equirect pixels don't actually represent a constant area. Imagine an HDR image with a single bright pixel and all others black. If 16 pixels are averaged together for form one in a smaller image, that result pixel will have the same value regardless of which of the 16 was bright. However, if the bright pixel was closer to a pole, it represents less light due to being physically smaller.

Of course my weird PMREM lat/long blur might well be doing something similar or even worse. Still, it's interesting that basic image reduction may introduce error as well. Thoughts @WestLangley?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants