engine
engine copied to clipboard
Implement HDR rendering + postprocessing pipeline
PlayCanvas by default renders everything in LDR to 8888 targets. Lighting in the shader takes place in linear HDR space, and at the end of the standard shader we apply tone-mapping to bring it to LDR range, and then apply gamma. Post-processing then takes place on top of that, usually directly in the gamma space.
I tried to enable HDR rendering and a bloom filter. The scene rendering takes place in linear HDR as before, and this is directly stored in 16F target in linear space. Great so far. Then the bloom runs, again in linear space, but internally it uses 8888 targets for blurs, so the HDR is lost. And also, we’re missing a way to apply tone mapping at the end / or somewhere in the post-processing, and also at the end a linear space image is generated, which is very contrasty - we need to bring it to gamma space.
Additionally the bloom does not look very good .. possibly related to the fact it uses LDR targets, but could be something else as well.
exploration PR: https://github.com/playcanvas/engine/pull/4322
I wonder how well rgbm 8888 targets would work... Rgbm should be blurrable etc without having to decode/encode, but not sure what artifacts might result.
Yep, many implementations use RGBM and it's a viable / faster option, with some range limitations.
https://learnopengl.com/Guest-Articles/2022/Phys.-Based-Bloom
related https://github.com/playcanvas/engine/issues/5287
related https://github.com/playcanvas/engine/issues/4284
Ideally we'd implement in using this system when ready: https://github.com/playcanvas/engine/issues/5687
related: https://github.com/playcanvas/engine/pull/5833