|
vor 8 Jahren | |
---|---|---|
.. | ||
babylon.customMaterial.ts | vor 8 Jahren | |
readme.md | vor 8 Jahren |
1- manage part of current shader
CustomMaterial put some part of shader in special part of current shader and make new shader in ShaderStore shaders struct :
[ Begin ]
. // includes extensions varyng uniforms attributes special functions
[ Definations ]
void main(){
[ Main Begin ] . . . [ ]
}
method : SelectVersion(ver:string)
Custom material for now Supported just ver 3.0.0 of BabylonJs and this is default of currentVersion for now Add other old version in Progress %
method : AddUniform(name:string,kind:string,param:any):CustomMaterial
usage : new CustomMaterial(...).AddUniform('time','float')for append dynamic setting and manage
this method Add Unforn in bouth of shaders(Fragment and Vertex)
: new CustomMaterial(...).AddUniform('direction','vec3',new BABYLON.Vector3(0.,0.,0.)) </br>
: new CustomMaterial(...).AddUniform('txt1','sampler2D', new BABYLON.Texture("path",scene))
method : Fragment_Begin(shaderPart:string):CustomMaterial
shaderPart is Shader Structure append in start of main function in fragment shader
usage : new CustomMaterial(...).Fragment_Begin('vec3 direction = vec3(0.);')
method : Fragment_Definations(shaderPart:string):CustomMaterial
usage : new CustomMaterial(...).Fragment_Definations('float func1(vec4 param1){ return param1.x;}')shaderPart is Shader Structure append in befor of the main function in fragment shader
you can define your varyng and functions from this
method : Fragment_MainBegin(shaderPart:string):CustomMaterial
shaderPart is Shader Structure append in start place of the main function in fragment shader
method : Fragment_Custom_Diffuse(shaderPart:string):CustomMaterial
shaderPart is Shader Structure append after diffuseColor is defined of the main function in fragment shader
usage : new CustomMaterial(...).Fragment_Custom_Diffuse('diffuseColor = vec3(sin(vPositionW.x));')
: new CustomMaterial(...).Fragment_Custom_Diffuse('result = vec3(sin(vPositionW.x));') </br>
method : Fragment_Custom_Alpha(shaderPart:string):CustomMaterial
shaderPart is Shader Structure append when material need a alpha parameter in fragment shader
method : Fragment_Before_FragColor(shaderPart:string):CustomMaterial
shaderPart is Shader Structure append before gl_FragColor wanna be set in fragment shader
method : Vertex_Begin(shaderPart:string):CustomMaterial
shaderPart is Shader Structure append in start of main function in vertex shader
usage : new CustomMaterial(...).Vertex_Begin('vec3 direction = vec3(0.);')
method : Vertex_Definations(shaderPart:string):CustomMaterial
usage : new CustomMaterial(...).Vertex_Definations('float func1(vec4 param1){ return param1.x;}')shaderPart is Shader Structure append in befor of the main function in vertex shader
you can define your varyng and functions from this
method : Vertex_MainBegin(shaderPart:string):CustomMaterial
shaderPart is Shader Structure append in start place of the main function in vertex shader
method : Vertex_Befor_PositionUpdated(shaderPart:string):CustomMaterial{
shaderPart is Shader Structure append after positionUpdated is defined of the main function in vertex shader
usage : new CustomMaterial(...).Vertex_Befor_PositionUpdated('positionUpdated = positionUpdated;')
: new CustomMaterial(...).Vertex_Befor_PositionUpdated('result = positionUpdated * 1.5 ;') </br>
method : Vertex_Befor_NormalUpdated(shaderPart:string):CustomMaterial
shaderPart is Shader Structure append after normalUpdated is defined of the main function in vertex shader
usage : new CustomMaterial(...).Vertex_Befor_NormalUpdated('normalUpdated = normalUpdated;')
: new CustomMaterial(...).Vertex_Befor_NormalUpdated('result = normalUpdated ;') </br>