engine icon indicating copy to clipboard operation
engine copied to clipboard

Implement HDR rendering + postprocessing pipeline

Open mvaligursky opened this issue 2 years ago • 7 comments

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

mvaligursky avatar Jun 10 '22 13:06 mvaligursky

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.

slimbuck avatar Jun 10 '22 13:06 slimbuck

Yep, many implementations use RGBM and it's a viable / faster option, with some range limitations.

mvaligursky avatar Jun 10 '22 13:06 mvaligursky

https://learnopengl.com/Guest-Articles/2022/Phys.-Based-Bloom

mvaligursky avatar Jun 13 '22 08:06 mvaligursky

related https://github.com/playcanvas/engine/issues/5287

mvaligursky avatar Jul 07 '23 15:07 mvaligursky

related https://github.com/playcanvas/engine/issues/4284

mvaligursky avatar Jul 07 '23 15:07 mvaligursky

Ideally we'd implement in using this system when ready: https://github.com/playcanvas/engine/issues/5687

mvaligursky avatar Sep 28 '23 14:09 mvaligursky

related: https://github.com/playcanvas/engine/pull/5833

mvaligursky avatar Nov 20 '23 16:11 mvaligursky