Exporting EXRs
At some point after building the three.js based 3D PBR preview for Smudge it became clear that a lot of textures looked better in the preview than in Unity. Internally, Smudge uses 2x and 4x resolution, 16-bits-per-channel buffers. The 3D PBR preview creates its textures from these high-quality buffers and looks great. The old export code packed the data onto the canvas and then exported it as a .png
. These exports were too low-resolution and low-depth for good PBR rendering, especially the height map.
The solution to this problem is to create higher quality exports. Smudge can now export high-resolution, 16-bit-per-channel files in the OpenEXR format. The export API needs a little work to give the user more control over export options. The .exr
is pretty basic, I based it heavily on the c++ miniexr library. I ported that to JavaScript, and added support for an alpha channel. I also added in gamma correction to suit linear or gamma workflows. The exported files are uncompressed and pretty big. This is mostly fine, you could compress the exported files with another tool if needed.
Down the road, I might also look into exporting HDR .png
files, possibly using pngjs. Compressed export would be nice. I’m not sure if this will work because I’m not sure how 16 bit .png
files, HDR, and Unity work together.