// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
CCEffect %{
techniques:
- name: opaque
passes:
- vert: unlit-vs:vert
frag: unlit-fs:frag
properties: &props
noiseTexture: { value: black }
mainTexture: { value: grey }
textureMoveSpeed: { value: [0, 0] }
tilingOffset: { value: [1, 1, 0, 0] }
noiseStrength: { value: [1, 1] }
noiseMoveSpeed: { value: [0, 0] }
mainColor: { value: [1, 1, 1, 1], editor: { type: color } }
colorScale: { value: [1, 1, 1], target: colorScaleAndCutoff.xyz }
alphaThreshold: { value: 0.5, target: colorScaleAndCutoff.w, editor: { parent: USE_ALPHA_TEST } }
color: { target: mainColor, editor: { visible: false } } # backward compability
migrations: &migs
properties:
mainColor: { formerlySerializedAs: color }
- name: transparent
passes:
- vert: unlit-vs:vert
frag: unlit-fs:frag
depthStencilState: &d1
depthTest: true
depthWrite: false
blendState:
targets:
- blend: true
blendSrc: src_alpha
blendDst: one_minus_src_alpha
blendDstAlpha: one_minus_src_alpha
properties: *props
migrations: *migs
- name: add
passes:
- vert: unlit-vs:vert
frag: unlit-fs:frag
rasterizerState: &r1 { cullMode: none }
depthStencilState: *d1
blendState:
targets:
- blend: true
blendSrc: src_alpha
blendDst: one
blendSrcAlpha: src_alpha
blendDstAlpha: one
properties: *props
migrations: *migs
- name: alpha-blend
passes:
- vert: unlit-vs:vert
frag: unlit-fs:frag
rasterizerState: *r1
depthStencilState: *d1
blendState:
targets:
- blend: true
blendSrc: src_alpha
blendDst: one_minus_src_alpha
blendSrcAlpha: src_alpha
blendDstAlpha: one_minus_src_alpha
properties: *props
migrations: *migs
}%
CCProgram unlit-vs %{
precision highp float;
#include
#include
#include
#if USE_VERTEX_COLOR
in vec4 a_color;
out vec4 v_color;
#endif
#if USE_TEXTURE
in vec2 a_texCoord;
out vec2 v_uv;
out vec2 screen_uv;
uniform TexCoords {
vec4 tilingOffset;
};
#endif
vec4 vert () {
vec4 position;
CCVertInput(position);
mat4 matWorld;
CCGetWorldMatrix(matWorld);
#if USE_TEXTURE
vec2 uv = a_texCoord;
#if FLIP_UV
uv.y = 1.0 - v_uv.y;
#endif
v_uv = uv * tilingOffset.xy + tilingOffset.zw;
#endif
#if USE_VERTEX_COLOR
v_color = a_color;
#endif
vec4 outPos = cc_matProj * (cc_matView * matWorld) * position;
screen_uv.x = (outPos.x / outPos.z + 1.0) * 0.5;
screen_uv.y = 1.0 - (outPos.y / outPos.z + 1.0) * 0.5;
return outPos;
}
}%
CCProgram unlit-fs %{
precision mediump float;
#include