mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-03 17:42:41 +08:00
58 lines
1.3 KiB
Plaintext
58 lines
1.3 KiB
Plaintext
// Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
|
|
|
|
CCEffect %{
|
|
techniques:
|
|
- passes:
|
|
- vert: tonemap-vs
|
|
frag: tonemap-fs
|
|
pass: tone-mapping
|
|
depthStencilState:
|
|
depthTest: false
|
|
depthWrite: false
|
|
rasterizerState:
|
|
cullMode: none
|
|
}%
|
|
|
|
CCProgram tonemap-vs %{
|
|
#include <./post-process/chunks/vs>
|
|
}%
|
|
|
|
CCProgram tonemap-fs %{
|
|
precision highp float;
|
|
#include <builtin/uniforms/cc-global>
|
|
#include <common/common-define>
|
|
#include <common/color/gamma>
|
|
#include <common/color/aces>
|
|
#include <common/debug/debug-view-define>
|
|
|
|
in vec2 v_uv;
|
|
|
|
#pragma rate u_texSampler pass
|
|
layout(binding = 0) uniform sampler2D u_texSampler;
|
|
|
|
layout(location = 0) out vec4 fragColor;
|
|
|
|
vec3 HDR2LDR_PostProcess(vec3 color) {
|
|
vec3 tempColor = color.rgb;
|
|
#if CC_USE_HDR && CC_TONE_MAPPING_TYPE == HDR_TONE_MAPPING_ACES
|
|
tempColor.rgb = ACESToneMap(color.rgb);
|
|
#endif
|
|
return tempColor.rgb;
|
|
}
|
|
|
|
vec4 CCFragOutput_PostProcess(vec4 color) {
|
|
if (!DebugViewNeedDisplayOriginalData()) {
|
|
#if CC_USE_FLOAT_OUTPUT
|
|
color.rgb = HDR2LDR_PostProcess(color.rgb);
|
|
color.rgb = LinearToSRGB(color.rgb);
|
|
#endif
|
|
}
|
|
return color;
|
|
}
|
|
|
|
void main () {
|
|
vec4 o = texture(u_texSampler, v_uv);
|
|
fragColor = CCFragOutput_PostProcess(o);
|
|
}
|
|
}%
|