-
new Shader(params)
-
Shader类
Name Type Description params
Object optional 初始化参数,所有params都会复制到实例上
Members Show Inherited
Name | Type | Default | Description |
---|---|---|---|
isShader
|
boolean | true | |
className
|
string | Shader | |
vs
|
String | ''· |
vs 顶点代码 |
fs
|
String | '' |
vs 片段代码 |
alwaysUse
|
Boolean | true |
是否始终使用 |
-
staticShader.shadersObject
-
内部的所有shader块字符串,可以用来拼接glsl代码
-
static,readonlyShader.cacheCache
-
Shader 缓存
-
static,readonlyShader.headerCacheCache
-
Shader header缓存,一般不用管
Methods Show Inherited
-
staticShader.init(renderer)
-
初始化
Name Type Description renderer
WebGLRenderer -
staticShader.reset()
-
重置
-
staticShader.getHeaderKey(mesh, material, lightManager, fog, useLogDepth){string}
-
获取header缓存的key
Name Type Description mesh
Mesh mesh
material
Material 材质
lightManager
LightManager lightManager
fog
Fog fog
useLogDepth
Boolean 是否使用对数深度
Returns:
Type Description string -
staticShader.getHeader(mesh, material, lightManager, fog){String}
-
获取header
Name Type Description mesh
Mesh material
Material lightManager
LightManager fog
Fog Returns:
Type Description String -
staticShader.getShader(mesh, material, isUseInstance, lightManager, fog, useLogDepth){Shader}
-
获取 shader
Name Type Description mesh
Mesh material
Material isUseInstance
Boolean lightManager
LightManager fog
Fog useLogDepth
Boolean Returns:
Type Description Shader -
staticShader.getBasicShader(material, isUseInstance, lightManager, fog){Shader}
-
获取基础 shader
Name Type Description material
Material isUseInstance
Boolean lightManager
LightManager fog
Fog Returns:
Type Description Shader -
staticShader.getCustomShader(vs, fs, cacheKey, useHeaderCache){Shader}
-
获取自定义shader
Name Type Default Description vs
String 顶点代码
fs
String 片段代码
cacheKey
String optional 如果有,会以此值缓存 shader
useHeaderCache
String false optional 如果cacheKey和useHeaderCache同时存在,使用 cacheKey+useHeaderCache缓存 shader
Returns:
Type Description Shader -
destroyIfNoRef(renderer){Shader}
-
没有被引用时销毁资源
Name Type Description renderer
WebGLRenderer Returns:
Type Description Shader this