CUBE LUTs direct support

Huh, apparently I haven’t posted anything on the UE forums since we moved away from the Epic forums… Anyway…

I thought I’d share this little side project I’m working on.

As you probably know if you’re interested in colour grading, you can set a Color Lookup Table in a Post Process Volume to change the look of your game.

However, the process to do this is quite clunky (download a PNG from the documentation, take it into photoshop, play around, export it, import it, change the texture settings, ???, profit).

So I decided to enable Unreal to directly import .cube LUTs (which is the industry standard format you can export from professional colour grading applications such as Davinci Resolve) and generate a CLUT texture from them.

For example, here’s a vanilla scene

And now with a Kodak film LUT nicked straight from Adobe Premiere. (The difference is subtle, I know, but I’m not trying to show what LUTs can do)

It will eventually support any size 3D LUT (and maybe even 1D LUTS). When it is in a good state, I’ll make a pull request for it.

It’s functional, but at the moment I’m doing gross approximations when evaluating the LUT, which results in a very choppy texture:

It’s supposed to look like this:

But right now it looks like this:

That’s because I need to learn how to do tetrahedral interpolations…

I’ll keep you posted of the progress.

This is really cool. Good luck! :slight_smile:

Thanks NasteX.

So, status update.

I had to backtrack a little bit as I found that my foundation work wasn’t entirely correct.

The first thing to do to get this working was to procedurally recreate the unmodified LUT texture provided by Epic. (The one found here: Color Grading and Filmic Tonemapper | Unreal Engine Documentation ).

If the LUT is really neutral, you’d expect that if you used it on a Post Process Volume, nothing would change. But in my case, something did change.

As a control, I imported the unmodified Epic LUT into the editor, and found that it was ever so slightly changing the contrast, as demonstrated below (assuming web compression doesn’t hide the difference)


No post process


Post process with Unmodified LUT

Note how the shadows get lighter on the second screenshot.

So one of two things is happening: either the source LUT is incorrect, or the process of downloading it from the website modifies it in some way. I’m not excluding the option that I might have downloaded it “wrong”, but in any case, from where I’m standing, this is another reason for doing what I’m doing. (EDIT: The provided LUT seems indeed correct, so I must have downloaded it incorrectly I suppose.)

This discovery got me to look more closely at how I generated the source LUT and realised I made a silly mistake (got my ranges wrong so was excluding the case when a colour channel was at 255).

With that fixed, my generated neutral LUT now leaves the image unmodified when applied on a post-process volume.

I’ve attached a TGA version of it for you to use.

SourceLUT.TGA (12 KB)

Now I need to look at a few edge cases where my evaluation of the CUBE LUT returns odd results.

Getting there.

Success!!

Right, I’ve got it working.

Here’s a more visual example


Vanilla scene

LUT applied: Fuji F125 (from the Adobe Creative Cloud LUTs)

So at this stage, any .cube 3D LUT of any size should work.

Now I’m going to take a look at supporting 1D LUTs. I doubt they’ll be used much, but I might as well fully support the format. And you never know, if somebody integrates UE4 scenes into live action video, this might be useful to match the gamma curve of the footage used.

Well that was easier than expected.

1D LUTs are now supported. In the example below, I’ve applied a Linear to sLog2 LUT.

Now I’ve got to do the boring part: Error handling…

Nice to see you’re making progress. Keep up the good work!

This is really interesting, great work!

Are you planning on releasing the code for this? I’d want to play with it as some projects I’m working on would greatly benefit of an improved colour grading pipeline :smiley:

I’m planning on making a pull request for it, so if it goes through it will just be part of the engine.

OK, I’m done, but I’m struggling to get the pull request actually created :frowning:

What problem do you have? Can we assist you in any way?

Nah, problem was fixed.

Pull request is there: https://github.com/EpicGames/UnrealEngine/pull/2802

Nice! Great work! :slight_smile:

Doing something like that with live action in the near future. Any luck getting this out there for the rest of us?

Well, it’s already out there, just integrate the pull request in your branch.

But if by “the rest of us”, you mean non-coders, I might consider making a plug-in out of it, though it’s such a small thing it would be nice to see it integrated to the engine.

I just get a 404