mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
3cea8e7fb8
* Fix CCLocal and CCForwardLight binding error of deferred pipeline * post process stage enable blend * Modify the way post process stage alpha blending * restore postprocess
78 lines
2.0 KiB
Plaintext
78 lines
2.0 KiB
Plaintext
// Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
|
|
|
|
CCEffect %{
|
|
techniques:
|
|
- passes:
|
|
- vert: post-process-vs
|
|
frag: post-process-fs
|
|
phase: post-process
|
|
depthStencilState:
|
|
depthTest: false
|
|
depthWrite: false
|
|
blendState:
|
|
targets:
|
|
- blend: true
|
|
blendSrc: src_alpha
|
|
blendDst: one_minus_src_alpha
|
|
blendSrcAlpha: src_alpha
|
|
blendDstAlpha: one_minus_src_alpha
|
|
}%
|
|
|
|
CCProgram post-process-vs %{
|
|
precision highp float;
|
|
#include <input-standard>
|
|
#include <cc-global>
|
|
#include <common>
|
|
|
|
out vec2 v_uv;
|
|
|
|
void main () {
|
|
StandardVertInput In;
|
|
CCVertInput(In);
|
|
CC_HANDLE_GET_CLIP_FLIP(In.position.xy);
|
|
gl_Position = In.position;
|
|
gl_Position.y = gl_Position.y;
|
|
v_uv = a_texCoord;
|
|
}
|
|
}%
|
|
|
|
CCProgram post-process-fs %{
|
|
precision highp float;
|
|
#include <cc-global>
|
|
#include <anti-aliasing>
|
|
in vec2 v_uv;
|
|
|
|
layout(binding = 0) uniform sampler2D outputResultMap;
|
|
|
|
layout(location = 0) out vec4 fragColor;
|
|
|
|
void texcoords(vec2 fragCoord, vec2 resolution,
|
|
out vec2 v_rgbNW, out vec2 v_rgbNE,
|
|
out vec2 v_rgbSW, out vec2 v_rgbSE,
|
|
out vec2 v_rgbM) {
|
|
vec2 inverseVP = 1.0 / resolution.xy;
|
|
v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;
|
|
v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;
|
|
v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;
|
|
v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;
|
|
v_rgbM = vec2(fragCoord * inverseVP);
|
|
}
|
|
|
|
void main () {
|
|
mediump vec2 v_rgbNW;
|
|
mediump vec2 v_rgbNE;
|
|
mediump vec2 v_rgbSW;
|
|
mediump vec2 v_rgbSE;
|
|
mediump vec2 v_rgbM;
|
|
|
|
#if ANTIALIAS_TYPE == 1
|
|
vec2 resolution = cc_screenSize.xy;
|
|
vec2 fragCoord = v_uv * resolution;
|
|
texcoords(fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
|
|
fragColor = fxaa(outputResultMap, fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
|
|
#else
|
|
fragColor = texture(outputResultMap, v_uv);
|
|
#endif
|
|
}
|
|
}%
|