[]角色模型的材质列表切换后,不播放动作了
如何给角色使用自定义的shader、材质后,动作依然正常?
这是自定义的shader
设置了材质后,动作就静止了
这是自定义的shader
var attributeMap = {自定义材质
'a_Position': Laya.VertexElementUsage.POSITION0,
'a_Normal': Laya.VertexElementUsage.NORMAL0,
'a_Texcoord': Laya.VertexElementUsage.TEXTURECOORDINATE0
};
var uniformMap = {
'u_MvpMatrix': [Laya.Sprite3D.MVPMATRIX, Laya.Shader3D.PERIOD_SPRITE],
'u_WorldMat': [Laya.Sprite3D.WORLDMATRIX, Laya.Shader3D.PERIOD_SPRITE],
'u_texture': [CustomMaterial.DIFFUSETEXTURE_ID, Laya.Shader3D.PERIOD_MATERIAL]
};
var customShader = Laya.Shader3D.nameKey.add("CustomShader");
var vs = "attribute vec4 a_Position;\n" +
"attribute vec2 a_Texcoord;\n" +
"uniform mat4 u_MvpMatrix;\n" +
"uniform mat4 u_WorldMat;\n" +
"attribute vec3 a_Normal;\n" +
"varying vec3 v_Normal;\n" +
"varying vec2 v_Texcoord;\n" +
"void main(){\n" +
"gl_Position = u_MvpMatrix * a_Position;\n" +
"mat3 worldMat=mat3(u_WorldMat);\n" +
"v_Texcoord=a_Texcoord;\n" +
"v_Normal=worldMat*a_Normal;}";
var ps = "#ifdef FSHIGHPRECISION\n" +
"precision highp float;\n" +
"#else\n" +
"precision mediump float;\n" +
"#endif\n" +
"varying vec3 v_Normal;\n" +
"varying vec2 v_Texcoord;\n" +
"uniform sampler2D u_texture;\n" +
"void main(){\n" +
"gl_FragColor=texture2D(u_texture, v_Texcoord);}\n";
class CustomMaterial extends Laya.BaseMaterial {设置材质
static DIFFUSETEXTURE_ID: number = 1;
constructor() {
super();
this.setShaderName("CustomShader");
}
public getDiffuseTexture(): Laya.BaseTexture {
return this._getTexture(CustomMaterial.DIFFUSETEXTURE_ID);
}
public setDiffuseTexture(value: Laya.BaseTexture): void {
this._setTexture(CustomMaterial.DIFFUSETEXTURE_ID, value);
}
}
mesh.meshRender.sharedMaterials = mats;
设置了材质后,动作就静止了
没有找到相关结果
已邀请:
要回复问题请先登录
3 个回复
Supermang42
赞同来自:
xbgzs2010
赞同来自:
183*****755
赞同来自: