Hi all, how can I can get a custom NME post process to underexpose the scene and handle emissive properly (like how scene.imageProcessingConfiguration.exposure = value does)
Here is a PG for an example and the NME material I’m using:
Thanks in advance for any insight!
@papajuan, after some discussion with @Deltakosh and @sebavan, we have an update for you in Exposure test | Babylon.js Playground
Basically, what is happening is since you over-cranked your emissive value to 20, you were blowing out the pixels which get clamped to LDR values before the post process step. This is why the emissive was darkening because it started at a value of 1.0 instead of a value of 20.0.
To correct for it, you need to let the post process handle the clamp rather than the material handling the clamp. To do this add:
emissive_material.imageProcessingConfiguration.applyByPostProcess = true
This prevents the material from clamping values after the PBR step in the shader. Then you need to tell the postProcess to use a float texture type so that it is working with an HDR texture and not clamping to LDR. This is added with the last argument in createPostProcess
let postProcess = pp_material.createPostProcess(camera, 1, undefined, engine, false, BABYLON.Constants.TEXTURETYPE_FLOAT)
Now you have your HDR values in your node material post process, but are now in linear space. The last thing you need to do is to convert back to gamma space at the end by setting your FragmentOutput to convert to gamma right on the block:
You will note, however, that setting up the scene this way will prevent the scene’s material processing to work like it was so you won’t be able to mix scene material processing with node material post processing. Hope this helps.
Thanks so much @PatrickRyan (and @Deltakosh and @sebavan) for both the fix and the detailed explanation. Truly amazing level of support here!!
Follow up issue: How can I involve Depth Of Field and still have HDR work? I’m not having any luck and not confident my approach is even correct. Can you please review this PG and offer advice? Thanks so much.
I added at the end the way to keep the emissive HDR
Looks like I had to give up default tone mapping. Any suggestions on how to get tone mapping back with this configuration?
Awesome. Because of some other effects in the chain, I just needed to add ippp.fromLinearSpace = false but this otherwise worked. Thank you so much!