mrdoob/three.js — pull request #5687 by MiiBond (2014-11-26 15:51:08+00:00)
Title: Adding shader code to read/write various HDR texture packing formats

I've added shader chunks for reading from and writing to several 32-bit HDR texture formats including RGBE, RGBM, RGBD and LogLuv. A description of each can be found here: http://lousodrome.net/blog/light/tag/rgbm/

The main benefit of these is that they make it possible for devices that don't support floating point textures to still run with HDR.

The envMap and lightMap material values now support HDR textures and, when you assign an HDR texture to these properties, the material automatically recompiles. `THREE.Texture` now has an `hdrPacking` property that will be assigned one of `THREE.HDRRGBM`, `THREE.HDRRGBD`, etc. Note that `texture.format` is still RGBA for each of these.

I also added support for outputting in one of these HDR formats. You can turn this on in the renderer by setting the following:
`WebGLRenderer.hdrOutputEnabled = true;
WebGLRenderer.hdrOutputType = THREE.HDRRGBE;`

This can be disabled or enabled on a per-material basis by setting 'material.hdrOutputEnabled` and `material.hdrOutputType`.

I've added an example called webgl_hdr_textures.html that lets you turn on the different HDR formats as render targets (instead of using floating point textures) while doing adaptive tone-mapping. The example also lets you choose from a couple of HDR environment maps. Unfortunately, I don't currently have a way of generating a LogLuv or RGBE-encoded PNG (though I'm working on this) so they're not included in this example. You can use RGBELoader to load an .hdr file as a DataTexture but, ultimately, I'd like a way of encoding this data into a PNG for efficient compression. Also, I know that the included RGBM and RGBD cubemaps are really low-res.