From 2d2bbe673197ef5bfa2289a44caeef9cd8acd6fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=85=B5?= <49358166+xubing0906@users.noreply.github.com> Date: Mon, 20 Jul 2026 14:13:02 +0800 Subject: [PATCH] Use TONE_MAPPING_ACES constant for CC_TONE_MAPPING_TYPE check, skip ACESToneMap in linear mode. (#196) --- editor/assets/chunks/common/color/tone-mapping.chunk | 2 +- editor/assets/chunks/common/common-define.chunk | 8 ++++++-- editor/assets/chunks/legacy/output-standard.chunk | 2 +- editor/assets/effects/pipeline/smaa.effect | 4 +++- editor/assets/effects/pipeline/tonemap.effect | 4 +++- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/editor/assets/chunks/common/color/tone-mapping.chunk b/editor/assets/chunks/common/color/tone-mapping.chunk index 6808b80677..5b72296019 100644 --- a/editor/assets/chunks/common/color/tone-mapping.chunk +++ b/editor/assets/chunks/common/color/tone-mapping.chunk @@ -10,7 +10,7 @@ vec3 HDRToLDR(vec3 color) #endif { // linear exposure has already applied to light intensity - #if CC_TONE_MAPPING_TYPE == HDR_TONE_MAPPING_ACES + #if CC_TONE_MAPPING_TYPE == TONE_MAPPING_ACES color.rgb = ACESToneMap(color.rgb); #endif } diff --git a/editor/assets/chunks/common/common-define.chunk b/editor/assets/chunks/common/common-define.chunk index f5ae1f6908..198e3a2577 100644 --- a/editor/assets/chunks/common/common-define.chunk +++ b/editor/assets/chunks/common/common-define.chunk @@ -79,8 +79,12 @@ vec4 saturate(vec4 value) { return clamp(value, vec4(0.0), vec4(1.0)); } #define IS_RANGED_DIRECTIONAL_LIGHT(light_type) equalf_lowp(light_type, LIGHT_TYPE_RANGED_DIRECTIONAL) // CC_TONE_MAPPING_TYPE Values -#define TONE_MAPPING_ACES 0 -#define TONE_MAPPING_LINEAR 1 +#ifndef TONE_MAPPING_ACES + #define TONE_MAPPING_ACES 0 +#endif +#ifndef TONE_MAPPING_LINEAR + #define TONE_MAPPING_LINEAR 1 +#endif // Material #define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0 diff --git a/editor/assets/chunks/legacy/output-standard.chunk b/editor/assets/chunks/legacy/output-standard.chunk index 44525108a8..52cb818e9a 100644 --- a/editor/assets/chunks/legacy/output-standard.chunk +++ b/editor/assets/chunks/legacy/output-standard.chunk @@ -7,7 +7,7 @@ vec4 CCFragOutput (vec4 color) { #if CC_USE_RGBE_OUTPUT color = packRGBE(color.rgb); #elif !CC_USE_FLOAT_OUTPUT - #if CC_USE_HDR && CC_TONE_MAPPING_TYPE == HDR_TONE_MAPPING_ACES + #if CC_USE_HDR && CC_TONE_MAPPING_TYPE == TONE_MAPPING_ACES color.rgb = ACESToneMap(color.rgb); #endif color.rgb = LinearToSRGB(color.rgb); diff --git a/editor/assets/effects/pipeline/smaa.effect b/editor/assets/effects/pipeline/smaa.effect index 37fb04cc15..badd65932c 100644 --- a/editor/assets/effects/pipeline/smaa.effect +++ b/editor/assets/effects/pipeline/smaa.effect @@ -70,7 +70,9 @@ CCProgram smaa-edge-fs %{ vec3 ToLDR(vec3 color) { #if CC_USE_HDR color *= cc_exposure.x * FP_SCALE_INV; - color = ACESToneMap(color); + #if CC_TONE_MAPPING_TYPE == TONE_MAPPING_ACES + color = ACESToneMap(color); + #endif color = LinearToSRGB(color); #endif return color; diff --git a/editor/assets/effects/pipeline/tonemap.effect b/editor/assets/effects/pipeline/tonemap.effect index f30c67c397..08c1c9fdae 100644 --- a/editor/assets/effects/pipeline/tonemap.effect +++ b/editor/assets/effects/pipeline/tonemap.effect @@ -55,7 +55,9 @@ CCProgram tonemap-fs %{ vec3 ToLDR(vec3 color) { #if CC_USE_HDR color *= cc_exposure.x * FP_SCALE_INV; - color = ACESToneMap(color); + #if CC_TONE_MAPPING_TYPE == TONE_MAPPING_ACES + color = ACESToneMap(color); + #endif color = LinearToSRGB(color); #endif return color;