[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
{
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
没有找到相关结果
已邀请:
要回复问题请先登录
1 个回复
雷神
赞同来自: