写shader还区分2d,与3d么!看官网是3d的shader例子,有没有2d的shader例子?

private initShader(): void {
var attributeMap = {
'a_Position': Laya.VertexElementUsage.POSITION0,
'a_Normal': Laya.VertexElementUsage.NORMAL0
};
var uniformMap = {
'u_MvpMatrix': [Laya.Sprite3D.MVPMATRIX, Laya.Shader3D.PERIOD_SPRITE],
'u_WorldMat': [Laya.Sprite3D.WORLDMATRIX, Laya.Shader3D.PERIOD_SPRITE]
};
var customShader: number = Laya.Shader3D.nameKey.add("CustomShader");
var vs: string = "attribute vec4 a_Position;\n" +
"uniform mat4 u_MvpMatrix;\n" +
"uniform mat4 u_WorldMat;\n" +
"attribute vec3 a_Normal;\n" +
"varying vec3 v_Normal;\n" +
"void main(){\n" +
"gl_Position = u_MvpMatrix * a_Position;\n" +
"mat3 worldMat=mat3(u_WorldMat);\n" +
"v_Normal=worldMat*a_Normal;}";
var ps: string = "#ifdef FSHIGHPRECISION\n" +
"precision highp float;\n" +
"#else\n" +
"precision mediump float;\n" +
"#endif\n" +
"varying vec3 v_Normal;\n" +
"void main(){\n" +
"gl_FragColor=vec4(v_Normal,1.0);}\n";
Laya.ShaderCompile3D.add(customShader, vs, ps, attributeMap, uniformMap);
}
已邀请:

Laya_Aaron

赞同来自: 纪龙

http://ldc.layabox.com/doc/?nav=zh-as-3-4-4

要回复问题请先

商务合作
商务合作