Using HD Scene Color Both With and Without Exposure In HDRP Post-Processing Effect

In HDRP I’m trying to use Shader Graph to create an effect where pixels that are below an HDR illuminance threshold are rendered in greyscale, and pixels that are above it are rendered in full colour as normal. In other words the mask shouldn’t just be pixels close to black as seen on the screen, but pixels that are actually darker than the threshold before exposure is adjusted to simulate eye adaptation.

My assumption right now is that to do this I’ll need to sample an HD Scene Color node with exposure off to get my data to convert to luminance for the mask, but will need an HD Scene Color node with exposure on to use as the base color data to modify. Although I’m hoping I just have some fundamental misunderstanding with how Unity and Shader Graph handles this, doing so doesn’t appear to work.

If I have two HD Scene Color input nodes with different exposure settings in the same post processing effect it throws a series of errors. Given that in any case I need a pass to access color data, and a second pass to write the modified output back to the camera colour buffer, I thought perhaps that I could insert a third pass between the other two, and then do this as follows;

Pass 1 - Sample HD Scene Color node without exposure, pass on to a Custom Target Color Buffer.
Pass 2 - Sample HD Scene Color node with exposure, retrieve output of pass 1 with Custom Color Buffer node. Use latter as mask and pass modified final data back into a Custom Target Colour Buffer.
Pass 3 - Retrieve output of pass 2 with Custom Color Buffer node, and throw it out into Camera Target Color Buffer for rendering.

In actuality what seems to happen is that only pass 1 or 2 will do anything, with the other just outputting a black screen, which makes me think I’m not correctly accessing or clearing buffers in between passes, or that maybe it has something to do with incorrect injection points.

Having gone through what little documentation I can find or wrap my head round, and having looked at hours of tutorials in hopes that something in there covers this, at this stage I’m really just mashing buttons that seem vaguely relevant and hoping for the best. Anyone know where I’m going wrong? It can’t be as hard as I’m making it.

I’m currently using 2022 LTS, but will happily update to 6 if anything’s changed there to make this easier.

I took your first explanation :

use Shader Graph to create an effect where pixels that are below an HDR illuminance threshold are rendered in greyscale, and pixels that are above it are rendered in full colour as normal

And made this fullscreen shadergraph, rendered with a custom pass (was to lazy to write a custom post process component, but it should be exactly the same) :

And here’s how it looks in the sample scene, objects in direct lighting (with a high intensity colors value) keep their original color, when the rest is desaturated.

You could also compute the smoothstep edges values based on the current exposure multiplier for the effect to adapt to the dynamic exposure.

Thanks Remy, I previously had no idea Unity handled exposure as a simple multiplication. Problem solved!