google / model-viewer

Easily display interactive 3D models on the web and in AR!
https://modelviewer.dev
Apache License 2.0
6.71k stars 800 forks source link

UltraHDR lighting support #4578

Closed elalish closed 7 months ago

elalish commented 7 months ago

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.