// Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd. CCEffect %{ techniques: - passes: - vert: hilight-vs:vert frag: hilight-fs:frag depthStencilState: depthTest: false depthWrite: false blendState: targets: - blend: true blendSrc: src_alpha blendDst: one_minus_src_alpha blendDstAlpha: one_minus_src_alpha rasterizerState: cullMode: none properties: alphaThreshold: { value: 0.5 } mainColor: { value: [1, 1, 1, 1], editor: { type: color } } highlightColor: { value: [1, 1, 1, 1], editor: { type: color } } highlightIntensity: { value: 0.0, editor: { type: number, min: 0.0, max: 1.0 } } }% CCProgram hilight-vs %{ precision highp float; #include #if USE_LOCAL #include #endif #if SAMPLE_FROM_RT #include #endif in vec3 a_position; in vec2 a_texCoord; in vec4 a_color; out vec4 color; out vec2 uv0; vec4 vert () { vec4 pos = vec4(a_position, 1); #if USE_LOCAL pos = cc_matWorld * pos; #endif #if USE_PIXEL_ALIGNMENT pos = cc_matView * pos; pos.xyz = floor(pos.xyz); pos = cc_matProj * pos; #else pos = cc_matViewProj * pos; #endif uv0 = a_texCoord; #if SAMPLE_FROM_RT CC_HANDLE_RT_SAMPLE_FLIP(uv0); #endif color = a_color; return pos; } }% CCProgram hilight-fs %{ precision highp float; #include #include in vec4 color; uniform Constant { vec4 mainColor; vec4 highlightColor; float highlightIntensity; }; #if USE_TEXTURE in vec2 uv0; #pragma builtin(local) layout(set = 2, binding = 12) uniform sampler2D cc_spriteTexture; #endif vec4 frag () { vec4 o = vec4(1, 1, 1, 1); #if USE_TEXTURE o *= CCSampleWithAlphaSeparated(cc_spriteTexture, uv0); #if IS_GRAY float gray = 0.2126 * o.r + 0.7152 * o.g + 0.0722 * o.b; o.r = o.g = o.b = gray; #endif #endif o *= color; o *= mainColor; if(o.a > 0.0){ vec4 hilit = highlightColor * highlightIntensity; o += hilit; } ALPHA_TEST(o); // CC_APPLY_FOG(o); // return CCFragOutput(o); return o; } }%