mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-06 03:22:39 +08:00
83 lines
2.3 KiB
Plaintext
83 lines
2.3 KiB
Plaintext
// Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
|
|
|
|
CCEffect %{
|
|
techniques:
|
|
- passes:
|
|
- vert: post-process-vs
|
|
frag: post-process-fs
|
|
pass: post-process
|
|
depthStencilState:
|
|
depthTest: false
|
|
depthWrite: false
|
|
rasterizerState:
|
|
cullMode: none
|
|
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 <legacy/decode-standard>
|
|
#include <builtin/uniforms/cc-global>
|
|
#include <common/common-define>
|
|
|
|
out vec2 v_uv;
|
|
|
|
void main () {
|
|
StandardVertInput In;
|
|
CCDecode(In);
|
|
CC_HANDLE_GET_CLIP_FLIP(In.position.xy);
|
|
gl_Position = In.position;
|
|
v_uv = a_texCoord;
|
|
}
|
|
}%
|
|
|
|
CCProgram post-process-fs %{
|
|
precision highp float;
|
|
#include <builtin/uniforms/cc-global>
|
|
#include <post-process/anti-aliasing>
|
|
in vec2 v_uv;
|
|
|
|
#pragma rate outputResultMap pass
|
|
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 () {
|
|
#if ANTIALIAS_TYPE == 1
|
|
mediump vec2 v_rgbNW;
|
|
mediump vec2 v_rgbNE;
|
|
mediump vec2 v_rgbSW;
|
|
mediump vec2 v_rgbSE;
|
|
mediump vec2 v_rgbM;
|
|
|
|
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);
|
|
#elif ANTIALIAS_TYPE == 2
|
|
vec3 color = FxaaPixelShader(v_uv, outputResultMap, 1.0 / cc_screenSize.xy);
|
|
fragColor = vec4(color, texture(outputResultMap, v_uv).a);
|
|
#else
|
|
fragColor = texture(outputResultMap, v_uv);
|
|
#endif
|
|
}
|
|
}%
|