mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 15:42:39 +08:00
143 lines
3.2 KiB
Plaintext
143 lines
3.2 KiB
Plaintext
CCEffect %{
|
|
temporaries:
|
|
b1: &b1
|
|
targets:
|
|
- blend: true
|
|
blendSrc: src_alpha
|
|
blendDst: one
|
|
blendSrcAlpha: src_alpha
|
|
blendDstAlpha: one
|
|
b2: &b2
|
|
targets:
|
|
- blend: true
|
|
blendSrc: one
|
|
blendDst: one_minus_src_alpha
|
|
blendSrcAlpha: one
|
|
blendDstAlpha: one_minus_src_alpha
|
|
d1: &d1 { depthTest: true, depthWrite: false }
|
|
r1: &r1 { cullMode: none }
|
|
p1: &p1
|
|
mainTexture: { value: grey }
|
|
mainTiling_Offset: { value: [1, 1, 0, 0] }
|
|
p2: &p2
|
|
<<: *p1
|
|
tintColor: { value: [0.5, 0.5, 0.5, 0.5], editor: { type: color } }
|
|
|
|
techniques:
|
|
- name: add
|
|
passes:
|
|
- vert: vert:vs_main
|
|
frag: tinted-fs:add
|
|
rasterizerState: *r1
|
|
depthStencilState: *d1
|
|
blendState: *b1
|
|
properties: *p2
|
|
- name: alpha-blend
|
|
passes:
|
|
- vert: vert:vs_main
|
|
frag: tinted-fs:add
|
|
rasterizerState: *r1
|
|
depthStencilState: *d1
|
|
blendState: *b2
|
|
properties: *p2
|
|
- name: add-multiply
|
|
passes:
|
|
- vert: vert:vs_main
|
|
frag: tinted-fs:multiply
|
|
rasterizerState: *r1
|
|
depthStencilState: *d1
|
|
blendState: *b2
|
|
properties: *p2
|
|
- name: add-smooth
|
|
passes:
|
|
- vert: vert:vs_main
|
|
frag: no-tint-fs:addSmooth
|
|
rasterizerState: *r1
|
|
depthStencilState: *d1
|
|
blendState: *b2
|
|
properties: *p1
|
|
- name: premultiply-blend
|
|
passes:
|
|
- vert: vert:vs_main
|
|
frag: no-tint-fs:premultiplied
|
|
rasterizerState: *r1
|
|
depthStencilState: *d1
|
|
blendState: *b2
|
|
properties: *p1
|
|
}%
|
|
|
|
// TODO: soft particle
|
|
|
|
CCProgram vert %{
|
|
precision mediump float;
|
|
#include <particle-common>
|
|
#pragma define CC_RENDER_MODE RENDER_MODE_BILLBOARD
|
|
in vec3 a_position; // center position
|
|
in vec2 a_texCoord; // texcoord
|
|
in vec4 a_color;
|
|
|
|
uniform builtin {
|
|
vec4 cc_size_rotation;
|
|
};
|
|
|
|
vec4 vs_main() {
|
|
vec4 pos = vec4(a_position, 1);
|
|
|
|
pos = cc_matWorld * pos;
|
|
|
|
vec2 vertOffset = a_texCoord.xy - 0.5;
|
|
computeVertPos(pos, vertOffset, quaternionFromEuler(vec3(0., 0., cc_size_rotation.z)), vec3(cc_size_rotation.xy, 0.), cc_matViewInv);
|
|
pos = cc_matViewProj * pos;
|
|
uv = a_texCoord.xy;
|
|
color = a_color;
|
|
return pos;
|
|
}
|
|
}%
|
|
|
|
CCProgram tinted-fs %{
|
|
precision mediump float;
|
|
#include <output>
|
|
|
|
in vec2 uv;
|
|
in vec4 color;
|
|
|
|
uniform sampler2D mainTexture;
|
|
uniform FragConstants {
|
|
vec4 tintColor;
|
|
};
|
|
|
|
vec4 add () {
|
|
vec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);
|
|
return CCFragOutput(col);
|
|
}
|
|
|
|
vec4 multiply () {
|
|
vec4 col;
|
|
vec4 texColor = texture(mainTexture, uv);
|
|
col.rgb = tintColor.rgb * texColor.rgb * color.rgb * vec3(2.0);
|
|
col.a = (1.0 - texColor.a) * (tintColor.a * color.a * 2.0);
|
|
return CCFragOutput(col);
|
|
}
|
|
}%
|
|
|
|
CCProgram no-tint-fs %{
|
|
precision mediump float;
|
|
#include <output>
|
|
|
|
in vec2 uv;
|
|
in vec4 color;
|
|
|
|
uniform sampler2D mainTexture;
|
|
|
|
vec4 addSmooth () {
|
|
vec4 col = color * texture(mainTexture, uv);
|
|
col.rgb *= col.a;
|
|
return CCFragOutput(col);
|
|
}
|
|
|
|
vec4 premultiplied () {
|
|
vec4 col = color * texture(mainTexture, uv) * color.a;
|
|
return CCFragOutput(col);
|
|
}
|
|
}%
|