求一spine外发光做法
同问,顶一下
也许可以先把单一Spine照到RenderTextue,然后对得到的Texture进行Shader发光。
请问单独spine单节点截图截不了,截整个canvas或者单个sprite可以,求单一spine截图的正确姿势
我也不会,参考一下这个不知行不行。
Creator | 实现单个 Node 截图的两种方式 - Creator - Cocos中文社区
额,就是用的这个。。。
你可以和@ SuperSuRaccoon大佬问一下,记得大佬当初和我说过这个,大概思路和楼上差不多,先对spine进行截图,然后渲染这个纹理进行外发光,然后将spine本身挪到别处去。。。但是每帧截图效率不一定高,个人觉得会掉帧,不过应该有优化方案
做出来一个简易的shader,一行代码,但是有缺陷!
// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
properties:
texture: { value: white }
alphaThreshold: { value: 0.5 }
spineOverlayColor: { value: [1.0, 1.0, 1.0, 1.0], editor: { type: color } }
}%
CCProgram vs %{
precision highp float;
#include <cc-global>
#include <cc-local>
in vec3 a_position;
in vec4 a_color;
#if USE_TINT
in vec4 a_color0;
#endif
in vec2 a_uv0;
out vec2 v_uv0;
out vec4 v_light;
#if USE_TINT
out vec4 v_dark;
#endif
void main () {
mat4 mvp;
#if CC_USE_MODEL
mvp = cc_matViewProj * cc_matWorld;
#else
mvp = cc_matViewProj;
#endif
v_uv0 = a_uv0;
v_light = a_color;
#if USE_TINT
v_dark = a_color0;
#endif
gl_Position = mvp * vec4(a_position, 1);
}
}%
CCProgram fs %{
precision highp float;
uniform sampler2D texture;
in vec2 v_uv0;
in vec4 v_light;
#if USE_TINT
in vec4 v_dark;
#endif
#include <alpha-test>
#include <texture>
uniform spineColorOverlay{
vec4 spineOverlayColor;
};
void main () {
vec4 texColor = vec4(1.0);
CCTexture(texture, v_uv0, texColor);
texColor = mix(texColor, spineOverlayColor, spineOverlayColor.a * step(texColor.a, 0.3) * step(0.001, texColor.a));
vec4 finalColor;
#if USE_TINT
finalColor.a = v_light.a * texColor.a;
finalColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;
#else
finalColor = texColor * v_light;
#endif
ALPHA_TEST(finalColor);
gl_FragColor = finalColor;
}
}%
这个好像和你要的差不多: