[0]2.x的2Dshader在laya3.x已经无法使用了
private shaderValue: Laya.Value2D;是否可以在官方demo出个简单的2Dshader,现在按找到的shader来实现会报错
static DissolveSurfaceSaveName: number = 9999;
constructor() {
super();
this.init();
}
public init(): void {
this.shaderValue = new Laya.Value2D(DissolveSurfaceSprite.DissolveSurfaceSaveName, DissolveSurfaceSprite.DissolveSurfaceSaveName);
//重要的一步 将渲染设置为自定义
this.customRenderEnable = true;
this.shaderValue.shader = new Laya.Shader2X(vs, ps, DissolveSurfaceSprite.DissolveSurfaceSaveName);
}
// 自定义渲染提交
public customRender(context: Context, x: number, y: number) {
if (this.texture) {
context.drawTarget(this.texture as any, x, y, this.texture.width, this.texture.height, null, this.shaderValue);
} else {
// context.drawTarget(this.texture as any, x, y, 0, 0, null, this.shaderValue);
}
}
没有找到相关结果
已邀请:
1 个回复
zon
赞同来自: