-
Notifications
You must be signed in to change notification settings - Fork 823
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
UltraHDR lighting support #4578
Conversation
(resolve, reject) => this.imageLoader.load(url, (result) => { | ||
const {texture} = result.renderTarget; | ||
result.dispose(false); | ||
resolve(texture) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fixes @daniele-pelagatti! All seems to be working now. One thing I was curious about: if I change this to result.dispose(true)
, my textures go black. However as it is, I believe I lose my handle to the renderTarget
and can therefore never dispose of it. Not sure that's a huge deal, but I'd like to know what your recommended pattern is here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result.dispose(true)
calls renderTarget.dispose()
too and can be used when , for example, you do
const result = await loader.loadAsync('something.jpeg')
// once pmremgenerator has generated its own texture, result.renderTargetis not used anymore
pmremgenerator.fromEquirectangular(result.renderTarget.texture)
// or
texture.map = result.toDataTexture()
// or
myfile.serialize(result.toDataTexture())
result.dispose(true) // <-----
in other words, if you are going to use result.renderTarget.texture in any significant way in the future, don't call result.dispose(true)
, just call it with false or no params
* UltraHDR working * update an HDR environment * add dispose * fixed texture name bug
This is an exciting one! Custom lighting environments with 10-30x less file size, using UltraHDR (a backward-compatible, HDR version of JPEG) rather than .hdr. This is pulling in a dependency on https://github.com/MONOGRID/gainmap-js (thanks @daniele-pelagatti!), which is a very fast and lightweight decoder that leverages the browser's in-built JPEG decoding that ends up faster than the JS .hdr decoder we use now.
Monogrid has also helpfully made available a simple webpage that will do local conversion of .hdr to UltraHDR .jpg files. This brought Spruit Sunrise down from 1.5MB to 122KB - and the compression is even more impressive with grayscale studio lighting. We're only going to support the single-file .jpg approach for now - separate WebP files gives a bit of additional compression, but it seems too inconvenient to our users.
We put an upstream fix into three.js to make this work better, so I'll wait to merge this until we've updated to the next release.