[0]layaair 3d 自定义shader 文件 报错 set shader name failed

Shader3D Start
{
type:Shader3D,
name:MyGlowingEdgeShader,
enableInstancing:true,
supportReflectionProbe:false,
uniformMap:{
u_marginalColor:{type:Color,tips:"边距颜色"},
u_OutLineWidth:{type:float,default:0.,tips:"线条宽度",fractionDigits:1}
},
styles:{
// 这里里面的内容只在编辑器中显示
u_marginalColor:{caption:"边距颜色"},
u_OutLineWidth:{caption:"线条宽度",range:[0.,100.],fractionDigits:1}
}
defines: {
ENABLEVERTEXCOLOR: { type: bool, default: false ,caption:"是否开启顶点颜色"}
}
shaderPass:[
{
pipeline:Forward,
VS:GlowingEdgeVS,
FS:GlowingEdgeFS
}
]
}
Shader3D End 
GLSL Start // 开始定义glsl 代码 
#defineGLSL GlowingEdgeVS // 定义顶点着色器代码
//#include "./glsl/GlowingEdge.vs";
#define SHADER_NAME MyGlowingEdgeShader 
#if defined(GL_FRAGMENT_PRECISION_HIGH)
precision highp float;
precision highp int;
#else
precision mediump float;
precision mediump int;
#endif 
#include "VertexCommon.glsl";
#include "Scene.glsl";
#include "Camera.glsl";
#include "Sprite3DVertex.glsl"; 
varying vec2 v_Texcoord;
varying vec3 v_Normal;
varying vec3 v_PositionWorld; 
void main()
{
Vertex vertex;
getVertexParams(vertex);
v_Texcoord = vertex.texCoord0;
mat4 worldMat = getWorldMatrix();
vec3 positionWS = (worldMat * vec4(vertex.positionOS,1.)).xyz;
v_PositionWorld = positionWS;
v_Normal = normalize((worldMat * vec4(vertex.normalOS,0.))).xyz;
gl_Position = getPositionCS(positionWS);
gl_Position = remapPositionZ(gl_Position);
}
#endGLSL 
#defineGLSL GlowingEdgeFS
//#include "./glsl/GlowingEdge.fs";
#define SHADER_NAME MyGlowingEdgeShader 
#if defined(GL_FRAGMENT_PRECISION_HIGH)
precision highp float;
precision highp int;
#else
precision mediump float;
precision mediump int;
#endif 
#include "Lighting.glsl";
#include "Camera.glsl";
#include "Scene.glsl";
#include "globalIllumination.glsl"; 
varying vec2 v_Texcoord;
varying vec3 v_Normal;
varying vec3 v_PositionWorld; 
uniform sampler2D u_texture;
uniform vec3 u_marginalColor; 
void main()
{
gl_FragColor = texture2D(u_texture,v_Texcoord);
vec3 ambientColor = diffuseIrradiance(v_Normal);
vec3 normal = normalize(v_Normal);
vec3 toEyeDir = normalize(getViewDirection(v_PositionWorld));
float Rim = 1. - max(0.,dot(toEyeDir,normal));
vec3 lightColor = ambientColor;
vec3 Emissive = 2. * lightColor * u_marginalColor * pow(Rim,3.); 
gl_FragColor = texture2D(u_texture,v_Texcoord) + vec4(Emissive,1.);
}
#endGLSL 
GLSL End
已邀请:

雷神

赞同来自:

为什么  会出现 设置 shader name 失败,文件名已经改成 GlowingEdgeShader.shader 里面的宏定义也改成了  GlowingEdgeShader

要回复问题请先

商务合作
商务合作