Skip to content

Conversation

@vanruesc
Copy link
Member

Related issue: #584

Description

This PR implements CDL for AgX tone mapping. It's based on mrdoob/three.js#27618 and mrdoob/three.js#29510.

The API looks like this:

const toneMappingEffect = new ToneMappingEffect({
  toneMapping: ToneMapping.AGX,
  cdlPreset: CDLPreset.PUNCHY
});

const cdl = toneMappingEffect.cdl;
cdl.slope.set(...);
cdl.offset.set(...);
cdl.power.set(...);
cdl.saturation = ...;

cdl.applyPreset(CDLPreset.DEFAULT);

I've also included the preset from Needle Engine that @hybridherbst posted here for good measure.

I had hoped that CDL would eventually land in three, and not just for TSL because it would've made the integration process much easier. Now it's a bit on the messier side since it requires shader chunk manipulation.

Feedback is welcome @donmccurdy, @hybridherbst and anyone else who might be interested.

@hybridherbst
Copy link

That's great!

I think the comment for the Needle preset can be adjusted to match better what the intention was, something like this?

Similar to the punchy preset, but with lower contrast.

/**
* Adjusted for production use to have a similar feeling of contrast as ACES over a wide range of scenes.
*/

NEEDLE

We're using this as default for AgX by the way, because in three.js it's not adjustable and baseline is too flat (as your comment states as well).

@vanruesc
Copy link
Member Author

I think the comment for the Needle preset can be adjusted to match better what the intention was

Done 👍

We're using this as default for AgX

I also prefer it, but I think for postprocessing it's best to stick to the default that three is using to avoid surprises.

@vanruesc
Copy link
Member Author

vanruesc commented Aug 21, 2025

One thing that bothers me a bit about this implementation is that it's so tightly coupled with tone mapping, but I guess that's why it's called "primary" color grading. Users won't be able to easily interpolate between different color grading settings without jumping through some hoops. Only the saturation can easily be controlled to blend into and out of a greyscale look, and this is only possible when AgX is used.

Maybe we should also add "secondary" color grading effects like Sepia and Greyscale to cover those common use cases.

@vanruesc
Copy link
Member Author

Users won't be able to easily interpolate between different color grading settings without jumping through some hoops.

I've added a lerp method to support this use case.

@vanruesc vanruesc merged commit 89be7ed into v7 Aug 29, 2025
2 checks passed
@vanruesc vanruesc deleted the cdl branch August 29, 2025 20:26
@vanruesc vanruesc mentioned this pull request Aug 29, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants