Packagelaya.webgl.shader
Classpublic class Shader
InheritanceShader Inheritance BaseShader Inheritance laya.resource.Resource
Subclasses Shader2X



Public Properties
 PropertyDefined By
 InheritedactiveShader : BaseShader
[static]
BaseShader
 InheritedbindShader : BaseShader
[static]
BaseShader
  _id : int
Shader
  nameKey : StringKey
[static]
Shader
  _offset : int = 0
Shader
  _params : Array = null
Shader
  _paramsMap : *
Shader
  _preCompileShader : *
[static]
Shader
  _program : * = null
Shader
  _pshader : *
Shader
  sharders : Array
[static]
Shader
  tag : *
Shader
  _vshader : *
Shader
Protected Properties
 PropertyDefined By
  shaderParamsMap : Object
[static]
Shader
Public Methods
 MethodDefined By
  
Shader(vs:String, ps:String, saveName:* = null, nameMap:* = null)
根据vs和ps信息生成shader对象
Shader
  
addInclude(fileName:String, txt:String):void
[static]
Shader
  
create(vs:String, ps:String, saveName:* = null, nameMap:* = null):Shader
[static]
Shader
  
getParams():Array
得到编译后的变量及相关预定义
Shader
  
[static]
Shader
  
getUniform(name:String):*
根据变量名字获得
Shader
  
preCompile(nameID:int, vs:String, ps:String, nameMap:*):void
[static] 预编译shader文件,主要是处理宏定义
Shader
  
preCompile2D(nameID:int, mainID:int, vs:String, ps:String, nameMap:*):void
[static] 预编译shader文件,主要是处理宏定义
Shader
  
upload(shaderValue:ShaderValue, params:Array = null):void
提交shader到GPU
Shader
  
uploadArray(shaderValue:Array, length:int, _bufferUsage:*):void
按数组的定义提交
Shader
  
uploadOne(name:String, value:*):void
Shader
  
uploadTexture2D(value:*):void
Shader
  
withCompile(nameID:int, define:*, shaderName:*, createShader:Function):Shader
[static] 根据宏动态生成shader文件,支持#include?COLOR_FILTER "parts/ColorFilter_ps_logic.glsl";条件嵌入文件
Shader
  
withCompile2D(nameID:int, mainID:int, define:*, shaderName:*, createShader:Function):Shader
[static] 根据宏动态生成shader文件,支持#include?COLOR_FILTER "parts/ColorFilter_ps_logic.glsl";条件嵌入文件
Shader
Protected Methods
 MethodDefined By
  
_preGetParams(vs:String, ps:String):Object
Shader
  
[override]
Shader
  
[override]
Shader
Public Constants
 ConstantDefined By
  SHADERNAME2ID : Number = 0.0002
[static]
Shader
Property Detail
_idproperty
public var _id:int

_offsetproperty 
public var _offset:int = 0

_paramsproperty 
public var _params:Array = null

_paramsMapproperty 
public var _paramsMap:*

_preCompileShaderproperty 
public static var _preCompileShader:*

_programproperty 
public var _program:* = null

_pshaderproperty 
public var _pshader:*

_vshaderproperty 
public var _vshader:*

nameKeyproperty 
public static var nameKey:StringKey

shaderParamsMapproperty 
protected static var shaderParamsMap:Object

shardersproperty 
public static var sharders:Array

tagproperty 
public var tag:*

Constructor Detail
Shader()Constructor
public function Shader(vs:String, ps:String, saveName:* = null, nameMap:* = null)

根据vs和ps信息生成shader对象

Parameters
vs:String
 
ps:String
 
saveName:* (default = null)
 
nameMap:* (default = null) — 帮助里要详细解释为什么需要nameMap
Method Detail
_preGetParams()method
protected function _preGetParams(vs:String, ps:String):Object

Parameters

vs:String
 
ps:String

Returns
Object
addInclude()method 
public static function addInclude(fileName:String, txt:String):void

Parameters

fileName:String
 
txt:String

create()method 
public static function create(vs:String, ps:String, saveName:* = null, nameMap:* = null):Shader

Parameters

vs:String
 
ps:String
 
saveName:* (default = null)
 
nameMap:* (default = null)

Returns
Shader
detoryResource()method 
override protected function detoryResource():void

getParams()method 
public function getParams():Array

得到编译后的变量及相关预定义

Returns
Array
getShader()method 
public static function getShader(name:*):Shader

Parameters

name:*

Returns
Shader
getUniform()method 
public function getUniform(name:String):*

根据变量名字获得

Parameters

name:String

Returns
*
preCompile()method 
public static function preCompile(nameID:int, vs:String, ps:String, nameMap:*):void

预编译shader文件,主要是处理宏定义

Parameters

nameID:int
 
vs:String
 
ps:String
 
nameMap:*

preCompile2D()method 
public static function preCompile2D(nameID:int, mainID:int, vs:String, ps:String, nameMap:*):void

预编译shader文件,主要是处理宏定义

Parameters

nameID:int
 
mainID:int
 
vs:String
 
ps:String
 
nameMap:*

recreateResource()method 
override protected function recreateResource():void

upload()method 
public function upload(shaderValue:ShaderValue, params:Array = null):void

提交shader到GPU

Parameters

shaderValue:ShaderValue
 
params:Array (default = null)

uploadArray()method 
public function uploadArray(shaderValue:Array, length:int, _bufferUsage:*):void

按数组的定义提交

Parameters

shaderValue:Array — 数组格式[name,value,...]
 
length:int
 
_bufferUsage:*

uploadOne()method 
public function uploadOne(name:String, value:*):void

Parameters

name:String
 
value:*

uploadTexture2D()method 
public function uploadTexture2D(value:*):void

Parameters

value:*

withCompile()method 
public static function withCompile(nameID:int, define:*, shaderName:*, createShader:Function):Shader

根据宏动态生成shader文件,支持#include?COLOR_FILTER "parts/ColorFilter_ps_logic.glsl";条件嵌入文件

Parameters

nameID:int
 
define:*
 
shaderName:*
 
createShader:Function — 宏定义,格式:{name:value...}

Returns
Shader
withCompile2D()method 
public static function withCompile2D(nameID:int, mainID:int, define:*, shaderName:*, createShader:Function):Shader

根据宏动态生成shader文件,支持#include?COLOR_FILTER "parts/ColorFilter_ps_logic.glsl";条件嵌入文件

Parameters

nameID:int
 
mainID:int
 
define:*
 
shaderName:* — 宏定义,格式:{name:value...}
 
createShader:Function

Returns
Shader
Constant Detail
SHADERNAME2IDConstant
public static const SHADERNAME2ID:Number = 0.0002