Skip to content

Conversation

@marwie
Copy link
Contributor

@marwie marwie commented Aug 26, 2025

Description

This PR adds an example for using FastHDR environment maps, which are smaller, load faster, and use almost no GPU memory in comparison to both EXR and UltraHDR.

Technically, FastHDR textures are "Precomputed PMREM in KTX2 UASTC HDR 4x4 format". (We chose that name to have something similar to "UltraHDR" which is also a "nice name" for a complex technical description.)

We have already processed a number of environments into this format, and they are CC0 and can be found here: https://cloud.needle.tools/hdris. We're working on some tools to make it easier to use the toolchain needed to precompute EXR textures as PMREM and then compress them with basis.

Live:
https://three.needle.tools/examples/?q=fast#webgl_materials_envmaps_fasthdr

Screencapture:

fastenv.mp4

This contribution is funded by Needle

@arpu
Copy link

arpu commented Aug 26, 2025

what is the basisu command to generate this ktx2 files for envmap?

@hybridherbst
Copy link
Contributor

hybridherbst commented Aug 27, 2025

There's no single command to generate them right now. We're working on providing tools to make this easier, but it's so much better than the status quo that we wanted to share some preprocessed files already.

Right now there's multiple steps involved as it combines two ideas to make it both fast and memory efficient:

  1. Precalculating what PMREMGenerator does (myEquirectFile.exr → myPmremFile.exr)
  2. Compressing to KTX2 with ./basisu -hdr_4x4 myPmremFile.exr.

PMREM HDR 4x4 works "right now" for a number of three.js versions, as seen in this PR. HDR 6x6 will be even smaller and we got it to work with an updated BasisU transcoder, see #31718, so that's a potential future improvement.

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 27, 2025

Would be okay if we wait with a merge until users are able to generate such KTX2 texture with your mentioned tools?

Otherwise I fear additional support effort since we have to explain users the incomplete workflow.

@hybridherbst
Copy link
Contributor

hybridherbst commented Aug 27, 2025

Users are able to generate them today (see my post above), but I agree that it should be easier.

I think it's already quite useful with the set of processed files we made (happy to add more by the way if you want specific ones!) since it makes all three.js apps faster, and the building blocks (pmrem, compression, etc.) are already in place.

Out of curiosity, what would be the minimum for you to consider as "complete workflow"? Is a description of command-line tools ok? Using Draco or KTX2 nowadays also often requires command-line knowledge.

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 27, 2025

I think for a good adaption on the user side there should be a command line tool that let you do the conversion in one go. Something like:

> fast-hdr input.exr output.ktx2

The general interface could be like in gltf-tranform if it makes sense to have more than one command:

> fast-hdr <command> [ARGUMENTS...] [OPTIONS...]

@donmccurdy
Copy link
Collaborator

Certainly a CLI is more practical, but we do have the example at https://threejs.org/examples/?q=exr#misc_exporter_exr for exporting PMREM data as OpenEXR files, too.

@hybridherbst
Copy link
Contributor

hybridherbst commented Aug 29, 2025

Hey there, the technical article is live:
https://cloud.needle.tools/articles/fasthdr-environment-maps

I would love input from all of you!
I included the current semi-manual steps for making FastHDR files as well.

Would be cool to get this merged for r180!

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 29, 2025

The section "Creating files in the FastHDR format" is sufficient for me from a support perspective. If developers have questions, we can guide them towards this article.

@marwie
Copy link
Contributor Author

marwie commented Aug 29, 2025

That's great! We'll also make sure to add links to the article from the FastHDR landing page (linked in the example header)

@marwie
Copy link
Contributor Author

marwie commented Sep 1, 2025

Added controls to the example for exposure, fov and blurriness + some more hdri images to switch

https://three.needle.tools/examples/?q=fast#webgl_materials_envmaps_fasthdr

20250901-110111_three.js_examples_-_Google_Chrome.mp4

@mrdoob mrdoob added this to the r180 milestone Sep 1, 2025
@mrdoob
Copy link
Owner

mrdoob commented Sep 1, 2025

Hmm, have you guys considered calling it PMREM HDR?

I know it's not as catchy as FastHDR but I feel like calling it FastHDR may confuse people trying to use these files on other engines without much success... Other engines would need to implement our custom PMREM format, no?

I also proposed renaming UltraHDR to JPGHDR at the time but didn't get much traction 😅

@hybridherbst
Copy link
Contributor

hybridherbst commented Sep 1, 2025

We're open for suggestions – that being said, the idea with" FastHDR" was to make it clear that this is, indeed, faster, hopefully helping with adoption (don't think there's any real downside to it).

I think PMREM HDR is too complicated – it's yet another acronym and people need to know a lot to understand what it means (and it's an 8-letter acronym 🤔)

may confuse people trying to use these files on other engines without much success

Yes, there would need to be some support for either the CubeUV format, or for shuffling the blocks around so that the loaded texture is an equirect map with mips, for example. But it's kind of the same with UltraHDR, it also has RGB and mono modes, and various ways to use the metadata, and I don't think many systems actually support multiple ways?

Can see why UltraHDR has beat JPGHDR lol

@mrdoob mrdoob merged commit b83d9ab into mrdoob:dev Sep 3, 2025
8 checks passed
@hybridherbst
Copy link
Contributor

Thanks for merging!

Question @mrdoob : the example page is now marked as "external" but I think that is usually used for external code references – FastHDR doesn't have any external references, it's just regular KTX2Loader used slightly differently. So I think "external" can be removed?

image

@Mugen87
Copy link
Collaborator

Mugen87 commented Sep 3, 2025

I've removed the tag in dev and gh-pages: 197f8d9, a9e9ed4

@Mugen87
Copy link
Collaborator

Mugen87 commented Sep 3, 2025

FYI: The download times of https://cdn.needle.tools/static/hdris/ballroom_2k.pmrem.ktx2 take quite long (almost 1.5 min).

image

Maybe a temporary issue?

@donmccurdy
Copy link
Collaborator

donmccurdy commented Sep 3, 2025

Strictly I think environment maps are not “high dynamic range images” — UltraHDR's compression methods are optimized for display- and perception-based metrics that don't necessarily apply to raw / scene-referred / floating-point RGB data. If UltraHDR gives results you're happy with, great! Just be aware of that possible mismatch if quality isn't as expected in some cases.

“HDR” is a fine term for describing modern display hardware, and (IMO) much messier and muddier when applied to anything else, but oh well. 😅 Arguably "PMREM HDR" is a bit of a contradiction for that reason. "FastEnvironment" or "FastIBL" would avoid these conceptual challenges. Just my drive-by thoughts though, naming is hard, and I like the PR!

@marwie
Copy link
Contributor Author

marwie commented Sep 3, 2025

FYI: The download times of https://cdn.needle.tools/static/hdris/ballroom_2k.pmrem.ktx2 take quite long (almost 1.5 min).

Wow that's extreme! Are you using Telekom by any chance? I think there have been issues with Cloudflare and Telekom in the past but haven't heard about it anymore for a while.

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.

6 participants