问题:
spine组件在编辑器里设置自定义材质,然后通过tween 动态修改uniform 渲染不生效。同样的操作作用于sprite组件是生效的。
操作函数如下(传入spine组件是渲染不生效,但是onupdate函数里打印uniform值是被修改了的。传入sprite组件则正常):
static redblink2(renderComp: Renderable2D): Tween {
return tween(renderComp)
.to(5, {}, {
onStart: (target) => {
let mat = (target as Renderable2D).material
if (mat) {
const pass = mat.passes[0]
if (pass) {
const hThreshold = pass.getHandle(‘coverColor’);
pass.setUniform(hThreshold, new Vec4(1, 0, 0, 0.5)); // now, albedoScale.w = 0.5
}
}
},
onUpdate: (target, ratio) => {
if (ratio) {
let mat = (target as Renderable2D).material
if (mat) {
const pass = mat.passes[0]
if (pass) {
const hThreshold = pass.getHandle(‘coverColor’);
let out = new Vec4(0, 0, 0, 0)
pass.getUniform(hThreshold, out)
console.log(out.w)
pass.setUniform(hThreshold, new Vec4(1, 0, 0, 0.5 * (1 - ratio)));
}
}
}
},
})
.start()
}