@babylonjs/materials 6.31.0 → 6.32.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -4,6 +4,7 @@ import type { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.
|
|
4
4
|
import { StandardMaterial } from "@babylonjs/core/Materials/standardMaterial.js";
|
5
5
|
import type { Mesh } from "@babylonjs/core/Meshes/mesh.js";
|
6
6
|
import type { Scene } from "@babylonjs/core/scene.js";
|
7
|
+
import type { Nullable } from "@babylonjs/core/types.js";
|
7
8
|
export declare class CustomShaderStructure {
|
8
9
|
FragmentStore: string;
|
9
10
|
VertexStore: string;
|
@@ -31,7 +32,6 @@ export declare class ShaderSpecialParts {
|
|
31
32
|
export declare class CustomMaterial extends StandardMaterial {
|
32
33
|
static ShaderIndexer: number;
|
33
34
|
CustomParts: ShaderSpecialParts;
|
34
|
-
_isCreatedShader: boolean;
|
35
35
|
_createdShaderName: string;
|
36
36
|
_customUniform: string[];
|
37
37
|
_newUniforms: string[];
|
@@ -48,6 +48,7 @@ export declare class CustomMaterial extends StandardMaterial {
|
|
48
48
|
ReviewUniform(name: string, arr: string[]): string[];
|
49
49
|
Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]): string;
|
50
50
|
constructor(name: string, scene?: Scene);
|
51
|
+
protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
|
51
52
|
AddUniform(name: string, kind: string, param: any): CustomMaterial;
|
52
53
|
AddAttribute(name: string): CustomMaterial;
|
53
54
|
Fragment_Begin(shaderPart: string): CustomMaterial;
|
package/custom/customMaterial.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { Effect } from "@babylonjs/core/Materials/effect.js";
|
2
2
|
import { StandardMaterial } from "@babylonjs/core/Materials/standardMaterial.js";
|
3
3
|
import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
|
4
|
+
import { Color3, Color4 } from "@babylonjs/core/Maths/math.color.js";
|
4
5
|
export class CustomShaderStructure {
|
5
6
|
constructor() { }
|
6
7
|
}
|
@@ -16,9 +17,20 @@ export class CustomMaterial extends StandardMaterial {
|
|
16
17
|
effect.setVector2(ea[1], this._newUniformInstances[el]);
|
17
18
|
}
|
18
19
|
else if (ea[0] == "vec3") {
|
19
|
-
|
20
|
+
if (this._newUniformInstances[el] instanceof Color3) {
|
21
|
+
effect.setColor3(ea[1], this._newUniformInstances[el]);
|
22
|
+
}
|
23
|
+
else {
|
24
|
+
effect.setVector3(ea[1], this._newUniformInstances[el]);
|
25
|
+
}
|
20
26
|
}
|
21
27
|
else if (ea[0] == "vec4") {
|
28
|
+
if (this._newUniformInstances[el] instanceof Color4) {
|
29
|
+
effect.setDirectColor4(ea[1], this._newUniformInstances[el]);
|
30
|
+
}
|
31
|
+
else {
|
32
|
+
effect.setVector4(ea[1], this._newUniformInstances[el]);
|
33
|
+
}
|
22
34
|
effect.setVector4(ea[1], this._newUniformInstances[el]);
|
23
35
|
}
|
24
36
|
else if (ea[0] == "mat4") {
|
@@ -61,23 +73,10 @@ export class CustomMaterial extends StandardMaterial {
|
|
61
73
|
}
|
62
74
|
this.ReviewUniform("uniform", uniforms);
|
63
75
|
this.ReviewUniform("sampler", samplers);
|
64
|
-
|
65
|
-
|
76
|
+
const name = this._createdShaderName;
|
77
|
+
if (Effect.ShadersStore[name + "VertexShader"] && Effect.ShadersStore[name + "PixelShader"]) {
|
78
|
+
return name;
|
66
79
|
}
|
67
|
-
this._isCreatedShader = false;
|
68
|
-
CustomMaterial.ShaderIndexer++;
|
69
|
-
const name = "custom_" + CustomMaterial.ShaderIndexer;
|
70
|
-
const fn_afterBind = this._afterBind.bind(this);
|
71
|
-
this._afterBind = (m, e) => {
|
72
|
-
if (!e) {
|
73
|
-
return;
|
74
|
-
}
|
75
|
-
this.AttachAfterBind(m, e);
|
76
|
-
try {
|
77
|
-
fn_afterBind(m, e);
|
78
|
-
}
|
79
|
-
catch (e) { }
|
80
|
-
};
|
81
80
|
Effect.ShadersStore[name + "VertexShader"] = this.VertexShader.replace("#define CUSTOM_VERTEX_BEGIN", this.CustomParts.Vertex_Begin ? this.CustomParts.Vertex_Begin : "")
|
82
81
|
.replace("#define CUSTOM_VERTEX_DEFINITIONS", (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Vertex_Definitions ? this.CustomParts.Vertex_Definitions : ""))
|
83
82
|
.replace("#define CUSTOM_VERTEX_MAIN_BEGIN", this.CustomParts.Vertex_MainBegin ? this.CustomParts.Vertex_MainBegin : "")
|
@@ -98,8 +97,6 @@ export class CustomMaterial extends StandardMaterial {
|
|
98
97
|
if (this.CustomParts.Fragment_Before_Fog) {
|
99
98
|
Effect.ShadersStore[name + "PixelShader"] = Effect.ShadersStore[name + "PixelShader"].replace("#define CUSTOM_FRAGMENT_BEFORE_FOG", this.CustomParts.Fragment_Before_Fog);
|
100
99
|
}
|
101
|
-
this._isCreatedShader = true;
|
102
|
-
this._createdShaderName = name;
|
103
100
|
return name;
|
104
101
|
}
|
105
102
|
constructor(name, scene) {
|
@@ -108,6 +105,18 @@ export class CustomMaterial extends StandardMaterial {
|
|
108
105
|
this.customShaderNameResolve = this.Builder;
|
109
106
|
this.FragmentShader = Effect.ShadersStore["defaultPixelShader"];
|
110
107
|
this.VertexShader = Effect.ShadersStore["defaultVertexShader"];
|
108
|
+
CustomMaterial.ShaderIndexer++;
|
109
|
+
this._createdShaderName = "custom_" + CustomMaterial.ShaderIndexer;
|
110
|
+
}
|
111
|
+
_afterBind(mesh, effect = null) {
|
112
|
+
if (!effect) {
|
113
|
+
return;
|
114
|
+
}
|
115
|
+
this.AttachAfterBind(mesh, effect);
|
116
|
+
try {
|
117
|
+
super._afterBind(mesh, effect);
|
118
|
+
}
|
119
|
+
catch (e) { }
|
111
120
|
}
|
112
121
|
AddUniform(name, kind, param) {
|
113
122
|
if (!this._customUniform) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"customMaterial.js","sourceRoot":"","sources":["../../../../dev/materials/src/custom/customMaterial.ts"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,CAAC,6BAA6B,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;QACjG,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,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;IAEM,6BAA6B,CAAC,UAAkB;QACnD,IAAI,CAAC,WAAW,CAAC,6BAA6B,GAAG,UAAU,CAAC;QAC5D,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,cAAc,CAAC,UAAkB;QACpC,IAAI,CAAC,WAAW,CAAC,cAAc,GAAG,UAAU,CAAC;QAC7C,OAAO,IAAI,CAAC;IAChB,CAAC;;AAvPa,4BAAa,GAAG,CAAC,CAAC;AA0PpC,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\n\r\nexport class CustomShaderStructure {\r\n public FragmentStore: string;\r\n public VertexStore: string;\r\n\r\n constructor() {}\r\n}\r\n\r\nexport class ShaderSpecialParts {\r\n constructor() {}\r\n\r\n public Fragment_Begin: string;\r\n public Fragment_Definitions: string;\r\n public Fragment_MainBegin: string;\r\n public Fragment_MainEnd: string;\r\n\r\n // diffuseColor\r\n public Fragment_Custom_Diffuse: string;\r\n // lights\r\n public Fragment_Before_Lights: string;\r\n // fog\r\n public Fragment_Before_Fog: string;\r\n // alpha\r\n public Fragment_Custom_Alpha: string;\r\n\r\n public Fragment_Before_FragColor: string;\r\n\r\n public Vertex_Begin: string;\r\n public Vertex_Definitions: string;\r\n public Vertex_MainBegin: string;\r\n\r\n // positionUpdated\r\n public Vertex_Before_PositionUpdated: string;\r\n\r\n // normalUpdated\r\n public Vertex_Before_NormalUpdated: string;\r\n\r\n // worldPosComputed\r\n public Vertex_After_WorldPosComputed: string;\r\n\r\n // mainEnd\r\n public Vertex_MainEnd: string;\r\n}\r\n\r\nexport class CustomMaterial extends StandardMaterial {\r\n public static ShaderIndexer = 1;\r\n public CustomParts: ShaderSpecialParts;\r\n _isCreatedShader: boolean;\r\n _createdShaderName: string;\r\n _customUniform: string[];\r\n _newUniforms: string[];\r\n _newUniformInstances: { [name: string]: any };\r\n _newSamplerInstances: { [name: string]: Texture };\r\n _customAttributes: string[];\r\n\r\n public FragmentShader: string;\r\n public VertexShader: string;\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 effect.setVector3(ea[1], this._newUniformInstances[el]);\r\n } else if (ea[0] == \"vec4\") {\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 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 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 if (this._isCreatedShader) {\r\n return this._createdShaderName;\r\n }\r\n this._isCreatedShader = false;\r\n\r\n CustomMaterial.ShaderIndexer++;\r\n const name: string = \"custom_\" + CustomMaterial.ShaderIndexer;\r\n\r\n const fn_afterBind = this._afterBind.bind(this);\r\n this._afterBind = (m, e) => {\r\n if (!e) {\r\n return;\r\n }\r\n this.AttachAfterBind(m, e);\r\n try {\r\n fn_afterBind(m, e);\r\n } catch (e) {}\r\n };\r\n\r\n Effect.ShadersStore[name + \"VertexShader\"] = this.VertexShader.replace(\"#define CUSTOM_VERTEX_BEGIN\", this.CustomParts.Vertex_Begin ? this.CustomParts.Vertex_Begin : \"\")\r\n .replace(\r\n \"#define CUSTOM_VERTEX_DEFINITIONS\",\r\n (this._customUniform ? this._customUniform.join(\"\\n\") : \"\") + (this.CustomParts.Vertex_Definitions ? this.CustomParts.Vertex_Definitions : \"\")\r\n )\r\n .replace(\"#define CUSTOM_VERTEX_MAIN_BEGIN\", this.CustomParts.Vertex_MainBegin ? this.CustomParts.Vertex_MainBegin : \"\")\r\n .replace(\"#define CUSTOM_VERTEX_UPDATE_POSITION\", this.CustomParts.Vertex_Before_PositionUpdated ? this.CustomParts.Vertex_Before_PositionUpdated : \"\")\r\n .replace(\"#define CUSTOM_VERTEX_UPDATE_NORMAL\", this.CustomParts.Vertex_Before_NormalUpdated ? this.CustomParts.Vertex_Before_NormalUpdated : \"\")\r\n .replace(\"#define CUSTOM_VERTEX_MAIN_END\", this.CustomParts.Vertex_MainEnd ? this.CustomParts.Vertex_MainEnd : \"\");\r\n\r\n if (this.CustomParts.Vertex_After_WorldPosComputed) {\r\n Effect.ShadersStore[name + \"VertexShader\"] = Effect.ShadersStore[name + \"VertexShader\"].replace(\r\n \"#define CUSTOM_VERTEX_UPDATE_WORLDPOS\",\r\n this.CustomParts.Vertex_After_WorldPosComputed\r\n );\r\n }\r\n\r\n Effect.ShadersStore[name + \"PixelShader\"] = this.FragmentShader.replace(\r\n \"#define CUSTOM_FRAGMENT_BEGIN\",\r\n this.CustomParts.Fragment_Begin ? this.CustomParts.Fragment_Begin : \"\"\r\n )\r\n .replace(\"#define CUSTOM_FRAGMENT_MAIN_BEGIN\", this.CustomParts.Fragment_MainBegin ? this.CustomParts.Fragment_MainBegin : \"\")\r\n .replace(\r\n \"#define CUSTOM_FRAGMENT_DEFINITIONS\",\r\n (this._customUniform ? this._customUniform.join(\"\\n\") : \"\") + (this.CustomParts.Fragment_Definitions ? this.CustomParts.Fragment_Definitions : \"\")\r\n )\r\n .replace(\"#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\", this.CustomParts.Fragment_Custom_Diffuse ? this.CustomParts.Fragment_Custom_Diffuse : \"\")\r\n .replace(\"#define CUSTOM_FRAGMENT_UPDATE_ALPHA\", this.CustomParts.Fragment_Custom_Alpha ? this.CustomParts.Fragment_Custom_Alpha : \"\")\r\n .replace(\"#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\", this.CustomParts.Fragment_Before_Lights ? this.CustomParts.Fragment_Before_Lights : \"\")\r\n .replace(\"#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\", this.CustomParts.Fragment_Before_FragColor ? this.CustomParts.Fragment_Before_FragColor : \"\")\r\n .replace(\"#define CUSTOM_FRAGMENT_MAIN_END\", this.CustomParts.Fragment_MainEnd ? this.CustomParts.Fragment_MainEnd : \"\");\r\n\r\n if (this.CustomParts.Fragment_Before_Fog) {\r\n Effect.ShadersStore[name + \"PixelShader\"] = Effect.ShadersStore[name + \"PixelShader\"].replace(\r\n \"#define CUSTOM_FRAGMENT_BEFORE_FOG\",\r\n this.CustomParts.Fragment_Before_Fog\r\n );\r\n }\r\n\r\n this._isCreatedShader = true;\r\n this._createdShaderName = name;\r\n\r\n return name;\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\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 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 public Fragment_Begin(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_Begin = shaderPart;\r\n return this;\r\n }\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 public Fragment_MainBegin(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_MainBegin = shaderPart;\r\n return this;\r\n }\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 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 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 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 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 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 public Vertex_Begin(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Vertex_Begin = shaderPart;\r\n return this;\r\n }\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 public Vertex_MainBegin(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Vertex_MainBegin = shaderPart;\r\n return this;\r\n }\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 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 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 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;AAGvD,MAAM,OAAO,qBAAqB;IAI9B,gBAAe,CAAC;CACnB;AAED,MAAM,OAAO,kBAAkB;IAC3B,gBAAe,CAAC;CAiCnB;AAED,MAAM,OAAO,cAAe,SAAQ,gBAAgB;IAazC,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,MAAM,EAAE;oBACxB,IAAI,IAAI,CAAC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,UAAU,CAAC;QAC5D,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,cAAc,CAAC,UAAkB;QACpC,IAAI,CAAC,WAAW,CAAC,cAAc,GAAG,UAAU,CAAC;QAC7C,OAAO,IAAI,CAAC;IAChB,CAAC;;AA5Pa,4BAAa,GAAG,CAAC,CAAC;AA+PpC,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\n\r\nexport class CustomShaderStructure {\r\n public FragmentStore: string;\r\n public VertexStore: string;\r\n\r\n constructor() {}\r\n}\r\n\r\nexport class ShaderSpecialParts {\r\n constructor() {}\r\n\r\n public Fragment_Begin: string;\r\n public Fragment_Definitions: string;\r\n public Fragment_MainBegin: string;\r\n public Fragment_MainEnd: string;\r\n\r\n // diffuseColor\r\n public Fragment_Custom_Diffuse: string;\r\n // lights\r\n public Fragment_Before_Lights: string;\r\n // fog\r\n public Fragment_Before_Fog: string;\r\n // alpha\r\n public Fragment_Custom_Alpha: string;\r\n\r\n public Fragment_Before_FragColor: string;\r\n\r\n public Vertex_Begin: string;\r\n public Vertex_Definitions: string;\r\n public Vertex_MainBegin: string;\r\n\r\n // positionUpdated\r\n public Vertex_Before_PositionUpdated: string;\r\n\r\n // normalUpdated\r\n public Vertex_Before_NormalUpdated: string;\r\n\r\n // worldPosComputed\r\n public Vertex_After_WorldPosComputed: string;\r\n\r\n // mainEnd\r\n public Vertex_MainEnd: string;\r\n}\r\n\r\nexport class CustomMaterial extends StandardMaterial {\r\n public static ShaderIndexer = 1;\r\n public CustomParts: ShaderSpecialParts;\r\n _createdShaderName: string;\r\n _customUniform: string[];\r\n _newUniforms: string[];\r\n _newUniformInstances: { [name: string]: any };\r\n _newSamplerInstances: { [name: string]: Texture };\r\n _customAttributes: string[];\r\n\r\n public FragmentShader: string;\r\n public VertexShader: string;\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 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 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\r\n Effect.ShadersStore[name + \"VertexShader\"] = this.VertexShader.replace(\"#define CUSTOM_VERTEX_BEGIN\", this.CustomParts.Vertex_Begin ? this.CustomParts.Vertex_Begin : \"\")\r\n .replace(\r\n \"#define CUSTOM_VERTEX_DEFINITIONS\",\r\n (this._customUniform ? this._customUniform.join(\"\\n\") : \"\") + (this.CustomParts.Vertex_Definitions ? this.CustomParts.Vertex_Definitions : \"\")\r\n )\r\n .replace(\"#define CUSTOM_VERTEX_MAIN_BEGIN\", this.CustomParts.Vertex_MainBegin ? this.CustomParts.Vertex_MainBegin : \"\")\r\n .replace(\"#define CUSTOM_VERTEX_UPDATE_POSITION\", this.CustomParts.Vertex_Before_PositionUpdated ? this.CustomParts.Vertex_Before_PositionUpdated : \"\")\r\n .replace(\"#define CUSTOM_VERTEX_UPDATE_NORMAL\", this.CustomParts.Vertex_Before_NormalUpdated ? this.CustomParts.Vertex_Before_NormalUpdated : \"\")\r\n .replace(\"#define CUSTOM_VERTEX_MAIN_END\", this.CustomParts.Vertex_MainEnd ? this.CustomParts.Vertex_MainEnd : \"\");\r\n\r\n if (this.CustomParts.Vertex_After_WorldPosComputed) {\r\n Effect.ShadersStore[name + \"VertexShader\"] = Effect.ShadersStore[name + \"VertexShader\"].replace(\r\n \"#define CUSTOM_VERTEX_UPDATE_WORLDPOS\",\r\n this.CustomParts.Vertex_After_WorldPosComputed\r\n );\r\n }\r\n\r\n Effect.ShadersStore[name + \"PixelShader\"] = this.FragmentShader.replace(\r\n \"#define CUSTOM_FRAGMENT_BEGIN\",\r\n this.CustomParts.Fragment_Begin ? this.CustomParts.Fragment_Begin : \"\"\r\n )\r\n .replace(\"#define CUSTOM_FRAGMENT_MAIN_BEGIN\", this.CustomParts.Fragment_MainBegin ? this.CustomParts.Fragment_MainBegin : \"\")\r\n .replace(\r\n \"#define CUSTOM_FRAGMENT_DEFINITIONS\",\r\n (this._customUniform ? this._customUniform.join(\"\\n\") : \"\") + (this.CustomParts.Fragment_Definitions ? this.CustomParts.Fragment_Definitions : \"\")\r\n )\r\n .replace(\"#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\", this.CustomParts.Fragment_Custom_Diffuse ? this.CustomParts.Fragment_Custom_Diffuse : \"\")\r\n .replace(\"#define CUSTOM_FRAGMENT_UPDATE_ALPHA\", this.CustomParts.Fragment_Custom_Alpha ? this.CustomParts.Fragment_Custom_Alpha : \"\")\r\n .replace(\"#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\", this.CustomParts.Fragment_Before_Lights ? this.CustomParts.Fragment_Before_Lights : \"\")\r\n .replace(\"#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\", this.CustomParts.Fragment_Before_FragColor ? this.CustomParts.Fragment_Before_FragColor : \"\")\r\n .replace(\"#define CUSTOM_FRAGMENT_MAIN_END\", this.CustomParts.Fragment_MainEnd ? this.CustomParts.Fragment_MainEnd : \"\");\r\n\r\n if (this.CustomParts.Fragment_Before_Fog) {\r\n Effect.ShadersStore[name + \"PixelShader\"] = Effect.ShadersStore[name + \"PixelShader\"].replace(\r\n \"#define CUSTOM_FRAGMENT_BEFORE_FOG\",\r\n this.CustomParts.Fragment_Before_Fog\r\n );\r\n }\r\n\r\n return name;\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 _afterBind(mesh?: Mesh, effect: Nullable<Effect> = null): 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);\r\n } catch (e) {}\r\n }\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 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 public Fragment_Begin(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_Begin = shaderPart;\r\n return this;\r\n }\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 public Fragment_MainBegin(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Fragment_MainBegin = shaderPart;\r\n return this;\r\n }\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 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 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 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 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 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 public Vertex_Begin(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Vertex_Begin = shaderPart;\r\n return this;\r\n }\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 public Vertex_MainBegin(shaderPart: string): CustomMaterial {\r\n this.CustomParts.Vertex_MainBegin = shaderPart;\r\n return this;\r\n }\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 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 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 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"]}
|
@@ -5,6 +5,7 @@ import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
|
|
5
5
|
import type { Mesh } from "@babylonjs/core/Meshes/mesh.js";
|
6
6
|
import type { Scene } from "@babylonjs/core/scene.js";
|
7
7
|
import type { ICustomShaderNameResolveOptions } from "@babylonjs/core/Materials/material.js";
|
8
|
+
import type { Nullable } from "@babylonjs/core/types.js";
|
8
9
|
export declare class ShaderAlbedoParts {
|
9
10
|
constructor();
|
10
11
|
Fragment_Begin: string;
|
@@ -34,7 +35,6 @@ export declare const ShaderAlebdoParts: typeof ShaderAlbedoParts;
|
|
34
35
|
export declare class PBRCustomMaterial extends PBRMaterial {
|
35
36
|
static ShaderIndexer: number;
|
36
37
|
CustomParts: ShaderAlbedoParts;
|
37
|
-
_isCreatedShader: boolean;
|
38
38
|
_createdShaderName: string;
|
39
39
|
_customUniform: string[];
|
40
40
|
_newUniforms: string[];
|
@@ -51,6 +51,7 @@ export declare class PBRCustomMaterial extends PBRMaterial {
|
|
51
51
|
ReviewUniform(name: string, arr: string[]): string[];
|
52
52
|
Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions): string;
|
53
53
|
constructor(name: string, scene?: Scene);
|
54
|
+
protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
|
54
55
|
AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
|
55
56
|
AddAttribute(name: string): PBRCustomMaterial;
|
56
57
|
Fragment_Begin(shaderPart: string): PBRCustomMaterial;
|
@@ -2,6 +2,7 @@ import { Effect } from "@babylonjs/core/Materials/effect.js";
|
|
2
2
|
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
|
3
3
|
import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
|
4
4
|
import { ShaderCodeInliner } from "@babylonjs/core/Engines/Processors/shaderCodeInliner.js";
|
5
|
+
import { Color3, Color4 } from "@babylonjs/core/Maths/math.color.js";
|
5
6
|
export class ShaderAlbedoParts {
|
6
7
|
constructor() { }
|
7
8
|
}
|
@@ -18,9 +19,20 @@ export class PBRCustomMaterial extends PBRMaterial {
|
|
18
19
|
effect.setVector2(ea[1], this._newUniformInstances[el]);
|
19
20
|
}
|
20
21
|
else if (ea[0] == "vec3") {
|
21
|
-
|
22
|
+
if (this._newUniformInstances[el] instanceof Color3) {
|
23
|
+
effect.setColor3(ea[1], this._newUniformInstances[el]);
|
24
|
+
}
|
25
|
+
else {
|
26
|
+
effect.setVector3(ea[1], this._newUniformInstances[el]);
|
27
|
+
}
|
22
28
|
}
|
23
29
|
else if (ea[0] == "vec4") {
|
30
|
+
if (this._newUniformInstances[el] instanceof Color4) {
|
31
|
+
effect.setDirectColor4(ea[1], this._newUniformInstances[el]);
|
32
|
+
}
|
33
|
+
else {
|
34
|
+
effect.setVector4(ea[1], this._newUniformInstances[el]);
|
35
|
+
}
|
24
36
|
effect.setVector4(ea[1], this._newUniformInstances[el]);
|
25
37
|
}
|
26
38
|
else if (ea[0] == "mat4") {
|
@@ -75,23 +87,10 @@ export class PBRCustomMaterial extends PBRMaterial {
|
|
75
87
|
}
|
76
88
|
this.ReviewUniform("uniform", uniforms);
|
77
89
|
this.ReviewUniform("sampler", samplers);
|
78
|
-
|
79
|
-
|
90
|
+
const name = this._createdShaderName;
|
91
|
+
if (Effect.ShadersStore[name + "VertexShader"] && Effect.ShadersStore[name + "PixelShader"]) {
|
92
|
+
return name;
|
80
93
|
}
|
81
|
-
this._isCreatedShader = false;
|
82
|
-
PBRCustomMaterial.ShaderIndexer++;
|
83
|
-
const name = "custom_" + PBRCustomMaterial.ShaderIndexer;
|
84
|
-
const fn_afterBind = this._afterBind.bind(this);
|
85
|
-
this._afterBind = (m, e) => {
|
86
|
-
if (!e) {
|
87
|
-
return;
|
88
|
-
}
|
89
|
-
this.AttachAfterBind(m, e);
|
90
|
-
try {
|
91
|
-
fn_afterBind(m, e);
|
92
|
-
}
|
93
|
-
catch (e) { }
|
94
|
-
};
|
95
94
|
Effect.ShadersStore[name + "VertexShader"] = this.VertexShader.replace("#define CUSTOM_VERTEX_BEGIN", this.CustomParts.Vertex_Begin ? this.CustomParts.Vertex_Begin : "")
|
96
95
|
.replace("#define CUSTOM_VERTEX_DEFINITIONS", (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Vertex_Definitions ? this.CustomParts.Vertex_Definitions : ""))
|
97
96
|
.replace("#define CUSTOM_VERTEX_MAIN_BEGIN", this.CustomParts.Vertex_MainBegin ? this.CustomParts.Vertex_MainBegin : "")
|
@@ -115,8 +114,6 @@ export class PBRCustomMaterial extends PBRMaterial {
|
|
115
114
|
if (this.CustomParts.Fragment_Before_Fog) {
|
116
115
|
Effect.ShadersStore[name + "PixelShader"] = Effect.ShadersStore[name + "PixelShader"].replace("#define CUSTOM_FRAGMENT_BEFORE_FOG", this.CustomParts.Fragment_Before_Fog);
|
117
116
|
}
|
118
|
-
this._isCreatedShader = true;
|
119
|
-
this._createdShaderName = name;
|
120
117
|
return name;
|
121
118
|
}
|
122
119
|
constructor(name, scene) {
|
@@ -128,6 +125,18 @@ export class PBRCustomMaterial extends PBRMaterial {
|
|
128
125
|
this.FragmentShader = this.FragmentShader.replace(/#include<pbrBlockAlbedoOpacity>/g, Effect.IncludesShadersStore["pbrBlockAlbedoOpacity"]);
|
129
126
|
this.FragmentShader = this.FragmentShader.replace(/#include<pbrBlockReflectivity>/g, Effect.IncludesShadersStore["pbrBlockReflectivity"]);
|
130
127
|
this.FragmentShader = this.FragmentShader.replace(/#include<pbrBlockFinalColorComposition>/g, Effect.IncludesShadersStore["pbrBlockFinalColorComposition"]);
|
128
|
+
PBRCustomMaterial.ShaderIndexer++;
|
129
|
+
this._createdShaderName = "custom_" + PBRCustomMaterial.ShaderIndexer;
|
130
|
+
}
|
131
|
+
_afterBind(mesh, effect = null) {
|
132
|
+
if (!effect) {
|
133
|
+
return;
|
134
|
+
}
|
135
|
+
this.AttachAfterBind(mesh, effect);
|
136
|
+
try {
|
137
|
+
super._afterBind(mesh, effect);
|
138
|
+
}
|
139
|
+
catch (e) { }
|
131
140
|
}
|
132
141
|
AddUniform(name, kind, param) {
|
133
142
|
if (!this._customUniform) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pbrCustomMaterial.js","sourceRoot":"","sources":["../../../../dev/materials/src/custom/pbrCustomMaterial.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAE/C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAG7D,OAAO,EAAE,aAAa,EAAE,0CAA4B;AACpD,OAAO,EAAE,iBAAiB,EAAE,gEAAkD;AAG9E,MAAM,OAAO,iBAAiB;IAC1B,gBAAe,CAAC;CAuCnB;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAEnD,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAcvC,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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AAC,CAAC;QACjG,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,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;IAEM,6BAA6B,CAAC,UAAkB;QACnD,IAAI,CAAC,WAAW,CAAC,6BAA6B,GAAG,UAAU,CAAC;QAC5D,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,cAAc,CAAC,UAAkB;QACpC,IAAI,CAAC,WAAW,CAAC,cAAc,GAAG,UAAU,CAAC;QAC7C,OAAO,IAAI,CAAC;IAChB,CAAC;;AAxSa,+BAAa,GAAG,CAAC,CAAC;AA2SpC,aAAa,CAAC,2BAA2B,EAAE,iBAAiB,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 { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { Scene } from \"core/scene\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { ShaderCodeInliner } from \"core/Engines/Processors/shaderCodeInliner\";\r\nimport type { ICustomShaderNameResolveOptions } from \"core/Materials/material\";\r\n\r\nexport class ShaderAlbedoParts {\r\n constructor() {}\r\n\r\n public Fragment_Begin: string;\r\n public Fragment_Definitions: string;\r\n public Fragment_MainBegin: string;\r\n public Fragment_MainEnd: string;\r\n\r\n // albedoColor\r\n public Fragment_Custom_Albedo: string;\r\n // lights\r\n public Fragment_Before_Lights: string;\r\n // roughness\r\n public Fragment_Custom_MetallicRoughness: string;\r\n // microsurface\r\n public Fragment_Custom_MicroSurface: string;\r\n // fog\r\n public Fragment_Before_Fog: string;\r\n // alpha\r\n public Fragment_Custom_Alpha: string;\r\n // color composition\r\n public Fragment_Before_FinalColorComposition: string;\r\n // frag color\r\n public Fragment_Before_FragColor: string;\r\n\r\n public Vertex_Begin: string;\r\n public Vertex_Definitions: string;\r\n public Vertex_MainBegin: string;\r\n\r\n // positionUpdated\r\n public Vertex_Before_PositionUpdated: string;\r\n\r\n // normalUpdated\r\n public Vertex_Before_NormalUpdated: string;\r\n\r\n // worldPosComputed\r\n public Vertex_After_WorldPosComputed: string;\r\n\r\n // mainEnd\r\n public Vertex_MainEnd: string;\r\n}\r\n\r\n/**\r\n * @deprecated use ShaderAlbedoParts instead.\r\n */\r\nexport const ShaderAlebdoParts = ShaderAlbedoParts;\r\n\r\nexport class PBRCustomMaterial extends PBRMaterial {\r\n public static ShaderIndexer = 1;\r\n public CustomParts: ShaderAlbedoParts;\r\n _isCreatedShader: boolean;\r\n _createdShaderName: string;\r\n _customUniform: string[];\r\n _newUniforms: string[];\r\n _newUniformInstances: { [name: string]: any };\r\n _newSamplerInstances: { [name: string]: Texture };\r\n _customAttributes: string[];\r\n\r\n public FragmentShader: string;\r\n public VertexShader: string;\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 effect.setVector3(ea[1], this._newUniformInstances[el]);\r\n } else if (ea[0] == \"vec4\") {\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 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 public Builder(\r\n shaderName: string,\r\n uniforms: string[],\r\n uniformBuffers: string[],\r\n samplers: string[],\r\n defines: MaterialDefines | string[],\r\n attributes?: string[],\r\n options?: ICustomShaderNameResolveOptions\r\n ): string {\r\n if (options) {\r\n const currentProcessing = options.processFinalCode;\r\n options.processFinalCode = (type: string, code: string) => {\r\n if (type === \"vertex\") {\r\n return currentProcessing ? currentProcessing(type, code) : code;\r\n }\r\n const sci = new ShaderCodeInliner(code);\r\n sci.inlineToken = \"#define pbr_inline\";\r\n sci.processCode();\r\n return currentProcessing ? currentProcessing(type, sci.code) : sci.code;\r\n };\r\n }\r\n\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 if (this._isCreatedShader) {\r\n return this._createdShaderName;\r\n }\r\n this._isCreatedShader = false;\r\n\r\n PBRCustomMaterial.ShaderIndexer++;\r\n const name: string = \"custom_\" + PBRCustomMaterial.ShaderIndexer;\r\n\r\n const fn_afterBind = this._afterBind.bind(this);\r\n this._afterBind = (m, e) => {\r\n if (!e) {\r\n return;\r\n }\r\n this.AttachAfterBind(m, e);\r\n try {\r\n fn_afterBind(m, e);\r\n } catch (e) {}\r\n };\r\n\r\n Effect.ShadersStore[name + \"VertexShader\"] = this.VertexShader.replace(\"#define CUSTOM_VERTEX_BEGIN\", this.CustomParts.Vertex_Begin ? this.CustomParts.Vertex_Begin : \"\")\r\n .replace(\r\n \"#define CUSTOM_VERTEX_DEFINITIONS\",\r\n (this._customUniform ? this._customUniform.join(\"\\n\") : \"\") + (this.CustomParts.Vertex_Definitions ? this.CustomParts.Vertex_Definitions : \"\")\r\n )\r\n .replace(\"#define CUSTOM_VERTEX_MAIN_BEGIN\", this.CustomParts.Vertex_MainBegin ? this.CustomParts.Vertex_MainBegin : \"\")\r\n .replace(\"#define CUSTOM_VERTEX_UPDATE_POSITION\", this.CustomParts.Vertex_Before_PositionUpdated ? this.CustomParts.Vertex_Before_PositionUpdated : \"\")\r\n .replace(\"#define CUSTOM_VERTEX_UPDATE_NORMAL\", this.CustomParts.Vertex_Before_NormalUpdated ? this.CustomParts.Vertex_Before_NormalUpdated : \"\")\r\n .replace(\"#define CUSTOM_VERTEX_MAIN_END\", this.CustomParts.Vertex_MainEnd ? this.CustomParts.Vertex_MainEnd : \"\");\r\n\r\n if (this.CustomParts.Vertex_After_WorldPosComputed) {\r\n Effect.ShadersStore[name + \"VertexShader\"] = Effect.ShadersStore[name + \"VertexShader\"].replace(\r\n \"#define CUSTOM_VERTEX_UPDATE_WORLDPOS\",\r\n this.CustomParts.Vertex_After_WorldPosComputed\r\n );\r\n }\r\n\r\n Effect.ShadersStore[name + \"PixelShader\"] = this.FragmentShader.replace(\r\n \"#define CUSTOM_FRAGMENT_BEGIN\",\r\n this.CustomParts.Fragment_Begin ? this.CustomParts.Fragment_Begin : \"\"\r\n )\r\n .replace(\"#define CUSTOM_FRAGMENT_MAIN_BEGIN\", this.CustomParts.Fragment_MainBegin ? this.CustomParts.Fragment_MainBegin : \"\")\r\n .replace(\r\n \"#define CUSTOM_FRAGMENT_DEFINITIONS\",\r\n (this._customUniform ? this._customUniform.join(\"\\n\") : \"\") + (this.CustomParts.Fragment_Definitions ? this.CustomParts.Fragment_Definitions : \"\")\r\n )\r\n .replace(\"#define CUSTOM_FRAGMENT_UPDATE_ALBEDO\", this.CustomParts.Fragment_Custom_Albedo ? this.CustomParts.Fragment_Custom_Albedo : \"\")\r\n .replace(\"#define CUSTOM_FRAGMENT_UPDATE_ALPHA\", this.CustomParts.Fragment_Custom_Alpha ? this.CustomParts.Fragment_Custom_Alpha : \"\")\r\n .replace(\"#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\", this.CustomParts.Fragment_Before_Lights ? this.CustomParts.Fragment_Before_Lights : \"\")\r\n .replace(\r\n \"#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS\",\r\n this.CustomParts.Fragment_Custom_MetallicRoughness ? this.CustomParts.Fragment_Custom_MetallicRoughness : \"\"\r\n )\r\n .replace(\"#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE\", this.CustomParts.Fragment_Custom_MicroSurface ? this.CustomParts.Fragment_Custom_MicroSurface : \"\")\r\n .replace(\r\n \"#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION\",\r\n this.CustomParts.Fragment_Before_FinalColorComposition ? this.CustomParts.Fragment_Before_FinalColorComposition : \"\"\r\n )\r\n .replace(\"#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\", this.CustomParts.Fragment_Before_FragColor ? this.CustomParts.Fragment_Before_FragColor : \"\")\r\n .replace(\"#define CUSTOM_FRAGMENT_MAIN_END\", this.CustomParts.Fragment_MainEnd ? this.CustomParts.Fragment_MainEnd : \"\");\r\n\r\n if (this.CustomParts.Fragment_Before_Fog) {\r\n Effect.ShadersStore[name + \"PixelShader\"] = Effect.ShadersStore[name + \"PixelShader\"].replace(\r\n \"#define CUSTOM_FRAGMENT_BEFORE_FOG\",\r\n this.CustomParts.Fragment_Before_Fog\r\n );\r\n }\r\n\r\n this._isCreatedShader = true;\r\n this._createdShaderName = name;\r\n\r\n return name;\r\n }\r\n\r\n constructor(name: string, scene?: Scene) {\r\n super(name, scene);\r\n this.CustomParts = new ShaderAlbedoParts();\r\n this.customShaderNameResolve = this.Builder;\r\n\r\n this.FragmentShader = Effect.ShadersStore[\"pbrPixelShader\"];\r\n this.VertexShader = Effect.ShadersStore[\"pbrVertexShader\"];\r\n\r\n this.FragmentShader = this.FragmentShader.replace(/#include<pbrBlockAlbedoOpacity>/g, Effect.IncludesShadersStore[\"pbrBlockAlbedoOpacity\"]);\r\n this.FragmentShader = this.FragmentShader.replace(/#include<pbrBlockReflectivity>/g, Effect.IncludesShadersStore[\"pbrBlockReflectivity\"]);\r\n this.FragmentShader = this.FragmentShader.replace(/#include<pbrBlockFinalColorComposition>/g, Effect.IncludesShadersStore[\"pbrBlockFinalColorComposition\"]);\r\n }\r\n\r\n public AddUniform(name: string, kind: string, param: any): PBRCustomMaterial {\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 public AddAttribute(name: string): PBRCustomMaterial {\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 public Fragment_Begin(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Begin = shaderPart;\r\n return this;\r\n }\r\n\r\n public Fragment_Definitions(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Definitions = shaderPart;\r\n return this;\r\n }\r\n\r\n public Fragment_MainBegin(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_MainBegin = shaderPart;\r\n return this;\r\n }\r\n\r\n public Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Custom_Albedo = shaderPart.replace(\"result\", \"surfaceAlbedo\");\r\n return this;\r\n }\r\n\r\n public Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Custom_Alpha = shaderPart.replace(\"result\", \"alpha\");\r\n return this;\r\n }\r\n\r\n public Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Before_Lights = shaderPart;\r\n return this;\r\n }\r\n\r\n public Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Custom_MetallicRoughness = shaderPart;\r\n return this;\r\n }\r\n\r\n public Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Custom_MicroSurface = shaderPart;\r\n return this;\r\n }\r\n\r\n public Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Before_Fog = shaderPart;\r\n return this;\r\n }\r\n\r\n public Fragment_Before_FinalColorComposition(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Before_FinalColorComposition = shaderPart;\r\n return this;\r\n }\r\n\r\n public Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Before_FragColor = shaderPart.replace(\"result\", \"color\");\r\n return this;\r\n }\r\n\r\n public Fragment_MainEnd(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_MainEnd = shaderPart;\r\n return this;\r\n }\r\n\r\n public Vertex_Begin(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Vertex_Begin = shaderPart;\r\n return this;\r\n }\r\n\r\n public Vertex_Definitions(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Vertex_Definitions = shaderPart;\r\n return this;\r\n }\r\n\r\n public Vertex_MainBegin(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Vertex_MainBegin = shaderPart;\r\n return this;\r\n }\r\n\r\n public Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Vertex_Before_PositionUpdated = shaderPart.replace(\"result\", \"positionUpdated\");\r\n return this;\r\n }\r\n\r\n public Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Vertex_Before_NormalUpdated = shaderPart.replace(\"result\", \"normalUpdated\");\r\n return this;\r\n }\r\n\r\n public Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Vertex_After_WorldPosComputed = shaderPart;\r\n return this;\r\n }\r\n\r\n public Vertex_MainEnd(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Vertex_MainEnd = shaderPart;\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.PBRCustomMaterial\", PBRCustomMaterial);\r\n"]}
|
1
|
+
{"version":3,"file":"pbrCustomMaterial.js","sourceRoot":"","sources":["../../../../dev/materials/src/custom/pbrCustomMaterial.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAE/C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAG7D,OAAO,EAAE,aAAa,EAAE,0CAA4B;AACpD,OAAO,EAAE,iBAAiB,EAAE,gEAAkD;AAE9E,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,4CAA8B;AAGvD,MAAM,OAAO,iBAAiB;IAC1B,gBAAe,CAAC;CAuCnB;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAEnD,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAavC,eAAe,CAAC,IAAsB,EAAE,MAAc;QACzD,IAAI,IAAI,CAAC,oBAAo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,iBAAiB,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 { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { Scene } from \"core/scene\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { ShaderCodeInliner } from \"core/Engines/Processors/shaderCodeInliner\";\r\nimport type { ICustomShaderNameResolveOptions } from \"core/Materials/material\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nexport class ShaderAlbedoParts {\r\n constructor() {}\r\n\r\n public Fragment_Begin: string;\r\n public Fragment_Definitions: string;\r\n public Fragment_MainBegin: string;\r\n public Fragment_MainEnd: string;\r\n\r\n // albedoColor\r\n public Fragment_Custom_Albedo: string;\r\n // lights\r\n public Fragment_Before_Lights: string;\r\n // roughness\r\n public Fragment_Custom_MetallicRoughness: string;\r\n // microsurface\r\n public Fragment_Custom_MicroSurface: string;\r\n // fog\r\n public Fragment_Before_Fog: string;\r\n // alpha\r\n public Fragment_Custom_Alpha: string;\r\n // color composition\r\n public Fragment_Before_FinalColorComposition: string;\r\n // frag color\r\n public Fragment_Before_FragColor: string;\r\n\r\n public Vertex_Begin: string;\r\n public Vertex_Definitions: string;\r\n public Vertex_MainBegin: string;\r\n\r\n // positionUpdated\r\n public Vertex_Before_PositionUpdated: string;\r\n\r\n // normalUpdated\r\n public Vertex_Before_NormalUpdated: string;\r\n\r\n // worldPosComputed\r\n public Vertex_After_WorldPosComputed: string;\r\n\r\n // mainEnd\r\n public Vertex_MainEnd: string;\r\n}\r\n\r\n/**\r\n * @deprecated use ShaderAlbedoParts instead.\r\n */\r\nexport const ShaderAlebdoParts = ShaderAlbedoParts;\r\n\r\nexport class PBRCustomMaterial extends PBRMaterial {\r\n public static ShaderIndexer = 1;\r\n public CustomParts: ShaderAlbedoParts;\r\n _createdShaderName: string;\r\n _customUniform: string[];\r\n _newUniforms: string[];\r\n _newUniformInstances: { [name: string]: any };\r\n _newSamplerInstances: { [name: string]: Texture };\r\n _customAttributes: string[];\r\n\r\n public FragmentShader: string;\r\n public VertexShader: string;\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 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 public Builder(\r\n shaderName: string,\r\n uniforms: string[],\r\n uniformBuffers: string[],\r\n samplers: string[],\r\n defines: MaterialDefines | string[],\r\n attributes?: string[],\r\n options?: ICustomShaderNameResolveOptions\r\n ): string {\r\n if (options) {\r\n const currentProcessing = options.processFinalCode;\r\n options.processFinalCode = (type: string, code: string) => {\r\n if (type === \"vertex\") {\r\n return currentProcessing ? currentProcessing(type, code) : code;\r\n }\r\n const sci = new ShaderCodeInliner(code);\r\n sci.inlineToken = \"#define pbr_inline\";\r\n sci.processCode();\r\n return currentProcessing ? currentProcessing(type, sci.code) : sci.code;\r\n };\r\n }\r\n\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\r\n Effect.ShadersStore[name + \"VertexShader\"] = this.VertexShader.replace(\"#define CUSTOM_VERTEX_BEGIN\", this.CustomParts.Vertex_Begin ? this.CustomParts.Vertex_Begin : \"\")\r\n .replace(\r\n \"#define CUSTOM_VERTEX_DEFINITIONS\",\r\n (this._customUniform ? this._customUniform.join(\"\\n\") : \"\") + (this.CustomParts.Vertex_Definitions ? this.CustomParts.Vertex_Definitions : \"\")\r\n )\r\n .replace(\"#define CUSTOM_VERTEX_MAIN_BEGIN\", this.CustomParts.Vertex_MainBegin ? this.CustomParts.Vertex_MainBegin : \"\")\r\n .replace(\"#define CUSTOM_VERTEX_UPDATE_POSITION\", this.CustomParts.Vertex_Before_PositionUpdated ? this.CustomParts.Vertex_Before_PositionUpdated : \"\")\r\n .replace(\"#define CUSTOM_VERTEX_UPDATE_NORMAL\", this.CustomParts.Vertex_Before_NormalUpdated ? this.CustomParts.Vertex_Before_NormalUpdated : \"\")\r\n .replace(\"#define CUSTOM_VERTEX_MAIN_END\", this.CustomParts.Vertex_MainEnd ? this.CustomParts.Vertex_MainEnd : \"\");\r\n\r\n if (this.CustomParts.Vertex_After_WorldPosComputed) {\r\n Effect.ShadersStore[name + \"VertexShader\"] = Effect.ShadersStore[name + \"VertexShader\"].replace(\r\n \"#define CUSTOM_VERTEX_UPDATE_WORLDPOS\",\r\n this.CustomParts.Vertex_After_WorldPosComputed\r\n );\r\n }\r\n\r\n Effect.ShadersStore[name + \"PixelShader\"] = this.FragmentShader.replace(\r\n \"#define CUSTOM_FRAGMENT_BEGIN\",\r\n this.CustomParts.Fragment_Begin ? this.CustomParts.Fragment_Begin : \"\"\r\n )\r\n .replace(\"#define CUSTOM_FRAGMENT_MAIN_BEGIN\", this.CustomParts.Fragment_MainBegin ? this.CustomParts.Fragment_MainBegin : \"\")\r\n .replace(\r\n \"#define CUSTOM_FRAGMENT_DEFINITIONS\",\r\n (this._customUniform ? this._customUniform.join(\"\\n\") : \"\") + (this.CustomParts.Fragment_Definitions ? this.CustomParts.Fragment_Definitions : \"\")\r\n )\r\n .replace(\"#define CUSTOM_FRAGMENT_UPDATE_ALBEDO\", this.CustomParts.Fragment_Custom_Albedo ? this.CustomParts.Fragment_Custom_Albedo : \"\")\r\n .replace(\"#define CUSTOM_FRAGMENT_UPDATE_ALPHA\", this.CustomParts.Fragment_Custom_Alpha ? this.CustomParts.Fragment_Custom_Alpha : \"\")\r\n .replace(\"#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\", this.CustomParts.Fragment_Before_Lights ? this.CustomParts.Fragment_Before_Lights : \"\")\r\n .replace(\r\n \"#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS\",\r\n this.CustomParts.Fragment_Custom_MetallicRoughness ? this.CustomParts.Fragment_Custom_MetallicRoughness : \"\"\r\n )\r\n .replace(\"#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE\", this.CustomParts.Fragment_Custom_MicroSurface ? this.CustomParts.Fragment_Custom_MicroSurface : \"\")\r\n .replace(\r\n \"#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION\",\r\n this.CustomParts.Fragment_Before_FinalColorComposition ? this.CustomParts.Fragment_Before_FinalColorComposition : \"\"\r\n )\r\n .replace(\"#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\", this.CustomParts.Fragment_Before_FragColor ? this.CustomParts.Fragment_Before_FragColor : \"\")\r\n .replace(\"#define CUSTOM_FRAGMENT_MAIN_END\", this.CustomParts.Fragment_MainEnd ? this.CustomParts.Fragment_MainEnd : \"\");\r\n\r\n if (this.CustomParts.Fragment_Before_Fog) {\r\n Effect.ShadersStore[name + \"PixelShader\"] = Effect.ShadersStore[name + \"PixelShader\"].replace(\r\n \"#define CUSTOM_FRAGMENT_BEFORE_FOG\",\r\n this.CustomParts.Fragment_Before_Fog\r\n );\r\n }\r\n\r\n return name;\r\n }\r\n\r\n constructor(name: string, scene?: Scene) {\r\n super(name, scene);\r\n this.CustomParts = new ShaderAlbedoParts();\r\n this.customShaderNameResolve = this.Builder;\r\n\r\n this.FragmentShader = Effect.ShadersStore[\"pbrPixelShader\"];\r\n this.VertexShader = Effect.ShadersStore[\"pbrVertexShader\"];\r\n\r\n this.FragmentShader = this.FragmentShader.replace(/#include<pbrBlockAlbedoOpacity>/g, Effect.IncludesShadersStore[\"pbrBlockAlbedoOpacity\"]);\r\n this.FragmentShader = this.FragmentShader.replace(/#include<pbrBlockReflectivity>/g, Effect.IncludesShadersStore[\"pbrBlockReflectivity\"]);\r\n this.FragmentShader = this.FragmentShader.replace(/#include<pbrBlockFinalColorComposition>/g, Effect.IncludesShadersStore[\"pbrBlockFinalColorComposition\"]);\r\n\r\n PBRCustomMaterial.ShaderIndexer++;\r\n this._createdShaderName = \"custom_\" + PBRCustomMaterial.ShaderIndexer;\r\n }\r\n\r\n protected _afterBind(mesh?: Mesh, effect: Nullable<Effect> = null): 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);\r\n } catch (e) {}\r\n }\r\n\r\n public AddUniform(name: string, kind: string, param: any): PBRCustomMaterial {\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 public AddAttribute(name: string): PBRCustomMaterial {\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 public Fragment_Begin(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Begin = shaderPart;\r\n return this;\r\n }\r\n\r\n public Fragment_Definitions(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Definitions = shaderPart;\r\n return this;\r\n }\r\n\r\n public Fragment_MainBegin(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_MainBegin = shaderPart;\r\n return this;\r\n }\r\n\r\n public Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Custom_Albedo = shaderPart.replace(\"result\", \"surfaceAlbedo\");\r\n return this;\r\n }\r\n\r\n public Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Custom_Alpha = shaderPart.replace(\"result\", \"alpha\");\r\n return this;\r\n }\r\n\r\n public Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Before_Lights = shaderPart;\r\n return this;\r\n }\r\n\r\n public Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Custom_MetallicRoughness = shaderPart;\r\n return this;\r\n }\r\n\r\n public Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Custom_MicroSurface = shaderPart;\r\n return this;\r\n }\r\n\r\n public Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Before_Fog = shaderPart;\r\n return this;\r\n }\r\n\r\n public Fragment_Before_FinalColorComposition(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Before_FinalColorComposition = shaderPart;\r\n return this;\r\n }\r\n\r\n public Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_Before_FragColor = shaderPart.replace(\"result\", \"color\");\r\n return this;\r\n }\r\n\r\n public Fragment_MainEnd(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Fragment_MainEnd = shaderPart;\r\n return this;\r\n }\r\n\r\n public Vertex_Begin(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Vertex_Begin = shaderPart;\r\n return this;\r\n }\r\n\r\n public Vertex_Definitions(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Vertex_Definitions = shaderPart;\r\n return this;\r\n }\r\n\r\n public Vertex_MainBegin(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Vertex_MainBegin = shaderPart;\r\n return this;\r\n }\r\n\r\n public Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Vertex_Before_PositionUpdated = shaderPart.replace(\"result\", \"positionUpdated\");\r\n return this;\r\n }\r\n\r\n public Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Vertex_Before_NormalUpdated = shaderPart.replace(\"result\", \"normalUpdated\");\r\n return this;\r\n }\r\n\r\n public Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Vertex_After_WorldPosComputed = shaderPart;\r\n return this;\r\n }\r\n\r\n public Vertex_MainEnd(shaderPart: string): PBRCustomMaterial {\r\n this.CustomParts.Vertex_MainEnd = shaderPart;\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.PBRCustomMaterial\", PBRCustomMaterial);\r\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babylonjs/materials",
|
3
|
-
"version": "6.
|
3
|
+
"version": "6.32.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": "^6.
|
21
|
+
"@babylonjs/core": "^6.32.1",
|
22
22
|
"@dev/build-tools": "^1.0.0",
|
23
23
|
"@lts/materials": "^1.0.0"
|
24
24
|
},
|