Search Unity

Help Wanted Average Luminance of active render texture before post processing

Discussion in 'General Graphics' started by AverageCG, Aug 29, 2021.

  1. AverageCG

    AverageCG

    Joined:
    Nov 13, 2017
    Posts:
    14
    Hey, I am currently working on HDRP implementing different custom post processing effects, and this might be a very basic question but I somehow i can't see the forest for all the trees. I know i could use either mipmaps or compute reduction to get the average luminance and i'd know how to do either of that but I am completely lost as to where and how I would need to inject any code for this. In the case of mipmaps i understand I would also need to first blit the rendertexture while taking the logarithm.

    it has been a while since i've used unity in any bigger capacity so I am already lost at how to inject anything before post processing. Appreciate any pointers to relevant documentation or code examples

    Thanks
     
  2. AverageCG

    AverageCG

    Joined:
    Nov 13, 2017
    Posts:
    14
    For clarification my current idea of how to achieve this is to create a custom pass (correct me if theres a better way for this first step) that simply renders the log luminance of the currently active color buffer into a custom buffer. However I am still lost at how i would go about injecting code that will generate mipmaps/ or run a compute shader handling reduction of said custom buffer after the custom pass finishes, so that the results will be available for post processing.

    I need this for some custom tone mapping project. Unity supports automatic exposure/ tone reproduction something unity will also need to compute average luminances for. If anyone knows how to just read those directly from the unity api or something that would also solve the issue...
     
    Last edited: Sep 1, 2021
unityunity