I’ll preface this by stating: I’m not a graphics programmer by background, so my question may be a foolish one. ![]()
I need to create functionality somewhat similar to eye adaptation, but different. I need to be able to, at the press of a button, determine the min and max intensities of a grayscale scene, and then apply gain (multiplicative) and bias (additive) to the scene to adjust the scene into a 0.0-1.0 range.
My scene materials render values potentially much greater than 1.0.
I currently have a (global) compute shader that constantly calculates the min and max intensities and reads them back from the GPU for the CPU to access. When a button is pushed, I calculate new gain and bias values on the CPU. Those are handed to a global fragment shader that applies these to the scene. A SceneViewExtension manages all of this in an override of PrePostProcessPass_RenderThread(). I read and write to (*Inputs.SceneTextures)->SceneColorTexture.
Everything works fine except that translucent items (glass and particles) don’t contribute to the min/max and are unaffected by my fragment shader.
I understand now that translucency is done in a separate pass and combined together (typically) later in the post process chain. I’m trying to make my shaders work with translucency. They also need to run before tonemapping (so I can read values > 1.0) and before bloom (so I can clamp values to 1.0 after I’ve read them).
So far, the solutions I’ve stumbled upon are:
- Change all of our translucent materials to render before DOF. This seems to combine them into the base pass early enough that my shaders catch them.
- Grab the main translucency buffer (there appear to be several, and that concerns me) and separately run the shaders on both the main scene color and the translucency buffer.
- Post Process materials seem to give me the ability to exert some control over where in the chain my custom shaders run (e.g. BeforeTonemapping). I could perhaps convert my compute shader to a pixel shader (change to reading back through a texture?). I would presume tonemapping happens after translucency is combined. >_> I’m used to gaining more control of things when I move from visual tools in Unreal to C++, but I’m just not seeing where I have any way to get at the kinds of things the Post Process Material management code uses in my SceneViewExtension.
Is there some other trick I’m missing? I believe I saw a way to request specific textures from the RDG by name, but I don’t immediately see how that would even help me.
Thanks for your time and assistance!