Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Post-Processing v2 color grading -- LUT interpolation

Discussion in 'General Graphics' started by mlab2, May 21, 2022.

  1. mlab2

    mlab2

    Joined:
    May 21, 2022
    Posts:
    4
    In the Post-Processing Stack v2, the color grading effect allows you to use a LUT texture image to adjust color appearance. I'd really appreciate it if someone who's familiar with the C# implementation of this effect could point me to the code where the values in a LUT texture are interpolated so as to adjust the full range of RGB values (0-255). I'm specifically interested in the low-dynamic range mode.

    I've searched the post-processing stack code in the Graphics github repo, but haven't been able to track down the interpolation routines.

    Additional background, in case it's useful: I've figured out how to create a LUT texture image from scratch, so I can apply arbitrary transformations to rendered RGB values. So far so good. The documentation says that the color grading effect uses linear interpolation on the LUT texture to get the color grading mapping for RGB values that aren't given in the LUT texture. When I test this, though (i.e., assign RGB values to a material, and see how they're transformed by post-processing), I find that it's not exactly true -- there are some departures from linear interpolation. So I'd like to know how the interpolation is actually done.

    Thanks!
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    9,785
    It’s probably done in a shader and not in C#.
     
  3. mlab2

    mlab2

    Joined:
    May 21, 2022
    Posts:
    4
    Very helpful, thanks! After that I was able to track it down to ApplyLut2D() in Color.hlsl, which I think is what I'm looking for.