@babylonjs/materials 7.21.0 → 7.21.1
Sign up to get free protection for your applications and to get access to all the features.
package/custom/customMaterial.js
CHANGED
@@ -144,7 +144,7 @@ export class CustomMaterial extends StandardMaterial {
|
|
144
144
|
};
|
145
145
|
}
|
146
146
|
constructor(name, scene) {
|
147
|
-
super(name, scene);
|
147
|
+
super(name, scene, true);
|
148
148
|
this.CustomParts = new ShaderSpecialParts();
|
149
149
|
this.customShaderNameResolve = this.Builder;
|
150
150
|
this.FragmentShader = Effect.ShadersStore["defaultPixelShader"];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"customMaterial.js","sourceRoot":"","sources":["../../../../dev/materials/src/custom/customMaterial.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAE/C,OAAO,EAAE,gBAAgB,EAAE,sDAAwC;AAGnE,OAAO,EAAE,aAAa,EAAE,0CAA4B;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,4CAA8B;AAIvD;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAU9B,gBAAe,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAC3B,gBAAe,CAAC;CAuEnB;AAED;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,gBAAgB;IA2ChD;;;;OAIG;IACI,eAAe,CAAC,IAAsB,EAAE,MAAc;QACzD,IAAI,IAAI,CAAC,oBAAoB,EAAE;YAC3B,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,oBAAoB,EAAE;gBACxC,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACpC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE;oBACjB,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC;iBAC3D;qBAAM,IAAI,EAAE,CAAC,CAA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C,WAAW,CAAC,gBAAgB,GAAG,UAAU,CAAC;QAC/C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,6BAA6B,CAAC,UAAkB;QACnD,IAAI,CAAC,WAAW,CAAC,6BAA6B,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;QACjG,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,2BAA2B,CAAC,UAAkB;QACjD,IAAI,CAAC,WAAW,CAAC,2BAA2B,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QAC7F,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,6BAA6B,CAAC,UAAkB;QACnD,IAAI,CAAC,WAAW,CAAC,6BAA6B,GAAG,UAAU,CAAC;QAC5D,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,cAAc,CAAC,UAAkB;QACpC,IAAI,CAAC,WAAW,CAAC,cAAc,GAAG,UAAU,CAAC;QAC7C,OAAO,IAAI,CAAC;IAChB,CAAC;;AA3YD;;GAEG;AACW,4BAAa,GAAG,CAAC,CAAC;AA2YpC,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { Effect } from \"core/Materials/effect\";\r\nimport type { MaterialDefines } from \"core/Materials/materialDefines\";\r\nimport { StandardMaterial } from \"core/Materials/standardMaterial\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { Scene } from \"core/scene\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { SubMesh } from \"core/Meshes/subMesh\";\r\n\r\n/**\r\n * Structure of a custom shader\r\n */\r\nexport class CustomShaderStructure {\r\n /**\r\n * Fragment store\r\n */\r\n public FragmentStore: string;\r\n /**\r\n * Vertex store\r\n */\r\n public VertexStore: string;\r\n\r\n constructor() {}\r\n}\r\n\r\n/**\r\n * Parts of a shader\r\n */\r\nexport class ShaderSpecialParts {\r\n constructor() {}\r\n\r\n /**\r\n * Beginning of the fragment shader\r\n */\r\n public Fragment_Begin: string;\r\n /**\r\n * Variable definitions of the fragment shader\r\n */\r\n public Fragment_Definitions: string;\r\n /**\r\n * Beginning of the fragment main function\r\n */\r\n public Fragment_MainBegin: string;\r\n /**\r\n * End of the fragment main function\r\n */\r\n public Fragment_MainEnd: string;\r\n\r\n /**\r\n * Diffuse color calculation\r\n */\r\n public Fragment_Custom_Diffuse: string;\r\n /**\r\n * Before lightning computations\r\n */\r\n public Fragment_Before_Lights: string;\r\n /**\r\n * Before fog computations\r\n */\r\n public Fragment_Before_Fog: string;\r\n /**\r\n * Alpha calculations\r\n */\r\n public Fragment_Custom_Alpha: string;\r\n /**\r\n * Before frag color is assigned\r\n */\r\n public Fragment_Before_FragColor: string;\r\n /**\r\n * Beginning of the vertex shader\r\n */\r\n public Vertex_Begin: string;\r\n /**\r\n * Variable definitions of the vertex shader\r\n */\r\n public Vertex_Definitions: string;\r\n /**\r\n * Start of the main function of the vertex shader\r\n */\r\n public Vertex_MainBegin: string;\r\n\r\n /**\r\n * Before the world position computation\r\n */\r\n public Vertex_Before_PositionUpdated: string;\r\n\r\n /**\r\n * Before the normal computation\r\n */\r\n public Vertex_Before_NormalUpdated: string;\r\n\r\n /**\r\n * After the world position has been computed\r\n */\r\n public Vertex_After_WorldPosComputed: string;\r\n\r\n /**\r\n * Main end of the vertex shader\r\n */\r\n public Vertex_MainEnd: string;\r\n}\r\n\r\n/**\r\n * Customized material\r\n */\r\nexport class CustomMaterial extends StandardMaterial {\r\n /**\r\n * Index for each created shader\r\n */\r\n public static ShaderIndexer = 1;\r\n /**\r\n * Custom shader structure\r\n */\r\n public CustomParts: ShaderSpecialParts;\r\n /**\r\n * Name of the shader\r\n */\r\n public _createdShaderName: string;\r\n /**\r\n * List of custom uniforms\r\n */\r\n public _customUniform: string[];\r\n /**\r\n * Names of the new uniforms\r\n */\r\n public _newUniforms: string[];\r\n /**\r\n * Instances of the new uniform objects\r\n */\r\n public _newUniformInstances: { [name: string]: any };\r\n /**\r\n * Instances of the new sampler objects\r\n */\r\n public _newSamplerInstances: { [name: string]: Texture };\r\n /**\r\n * List of the custom attributes\r\n */\r\n public _customAttributes: string[];\r\n\r\n /**\r\n * Fragment shader string\r\n */\r\n public FragmentShader: string;\r\n /**\r\n * Vertex shader string\r\n */\r\n public VertexShader: string;\r\n\r\n /**\r\n * Runs after the material is bound to a mesh\r\n * @param mesh mesh bound\r\n * @param effect bound effect used to render\r\n */\r\n public AttachAfterBind(mesh: Mesh | undefined, effect: Effect) {\r\n if (this._newUniformInstances) {\r\n for (const el in this._newUniformInstances) {\r\n const ea = el.toString().split(\"-\");\r\n if (ea[0] == \"vec2\") {\r\n effect.setVector2(ea[1], this._newUniformInstances[el]);\r\n } else if (ea[0] == \"vec3\") {\r\n if (this._newUniformInstances[el] instanceof Color3) {\r\n effect.setColor3(ea[1], this._newUniformInstances[el]);\r\n } else {\r\n effect.setVector3(ea[1], this._newUniformInstances[el]);\r\n }\r\n } else if (ea[0] == \"vec4\") {\r\n if (this._newUniformInstances[el] instanceof Color4) {\r\n effect.setDirectColor4(ea[1], this._newUniformInstances[el]);\r\n } else {\r\n effect.setVector4(ea[1], this._newUniformInstances[el]);\r\n }\r\n effect.setVector4(ea[1], this._newUniformInstances[el]);\r\n } else if (ea[0] == \"mat4\") {\r\n effect.setMatrix(ea[1], this._newUniformInstances[el]);\r\n } else if (ea[0] == \"float\") {\r\n effect.setFloat(ea[1], this._newUniformInstances[el]);\r\n }\r\n }\r\n }\r\n if (this._newSamplerInstances) {\r\n for (const el in this._newSamplerInstances) {\r\n const ea = el.toString().split(\"-\");\r\n if (ea[0] == \"sampler2D\" && this._newSamplerInstances[el].isReady && this._newSamplerInstances[el].isReady()) {\r\n effect.setTexture(ea[1], this._newSamplerInstances[el]);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public ReviewUniform(name: string, arr: string[]): string[] {\r\n if (name == \"uniform\" && this._newUniforms) {\r\n for (let ind = 0; ind < this._newUniforms.length; ind++) {\r\n if (this._customUniform[ind].indexOf(\"sampler\") == -1) {\r\n arr.push(this._newUniforms[ind].replace(/\\[\\d*\\]/g, \"\"));\r\n }\r\n }\r\n }\r\n if (name == \"sampler\" && this._newUniforms) {\r\n for (let ind = 0; ind < this._newUniforms.length; ind++) {\r\n if (this._customUniform[ind].indexOf(\"sampler\") != -1) {\r\n arr.push(this._newUniforms[ind].replace(/\\[\\d*\\]/g, \"\"));\r\n }\r\n }\r\n }\r\n return arr;\r\n }\r\n\r\n /**\r\n * Builds the material\r\n * @param shaderName name of the shader\r\n * @param uniforms list of uniforms\r\n * @param uniformBuffers list of uniform buffers\r\n * @param samplers list of samplers\r\n * @param defines list of defines\r\n * @param attributes list of attributes\r\n * @returns the shader name\r\n */\r\n public Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]): string {\r\n if (attributes && this._customAttributes && this._customAttributes.length > 0) {\r\n attributes.push(...this._customAttributes);\r\n }\r\n\r\n this.ReviewUniform(\"uniform\", uniforms);\r\n this.ReviewUniform(\"sampler\", samplers);\r\n\r\n const name = this._createdShaderName;\r\n\r\n if (Effect.ShadersStore[name + \"VertexShader\"] && Effect.ShadersStore[name + \"PixelShader\"]) {\r\n return name;\r\n }\r\n Effect.ShadersStore[name + \"VertexShader\"] = this._injectCustomCode(this.VertexShader, \"vertex\");\r\n Effect.ShadersStore[name + \"PixelShader\"] = this._injectCustomCode(this.FragmentShader, \"fragment\");\r\n\r\n return name;\r\n }\r\n\r\n protected _injectCustomCode(code: string, shaderType: string): string {\r\n const customCode = this._getCustomCode(shaderType);\r\n\r\n for (const point in customCode) {\r\n const injectedCode = customCode[point];\r\n\r\n if (injectedCode && injectedCode.length > 0) {\r\n const fullPointName = \"#define \" + point;\r\n code = code.replace(fullPointName, \"\\n\" + injectedCode + \"\\n\" + fullPointName);\r\n }\r\n }\r\n\r\n return code;\r\n }\r\n\r\n protected _getCustomCode(shaderType: string): { [pointName: string]: string } {\r\n if (shaderType === \"vertex\") {\r\n return {\r\n CUSTOM_VERTEX_BEGIN: this.CustomParts.Vertex_Begin,\r\n CUSTOM_VERTEX_DEFINITIONS: (this._customUniform?.join(\"\\n\") || \"\") + (this.CustomParts.Vertex_Definitions || \"\"),\r\n CUSTOM_VERTEX_MAIN_BEGIN: this.CustomParts.Vertex_MainBegin,\r\n CUSTOM_VERTEX_UPDATE_POSITION: this.CustomParts.Vertex_Before_PositionUpdated,\r\n CUSTOM_VERTEX_UPDATE_NORMAL: this.CustomParts.Vertex_Before_NormalUpdated,\r\n CUSTOM_VERTEX_MAIN_END: this.CustomParts.Vertex_MainEnd,\r\n CUSTOM_VERTEX_UPDATE_WORLDPOS: this.CustomParts.Vertex_After_WorldPosComputed,\r\n };\r\n }\r\n return {\r\n CUSTOM_FRAGMENT_BEGIN: this.CustomParts.Fragment_Begin,\r\n CUSTOM_FRAGMENT_DEFINITIONS: (this._customUniform?.join(\"\\n\") || \"\") + (this.CustomParts.Fragment_Definitions || \"\"),\r\n CUSTOM_FRAGMENT_MAIN_BEGIN: this.CustomParts.Fragment_MainBegin,\r\n CUSTOM_FRAGMENT_UPDATE_DIFFUSE: this.CustomParts.Fragment_Custom_Diffuse,\r\n CUSTOM_FRAGMENT_UPDATE_ALPHA: this.CustomParts.Fragment_Custom_Alpha,\r\n CUSTOM_FRAGMENT_BEFORE_LIGHTS: this.CustomParts.Fragment_Before_Lights,\r\n CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR: this.CustomParts.Fragment_Before_FragColor,\r\n CUSTOM_FRAGMENT_MAIN_END: this.CustomParts.Fragment_MainEnd,\r\n CUSTOM_FRAGMENT_BEFORE_FOG: this.CustomParts.Fragment_Before_Fog,\r\n };\r\n }\r\n\r\n constructor(name: string, scene?: Scene) {\r\n super(name, scene);\r\n this.CustomParts = new ShaderSpecialParts();\r\n this.customShaderNameResolve = this.Builder;\r\n\r\n this.FragmentShader = Effect.ShadersStore[\"defaultPixelShader\"];\r\n this.VertexShader = Effect.ShadersStore[\"defaultVertexShader\"];\r\n\r\n CustomMaterial.ShaderIndexer++;\r\n this._createdShaderName = \"custom_\" + CustomMaterial.ShaderIndexer;\r\n }\r\n\r\n protected override _afterBind(mesh?: Mesh, effect: Nullable<Effect> = null, subMesh?: SubMesh): void {\r\n if (!effect) {\r\n return;\r\n }\r\n this.AttachAfterBind(mesh, effect);\r\n try {\r\n super._afterBind(mesh, effect, subMesh);\r\n } catch (e) {}\r\n }\r\n\r\n /**\r\n * Adds a new uniform to the shader\r\n * @param name the name of the uniform to add\r\n * @param kind the type of the uniform to add\r\n * @param param the value of the uniform to add\r\n * @returns the current material\r\n */\r\n public AddUniform(name: string, kind: string, param: any): CustomMaterial {\r\n if (!this._customUniform) {\r\n this._customUniform = new Array();\r\n this._newUniforms = new Array();\r\n this._newSamplerInstances = {};\r\n this._newUniformInstances = {};\r\n }\r\n if (param) {\r\n if (kind.indexOf(\"sampler\") != -1) {\r\n (<any>this._newSamplerInstances)[kind + \"-\" + name] = param;\r\n } else {\r\n (<any>this._newUniformInstances)[kind + \"-\" + name] = param;\r\n }\r\n }\r\n this._customUniform.push(\"uniform \" + kind + \" \" + name + \";\");\r\n this._newUniforms.push(name);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a custom attribute\r\n * @param name the name of the attribute\r\n * @returns the current material\r\n */\r\n public AddAttribute(name: string): CustomMaterial {\r\n if (!this._customAttributes) {\r\n this._customAttributes = [];\r\n }\r\n\r\n this._customAttributes.push(name);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Fragment_Begin portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Fragment_Begin(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_Begin = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Fragment_Definitions portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Fragment_Definitions(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_Definitions = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Fragment_MainBegin portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Fragment_MainBegin(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_MainBegin = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Fragment_MainEnd portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Fragment_MainEnd(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_MainEnd = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Fragment_Custom_Diffuse portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_Custom_Diffuse = shaderPart.replace(\"result\", \"diffuseColor\");\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Fragment_Custom_Alpha portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Fragment_Custom_Alpha(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_Custom_Alpha = shaderPart.replace(\"result\", \"alpha\");\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Fragment_Before_Lights portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Fragment_Before_Lights(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_Before_Lights = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Fragment_Before_Fog portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Fragment_Before_Fog(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_Before_Fog = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Fragment_Before_FragColor portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Fragment_Before_FragColor(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_Before_FragColor = shaderPart.replace(\"result\", \"color\");\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Vertex_Begin portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Vertex_Begin(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Vertex_Begin = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Vertex_Definitions portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Vertex_Definitions(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Vertex_Definitions = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Vertex_MainBegin portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Vertex_MainBegin(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Vertex_MainBegin = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Vertex_Before_PositionUpdated portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Vertex_Before_PositionUpdated = shaderPart.replace(\"result\", \"positionUpdated\");\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Vertex_Before_NormalUpdated portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Vertex_Before_NormalUpdated = shaderPart.replace(\"result\", \"normalUpdated\");\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Vertex_After_WorldPosComputed portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Vertex_After_WorldPosComputed = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Vertex_MainEnd portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Vertex_MainEnd(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Vertex_MainEnd = shaderPart;\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.CustomMaterial\", CustomMaterial);\r\n"]}
|
1
|
+
{"version":3,"file":"customMaterial.js","sourceRoot":"","sources":["../../../../dev/materials/src/custom/customMaterial.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAE/C,OAAO,EAAE,gBAAgB,EAAE,sDAAwC;AAGnE,OAAO,EAAE,aAAa,EAAE,0CAA4B;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,4CAA8B;AAIvD;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAU9B,gBAAe,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAC3B,gBAAe,CAAC;CAuEnB;AAED;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,gBAAgB;IA2ChD;;;;OAIG;IACI,eAAe,CAAC,IAAsB,EAAE,MAAc;QACzD,IAAI,IAAI,CAAC,oBAAoB,EAAE;YAC3B,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,oBAAoB,EAAE;gBACxC,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACpC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE;oBACjB,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC;iBAC3D;qBAAM,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI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,WAAW,CAAC,gBAAgB,GAAG,UAAU,CAAC;QAC/C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,6BAA6B,CAAC,UAAkB;QACnD,IAAI,CAAC,WAAW,CAAC,6BAA6B,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;QACjG,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,2BAA2B,CAAC,UAAkB;QACjD,IAAI,CAAC,WAAW,CAAC,2BAA2B,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QAC7F,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,6BAA6B,CAAC,UAAkB;QACnD,IAAI,CAAC,WAAW,CAAC,6BAA6B,GAAG,UAAU,CAAC;QAC5D,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,cAAc,CAAC,UAAkB;QACpC,IAAI,CAAC,WAAW,CAAC,cAAc,GAAG,UAAU,CAAC;QAC7C,OAAO,IAAI,CAAC;IAChB,CAAC;;AA3YD;;GAEG;AACW,4BAAa,GAAG,CAAC,CAAC;AA2YpC,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { Effect } from \"core/Materials/effect\";\r\nimport type { MaterialDefines } from \"core/Materials/materialDefines\";\r\nimport { StandardMaterial } from \"core/Materials/standardMaterial\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { Scene } from \"core/scene\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { SubMesh } from \"core/Meshes/subMesh\";\r\n\r\n/**\r\n * Structure of a custom shader\r\n */\r\nexport class CustomShaderStructure {\r\n /**\r\n * Fragment store\r\n */\r\n public FragmentStore: string;\r\n /**\r\n * Vertex store\r\n */\r\n public VertexStore: string;\r\n\r\n constructor() {}\r\n}\r\n\r\n/**\r\n * Parts of a shader\r\n */\r\nexport class ShaderSpecialParts {\r\n constructor() {}\r\n\r\n /**\r\n * Beginning of the fragment shader\r\n */\r\n public Fragment_Begin: string;\r\n /**\r\n * Variable definitions of the fragment shader\r\n */\r\n public Fragment_Definitions: string;\r\n /**\r\n * Beginning of the fragment main function\r\n */\r\n public Fragment_MainBegin: string;\r\n /**\r\n * End of the fragment main function\r\n */\r\n public Fragment_MainEnd: string;\r\n\r\n /**\r\n * Diffuse color calculation\r\n */\r\n public Fragment_Custom_Diffuse: string;\r\n /**\r\n * Before lightning computations\r\n */\r\n public Fragment_Before_Lights: string;\r\n /**\r\n * Before fog computations\r\n */\r\n public Fragment_Before_Fog: string;\r\n /**\r\n * Alpha calculations\r\n */\r\n public Fragment_Custom_Alpha: string;\r\n /**\r\n * Before frag color is assigned\r\n */\r\n public Fragment_Before_FragColor: string;\r\n /**\r\n * Beginning of the vertex shader\r\n */\r\n public Vertex_Begin: string;\r\n /**\r\n * Variable definitions of the vertex shader\r\n */\r\n public Vertex_Definitions: string;\r\n /**\r\n * Start of the main function of the vertex shader\r\n */\r\n public Vertex_MainBegin: string;\r\n\r\n /**\r\n * Before the world position computation\r\n */\r\n public Vertex_Before_PositionUpdated: string;\r\n\r\n /**\r\n * Before the normal computation\r\n */\r\n public Vertex_Before_NormalUpdated: string;\r\n\r\n /**\r\n * After the world position has been computed\r\n */\r\n public Vertex_After_WorldPosComputed: string;\r\n\r\n /**\r\n * Main end of the vertex shader\r\n */\r\n public Vertex_MainEnd: string;\r\n}\r\n\r\n/**\r\n * Customized material\r\n */\r\nexport class CustomMaterial extends StandardMaterial {\r\n /**\r\n * Index for each created shader\r\n */\r\n public static ShaderIndexer = 1;\r\n /**\r\n * Custom shader structure\r\n */\r\n public CustomParts: ShaderSpecialParts;\r\n /**\r\n * Name of the shader\r\n */\r\n public _createdShaderName: string;\r\n /**\r\n * List of custom uniforms\r\n */\r\n public _customUniform: string[];\r\n /**\r\n * Names of the new uniforms\r\n */\r\n public _newUniforms: string[];\r\n /**\r\n * Instances of the new uniform objects\r\n */\r\n public _newUniformInstances: { [name: string]: any };\r\n /**\r\n * Instances of the new sampler objects\r\n */\r\n public _newSamplerInstances: { [name: string]: Texture };\r\n /**\r\n * List of the custom attributes\r\n */\r\n public _customAttributes: string[];\r\n\r\n /**\r\n * Fragment shader string\r\n */\r\n public FragmentShader: string;\r\n /**\r\n * Vertex shader string\r\n */\r\n public VertexShader: string;\r\n\r\n /**\r\n * Runs after the material is bound to a mesh\r\n * @param mesh mesh bound\r\n * @param effect bound effect used to render\r\n */\r\n public AttachAfterBind(mesh: Mesh | undefined, effect: Effect) {\r\n if (this._newUniformInstances) {\r\n for (const el in this._newUniformInstances) {\r\n const ea = el.toString().split(\"-\");\r\n if (ea[0] == \"vec2\") {\r\n effect.setVector2(ea[1], this._newUniformInstances[el]);\r\n } else if (ea[0] == \"vec3\") {\r\n if (this._newUniformInstances[el] instanceof Color3) {\r\n effect.setColor3(ea[1], this._newUniformInstances[el]);\r\n } else {\r\n effect.setVector3(ea[1], this._newUniformInstances[el]);\r\n }\r\n } else if (ea[0] == \"vec4\") {\r\n if (this._newUniformInstances[el] instanceof Color4) {\r\n effect.setDirectColor4(ea[1], this._newUniformInstances[el]);\r\n } else {\r\n effect.setVector4(ea[1], this._newUniformInstances[el]);\r\n }\r\n effect.setVector4(ea[1], this._newUniformInstances[el]);\r\n } else if (ea[0] == \"mat4\") {\r\n effect.setMatrix(ea[1], this._newUniformInstances[el]);\r\n } else if (ea[0] == \"float\") {\r\n effect.setFloat(ea[1], this._newUniformInstances[el]);\r\n }\r\n }\r\n }\r\n if (this._newSamplerInstances) {\r\n for (const el in this._newSamplerInstances) {\r\n const ea = el.toString().split(\"-\");\r\n if (ea[0] == \"sampler2D\" && this._newSamplerInstances[el].isReady && this._newSamplerInstances[el].isReady()) {\r\n effect.setTexture(ea[1], this._newSamplerInstances[el]);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public ReviewUniform(name: string, arr: string[]): string[] {\r\n if (name == \"uniform\" && this._newUniforms) {\r\n for (let ind = 0; ind < this._newUniforms.length; ind++) {\r\n if (this._customUniform[ind].indexOf(\"sampler\") == -1) {\r\n arr.push(this._newUniforms[ind].replace(/\\[\\d*\\]/g, \"\"));\r\n }\r\n }\r\n }\r\n if (name == \"sampler\" && this._newUniforms) {\r\n for (let ind = 0; ind < this._newUniforms.length; ind++) {\r\n if (this._customUniform[ind].indexOf(\"sampler\") != -1) {\r\n arr.push(this._newUniforms[ind].replace(/\\[\\d*\\]/g, \"\"));\r\n }\r\n }\r\n }\r\n return arr;\r\n }\r\n\r\n /**\r\n * Builds the material\r\n * @param shaderName name of the shader\r\n * @param uniforms list of uniforms\r\n * @param uniformBuffers list of uniform buffers\r\n * @param samplers list of samplers\r\n * @param defines list of defines\r\n * @param attributes list of attributes\r\n * @returns the shader name\r\n */\r\n public Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]): string {\r\n if (attributes && this._customAttributes && this._customAttributes.length > 0) {\r\n attributes.push(...this._customAttributes);\r\n }\r\n\r\n this.ReviewUniform(\"uniform\", uniforms);\r\n this.ReviewUniform(\"sampler\", samplers);\r\n\r\n const name = this._createdShaderName;\r\n\r\n if (Effect.ShadersStore[name + \"VertexShader\"] && Effect.ShadersStore[name + \"PixelShader\"]) {\r\n return name;\r\n }\r\n Effect.ShadersStore[name + \"VertexShader\"] = this._injectCustomCode(this.VertexShader, \"vertex\");\r\n Effect.ShadersStore[name + \"PixelShader\"] = this._injectCustomCode(this.FragmentShader, \"fragment\");\r\n\r\n return name;\r\n }\r\n\r\n protected _injectCustomCode(code: string, shaderType: string): string {\r\n const customCode = this._getCustomCode(shaderType);\r\n\r\n for (const point in customCode) {\r\n const injectedCode = customCode[point];\r\n\r\n if (injectedCode && injectedCode.length > 0) {\r\n const fullPointName = \"#define \" + point;\r\n code = code.replace(fullPointName, \"\\n\" + injectedCode + \"\\n\" + fullPointName);\r\n }\r\n }\r\n\r\n return code;\r\n }\r\n\r\n protected _getCustomCode(shaderType: string): { [pointName: string]: string } {\r\n if (shaderType === \"vertex\") {\r\n return {\r\n CUSTOM_VERTEX_BEGIN: this.CustomParts.Vertex_Begin,\r\n CUSTOM_VERTEX_DEFINITIONS: (this._customUniform?.join(\"\\n\") || \"\") + (this.CustomParts.Vertex_Definitions || \"\"),\r\n CUSTOM_VERTEX_MAIN_BEGIN: this.CustomParts.Vertex_MainBegin,\r\n CUSTOM_VERTEX_UPDATE_POSITION: this.CustomParts.Vertex_Before_PositionUpdated,\r\n CUSTOM_VERTEX_UPDATE_NORMAL: this.CustomParts.Vertex_Before_NormalUpdated,\r\n CUSTOM_VERTEX_MAIN_END: this.CustomParts.Vertex_MainEnd,\r\n CUSTOM_VERTEX_UPDATE_WORLDPOS: this.CustomParts.Vertex_After_WorldPosComputed,\r\n };\r\n }\r\n return {\r\n CUSTOM_FRAGMENT_BEGIN: this.CustomParts.Fragment_Begin,\r\n CUSTOM_FRAGMENT_DEFINITIONS: (this._customUniform?.join(\"\\n\") || \"\") + (this.CustomParts.Fragment_Definitions || \"\"),\r\n CUSTOM_FRAGMENT_MAIN_BEGIN: this.CustomParts.Fragment_MainBegin,\r\n CUSTOM_FRAGMENT_UPDATE_DIFFUSE: this.CustomParts.Fragment_Custom_Diffuse,\r\n CUSTOM_FRAGMENT_UPDATE_ALPHA: this.CustomParts.Fragment_Custom_Alpha,\r\n CUSTOM_FRAGMENT_BEFORE_LIGHTS: this.CustomParts.Fragment_Before_Lights,\r\n CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR: this.CustomParts.Fragment_Before_FragColor,\r\n CUSTOM_FRAGMENT_MAIN_END: this.CustomParts.Fragment_MainEnd,\r\n CUSTOM_FRAGMENT_BEFORE_FOG: this.CustomParts.Fragment_Before_Fog,\r\n };\r\n }\r\n\r\n constructor(name: string, scene?: Scene) {\r\n super(name, scene, true);\r\n this.CustomParts = new ShaderSpecialParts();\r\n this.customShaderNameResolve = this.Builder;\r\n\r\n this.FragmentShader = Effect.ShadersStore[\"defaultPixelShader\"];\r\n this.VertexShader = Effect.ShadersStore[\"defaultVertexShader\"];\r\n\r\n CustomMaterial.ShaderIndexer++;\r\n this._createdShaderName = \"custom_\" + CustomMaterial.ShaderIndexer;\r\n }\r\n\r\n protected override _afterBind(mesh?: Mesh, effect: Nullable<Effect> = null, subMesh?: SubMesh): void {\r\n if (!effect) {\r\n return;\r\n }\r\n this.AttachAfterBind(mesh, effect);\r\n try {\r\n super._afterBind(mesh, effect, subMesh);\r\n } catch (e) {}\r\n }\r\n\r\n /**\r\n * Adds a new uniform to the shader\r\n * @param name the name of the uniform to add\r\n * @param kind the type of the uniform to add\r\n * @param param the value of the uniform to add\r\n * @returns the current material\r\n */\r\n public AddUniform(name: string, kind: string, param: any): CustomMaterial {\r\n if (!this._customUniform) {\r\n this._customUniform = new Array();\r\n this._newUniforms = new Array();\r\n this._newSamplerInstances = {};\r\n this._newUniformInstances = {};\r\n }\r\n if (param) {\r\n if (kind.indexOf(\"sampler\") != -1) {\r\n (<any>this._newSamplerInstances)[kind + \"-\" + name] = param;\r\n } else {\r\n (<any>this._newUniformInstances)[kind + \"-\" + name] = param;\r\n }\r\n }\r\n this._customUniform.push(\"uniform \" + kind + \" \" + name + \";\");\r\n this._newUniforms.push(name);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a custom attribute\r\n * @param name the name of the attribute\r\n * @returns the current material\r\n */\r\n public AddAttribute(name: string): CustomMaterial {\r\n if (!this._customAttributes) {\r\n this._customAttributes = [];\r\n }\r\n\r\n this._customAttributes.push(name);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Fragment_Begin portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Fragment_Begin(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_Begin = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Fragment_Definitions portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Fragment_Definitions(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_Definitions = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Fragment_MainBegin portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Fragment_MainBegin(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_MainBegin = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Fragment_MainEnd portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Fragment_MainEnd(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_MainEnd = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Fragment_Custom_Diffuse portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_Custom_Diffuse = shaderPart.replace(\"result\", \"diffuseColor\");\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Fragment_Custom_Alpha portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Fragment_Custom_Alpha(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_Custom_Alpha = shaderPart.replace(\"result\", \"alpha\");\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Fragment_Before_Lights portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Fragment_Before_Lights(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_Before_Lights = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Fragment_Before_Fog portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Fragment_Before_Fog(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_Before_Fog = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Fragment_Before_FragColor portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Fragment_Before_FragColor(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_Before_FragColor = shaderPart.replace(\"result\", \"color\");\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Vertex_Begin portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Vertex_Begin(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Vertex_Begin = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Vertex_Definitions portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Vertex_Definitions(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Vertex_Definitions = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Vertex_MainBegin portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Vertex_MainBegin(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Vertex_MainBegin = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Vertex_Before_PositionUpdated portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Vertex_Before_PositionUpdated = shaderPart.replace(\"result\", \"positionUpdated\");\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Vertex_Before_NormalUpdated portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Vertex_Before_NormalUpdated = shaderPart.replace(\"result\", \"normalUpdated\");\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Vertex_After_WorldPosComputed portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Vertex_After_WorldPosComputed = shaderPart;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the code on Vertex_MainEnd portion\r\n * @param shaderPart the code string\r\n * @returns the current material\r\n */\r\n public Vertex_MainEnd(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Vertex_MainEnd = shaderPart;\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.CustomMaterial\", CustomMaterial);\r\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babylonjs/materials",
|
3
|
-
"version": "7.21.
|
3
|
+
"version": "7.21.1",
|
4
4
|
"main": "index.js",
|
5
5
|
"module": "index.js",
|
6
6
|
"types": "index.d.ts",
|
@@ -18,7 +18,7 @@
|
|
18
18
|
"postcompile": "build-tools -c add-js-to-es6"
|
19
19
|
},
|
20
20
|
"devDependencies": {
|
21
|
-
"@babylonjs/core": "^7.21.
|
21
|
+
"@babylonjs/core": "^7.21.1",
|
22
22
|
"@dev/build-tools": "^1.0.0",
|
23
23
|
"@lts/materials": "^1.0.0"
|
24
24
|
},
|