@onerjs/materials 8.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cell/cell.fragment.d.ts +19 -0
- package/cell/cell.fragment.js +100 -0
- package/cell/cell.fragment.js.map +1 -0
- package/cell/cell.vertex.d.ts +21 -0
- package/cell/cell.vertex.js +96 -0
- package/cell/cell.vertex.js.map +1 -0
- package/cell/cellMaterial.d.ts +37 -0
- package/cell/cellMaterial.js +312 -0
- package/cell/cellMaterial.js.map +1 -0
- package/cell/index.d.ts +1 -0
- package/cell/index.js +2 -0
- package/cell/index.js.map +1 -0
- package/custom/customMaterial.d.ts +280 -0
- package/custom/customMaterial.js +355 -0
- package/custom/customMaterial.js.map +1 -0
- package/custom/index.d.ts +2 -0
- package/custom/index.js +3 -0
- package/custom/index.js.map +1 -0
- package/custom/pbrCustomMaterial.d.ts +299 -0
- package/custom/pbrCustomMaterial.js +397 -0
- package/custom/pbrCustomMaterial.js.map +1 -0
- package/fire/fire.fragment.d.ts +13 -0
- package/fire/fire.fragment.js +65 -0
- package/fire/fire.fragment.js.map +1 -0
- package/fire/fire.vertex.d.ts +18 -0
- package/fire/fire.vertex.js +80 -0
- package/fire/fire.vertex.js.map +1 -0
- package/fire/fireMaterial.d.ts +38 -0
- package/fire/fireMaterial.js +342 -0
- package/fire/fireMaterial.js.map +1 -0
- package/fire/index.d.ts +1 -0
- package/fire/index.js +2 -0
- package/fire/index.js.map +1 -0
- package/fur/fur.fragment.d.ts +19 -0
- package/fur/fur.fragment.js +94 -0
- package/fur/fur.fragment.js.map +1 -0
- package/fur/fur.vertex.d.ts +21 -0
- package/fur/fur.vertex.js +126 -0
- package/fur/fur.vertex.js.map +1 -0
- package/fur/furMaterial.d.ts +57 -0
- package/fur/furMaterial.js +505 -0
- package/fur/furMaterial.js.map +1 -0
- package/fur/index.d.ts +1 -0
- package/fur/index.js +2 -0
- package/fur/index.js.map +1 -0
- package/gradient/gradient.fragment.d.ts +19 -0
- package/gradient/gradient.fragment.js +80 -0
- package/gradient/gradient.fragment.js.map +1 -0
- package/gradient/gradient.vertex.d.ts +21 -0
- package/gradient/gradient.vertex.js +87 -0
- package/gradient/gradient.vertex.js.map +1 -0
- package/gradient/gradientMaterial.d.ts +37 -0
- package/gradient/gradientMaterial.js +283 -0
- package/gradient/gradientMaterial.js.map +1 -0
- package/gradient/index.d.ts +1 -0
- package/gradient/index.js +2 -0
- package/gradient/index.js.map +1 -0
- package/grid/grid.fragment.d.ts +12 -0
- package/grid/grid.fragment.js +79 -0
- package/grid/grid.fragment.js.map +1 -0
- package/grid/grid.vertex.d.ts +15 -0
- package/grid/grid.vertex.js +60 -0
- package/grid/grid.vertex.js.map +1 -0
- package/grid/gridMaterial.d.ts +85 -0
- package/grid/gridMaterial.js +308 -0
- package/grid/gridMaterial.js.map +1 -0
- package/grid/index.d.ts +1 -0
- package/grid/index.js +2 -0
- package/grid/index.js.map +1 -0
- package/index.d.ts +15 -0
- package/index.js +17 -0
- package/index.js.map +1 -0
- package/lava/index.d.ts +1 -0
- package/lava/index.js +2 -0
- package/lava/index.js.map +1 -0
- package/lava/lava.fragment.d.ts +19 -0
- package/lava/lava.fragment.js +89 -0
- package/lava/lava.fragment.js.map +1 -0
- package/lava/lava.vertex.d.ts +21 -0
- package/lava/lava.vertex.js +113 -0
- package/lava/lava.vertex.js.map +1 -0
- package/lava/lavaMaterial.d.ts +45 -0
- package/lava/lavaMaterial.js +402 -0
- package/lava/lavaMaterial.js.map +1 -0
- package/legacy/legacy-cell.d.ts +1 -0
- package/legacy/legacy-cell.js +14 -0
- package/legacy/legacy-cell.js.map +1 -0
- package/legacy/legacy-custom.d.ts +1 -0
- package/legacy/legacy-custom.js +14 -0
- package/legacy/legacy-custom.js.map +1 -0
- package/legacy/legacy-fire.d.ts +1 -0
- package/legacy/legacy-fire.js +14 -0
- package/legacy/legacy-fire.js.map +1 -0
- package/legacy/legacy-fur.d.ts +1 -0
- package/legacy/legacy-fur.js +14 -0
- package/legacy/legacy-fur.js.map +1 -0
- package/legacy/legacy-gradient.d.ts +1 -0
- package/legacy/legacy-gradient.js +14 -0
- package/legacy/legacy-gradient.js.map +1 -0
- package/legacy/legacy-grid.d.ts +1 -0
- package/legacy/legacy-grid.js +14 -0
- package/legacy/legacy-grid.js.map +1 -0
- package/legacy/legacy-lava.d.ts +1 -0
- package/legacy/legacy-lava.js +14 -0
- package/legacy/legacy-lava.js.map +1 -0
- package/legacy/legacy-mix.d.ts +1 -0
- package/legacy/legacy-mix.js +14 -0
- package/legacy/legacy-mix.js.map +1 -0
- package/legacy/legacy-normal.d.ts +1 -0
- package/legacy/legacy-normal.js +14 -0
- package/legacy/legacy-normal.js.map +1 -0
- package/legacy/legacy-shadowOnly.d.ts +1 -0
- package/legacy/legacy-shadowOnly.js +14 -0
- package/legacy/legacy-shadowOnly.js.map +1 -0
- package/legacy/legacy-simple.d.ts +1 -0
- package/legacy/legacy-simple.js +14 -0
- package/legacy/legacy-simple.js.map +1 -0
- package/legacy/legacy-sky.d.ts +1 -0
- package/legacy/legacy-sky.js +14 -0
- package/legacy/legacy-sky.js.map +1 -0
- package/legacy/legacy-terrain.d.ts +1 -0
- package/legacy/legacy-terrain.js +14 -0
- package/legacy/legacy-terrain.js.map +1 -0
- package/legacy/legacy-triPlanar.d.ts +1 -0
- package/legacy/legacy-triPlanar.js +14 -0
- package/legacy/legacy-triPlanar.js.map +1 -0
- package/legacy/legacy-water.d.ts +1 -0
- package/legacy/legacy-water.js +14 -0
- package/legacy/legacy-water.js.map +1 -0
- package/legacy/legacy.d.ts +1 -0
- package/legacy/legacy.js +17 -0
- package/legacy/legacy.js.map +1 -0
- package/license.md +71 -0
- package/mix/index.d.ts +1 -0
- package/mix/index.js +2 -0
- package/mix/index.js.map +1 -0
- package/mix/mix.fragment.d.ts +19 -0
- package/mix/mix.fragment.js +106 -0
- package/mix/mix.fragment.js.map +1 -0
- package/mix/mix.vertex.d.ts +21 -0
- package/mix/mix.vertex.js +96 -0
- package/mix/mix.vertex.js.map +1 -0
- package/mix/mixMaterial.d.ts +65 -0
- package/mix/mixMaterial.js +508 -0
- package/mix/mixMaterial.js.map +1 -0
- package/normal/index.d.ts +1 -0
- package/normal/index.js +2 -0
- package/normal/index.js.map +1 -0
- package/normal/normal.fragment.d.ts +19 -0
- package/normal/normal.fragment.js +85 -0
- package/normal/normal.fragment.js.map +1 -0
- package/normal/normal.vertex.d.ts +20 -0
- package/normal/normal.vertex.js +88 -0
- package/normal/normal.vertex.js.map +1 -0
- package/normal/normalMaterial.d.ts +36 -0
- package/normal/normalMaterial.js +345 -0
- package/normal/normalMaterial.js.map +1 -0
- package/package.json +47 -0
- package/readme.md +30 -0
- package/shadowOnly/index.d.ts +1 -0
- package/shadowOnly/index.js +2 -0
- package/shadowOnly/index.js.map +1 -0
- package/shadowOnly/shadowOnly.fragment.d.ts +20 -0
- package/shadowOnly/shadowOnly.fragment.js +60 -0
- package/shadowOnly/shadowOnly.fragment.js.map +1 -0
- package/shadowOnly/shadowOnly.vertex.d.ts +22 -0
- package/shadowOnly/shadowOnly.vertex.js +69 -0
- package/shadowOnly/shadowOnly.vertex.js.map +1 -0
- package/shadowOnly/shadowOnlyMaterial.d.ts +30 -0
- package/shadowOnly/shadowOnlyMaterial.js +243 -0
- package/shadowOnly/shadowOnlyMaterial.js.map +1 -0
- package/simple/index.d.ts +1 -0
- package/simple/index.js +2 -0
- package/simple/index.js.map +1 -0
- package/simple/simple.fragment.d.ts +19 -0
- package/simple/simple.fragment.js +81 -0
- package/simple/simple.fragment.js.map +1 -0
- package/simple/simple.vertex.d.ts +21 -0
- package/simple/simple.vertex.js +96 -0
- package/simple/simple.vertex.js.map +1 -0
- package/simple/simpleMaterial.d.ts +35 -0
- package/simple/simpleMaterial.js +303 -0
- package/simple/simpleMaterial.js.map +1 -0
- package/sky/index.d.ts +1 -0
- package/sky/index.js +2 -0
- package/sky/index.js.map +1 -0
- package/sky/sky.fragment.d.ts +13 -0
- package/sky/sky.fragment.js +81 -0
- package/sky/sky.fragment.js.map +1 -0
- package/sky/sky.vertex.d.ts +11 -0
- package/sky/sky.vertex.js +47 -0
- package/sky/sky.vertex.js.map +1 -0
- package/sky/skyMaterial.d.ts +151 -0
- package/sky/skyMaterial.js +367 -0
- package/sky/skyMaterial.js.map +1 -0
- package/terrain/index.d.ts +1 -0
- package/terrain/index.js +2 -0
- package/terrain/index.js.map +1 -0
- package/terrain/terrain.fragment.d.ts +19 -0
- package/terrain/terrain.fragment.js +110 -0
- package/terrain/terrain.fragment.js.map +1 -0
- package/terrain/terrain.vertex.d.ts +21 -0
- package/terrain/terrain.vertex.js +96 -0
- package/terrain/terrain.vertex.js.map +1 -0
- package/terrain/terrainMaterial.d.ts +50 -0
- package/terrain/terrainMaterial.js +445 -0
- package/terrain/terrainMaterial.js.map +1 -0
- package/triPlanar/index.d.ts +1 -0
- package/triPlanar/index.js +2 -0
- package/triPlanar/index.js.map +1 -0
- package/triPlanar/triPlanarMaterial.d.ts +49 -0
- package/triPlanar/triPlanarMaterial.js +421 -0
- package/triPlanar/triPlanarMaterial.js.map +1 -0
- package/triPlanar/triplanar.fragment.d.ts +19 -0
- package/triPlanar/triplanar.fragment.js +126 -0
- package/triPlanar/triplanar.fragment.js.map +1 -0
- package/triPlanar/triplanar.vertex.d.ts +22 -0
- package/triPlanar/triplanar.vertex.js +101 -0
- package/triPlanar/triplanar.vertex.js.map +1 -0
- package/water/index.d.ts +1 -0
- package/water/index.js +2 -0
- package/water/index.js.map +1 -0
- package/water/water.fragment.d.ts +19 -0
- package/water/water.fragment.js +160 -0
- package/water/water.fragment.js.map +1 -0
- package/water/water.vertex.d.ts +21 -0
- package/water/water.vertex.js +125 -0
- package/water/water.vertex.js.map +1 -0
- package/water/waterMaterial.d.ts +141 -0
- package/water/waterMaterial.js +729 -0
- package/water/waterMaterial.js.map +1 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import type { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
|
|
2
|
+
import { Effect } from "@babylonjs/core/Materials/effect.js";
|
|
3
|
+
import type { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
|
|
4
|
+
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
|
|
5
|
+
import type { Mesh } from "@babylonjs/core/Meshes/mesh.js";
|
|
6
|
+
import type { Scene } from "@babylonjs/core/scene.js";
|
|
7
|
+
import type { ICustomShaderNameResolveOptions } from "@babylonjs/core/Materials/material.js";
|
|
8
|
+
import type { Nullable } from "@babylonjs/core/types.js";
|
|
9
|
+
import type { SubMesh } from "@babylonjs/core/Meshes/subMesh.js";
|
|
10
|
+
import "@babylonjs/core/Shaders/pbr.vertex.js";
|
|
11
|
+
import "@babylonjs/core/Shaders/pbr.fragment.js";
|
|
12
|
+
/**
|
|
13
|
+
* Albedo parts of the shader
|
|
14
|
+
*/
|
|
15
|
+
export declare class ShaderAlbedoParts {
|
|
16
|
+
constructor();
|
|
17
|
+
/**
|
|
18
|
+
* Beginning of the fragment shader
|
|
19
|
+
*/
|
|
20
|
+
Fragment_Begin: string;
|
|
21
|
+
/**
|
|
22
|
+
* Fragment definitions
|
|
23
|
+
*/
|
|
24
|
+
Fragment_Definitions: string;
|
|
25
|
+
/**
|
|
26
|
+
* Beginning of the main function
|
|
27
|
+
*/
|
|
28
|
+
Fragment_MainBegin: string;
|
|
29
|
+
/**
|
|
30
|
+
* End of main function
|
|
31
|
+
*/
|
|
32
|
+
Fragment_MainEnd: string;
|
|
33
|
+
/**
|
|
34
|
+
* Albedo color
|
|
35
|
+
*/
|
|
36
|
+
Fragment_Custom_Albedo: string;
|
|
37
|
+
/**
|
|
38
|
+
* Lights
|
|
39
|
+
*/
|
|
40
|
+
Fragment_Before_Lights: string;
|
|
41
|
+
/**
|
|
42
|
+
* Metallic and roughness
|
|
43
|
+
*/
|
|
44
|
+
Fragment_Custom_MetallicRoughness: string;
|
|
45
|
+
/**
|
|
46
|
+
* Microsurface
|
|
47
|
+
*/
|
|
48
|
+
Fragment_Custom_MicroSurface: string;
|
|
49
|
+
/**
|
|
50
|
+
* Fog computations
|
|
51
|
+
*/
|
|
52
|
+
Fragment_Before_Fog: string;
|
|
53
|
+
/**
|
|
54
|
+
* Alpha
|
|
55
|
+
*/
|
|
56
|
+
Fragment_Custom_Alpha: string;
|
|
57
|
+
/**
|
|
58
|
+
* Color composition
|
|
59
|
+
*/
|
|
60
|
+
Fragment_Before_FinalColorComposition: string;
|
|
61
|
+
/**
|
|
62
|
+
* Fragment color
|
|
63
|
+
*/
|
|
64
|
+
Fragment_Before_FragColor: string;
|
|
65
|
+
/**
|
|
66
|
+
* Beginning of vertex shader
|
|
67
|
+
*/
|
|
68
|
+
Vertex_Begin: string;
|
|
69
|
+
/**
|
|
70
|
+
* Vertex definitions
|
|
71
|
+
*/
|
|
72
|
+
Vertex_Definitions: string;
|
|
73
|
+
/**
|
|
74
|
+
* Vertex main begin
|
|
75
|
+
*/
|
|
76
|
+
Vertex_MainBegin: string;
|
|
77
|
+
/**
|
|
78
|
+
* Vertex before position updated
|
|
79
|
+
*/
|
|
80
|
+
Vertex_Before_PositionUpdated: string;
|
|
81
|
+
/**
|
|
82
|
+
* Vertex before normal updated
|
|
83
|
+
*/
|
|
84
|
+
Vertex_Before_NormalUpdated: string;
|
|
85
|
+
/**
|
|
86
|
+
* Vertex after world pos computed
|
|
87
|
+
*/
|
|
88
|
+
Vertex_After_WorldPosComputed: string;
|
|
89
|
+
/**
|
|
90
|
+
* Vertex main end
|
|
91
|
+
*/
|
|
92
|
+
Vertex_MainEnd: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @deprecated use ShaderAlbedoParts instead.
|
|
96
|
+
*/
|
|
97
|
+
export declare const ShaderAlebdoParts: typeof ShaderAlbedoParts;
|
|
98
|
+
export declare class PBRCustomMaterial extends PBRMaterial {
|
|
99
|
+
/**
|
|
100
|
+
* Index for each created shader
|
|
101
|
+
*/
|
|
102
|
+
static ShaderIndexer: number;
|
|
103
|
+
/**
|
|
104
|
+
* Custom shader structure
|
|
105
|
+
*/
|
|
106
|
+
CustomParts: ShaderAlbedoParts;
|
|
107
|
+
/**
|
|
108
|
+
* Name of the shader
|
|
109
|
+
*/
|
|
110
|
+
_createdShaderName: string;
|
|
111
|
+
/**
|
|
112
|
+
* List of custom uniforms
|
|
113
|
+
*/
|
|
114
|
+
_customUniform: string[];
|
|
115
|
+
/**
|
|
116
|
+
* Names of the new uniforms
|
|
117
|
+
*/
|
|
118
|
+
_newUniforms: string[];
|
|
119
|
+
/**
|
|
120
|
+
* Instances of the new uniform objects
|
|
121
|
+
*/
|
|
122
|
+
_newUniformInstances: {
|
|
123
|
+
[name: string]: any;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Instances of the new sampler objects
|
|
127
|
+
*/
|
|
128
|
+
_newSamplerInstances: {
|
|
129
|
+
[name: string]: Texture;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* List of the custom attributes
|
|
133
|
+
*/
|
|
134
|
+
_customAttributes: string[];
|
|
135
|
+
/**
|
|
136
|
+
* Fragment shader string
|
|
137
|
+
*/
|
|
138
|
+
FragmentShader: string;
|
|
139
|
+
/**
|
|
140
|
+
* Vertex shader string
|
|
141
|
+
*/
|
|
142
|
+
VertexShader: string;
|
|
143
|
+
/**
|
|
144
|
+
* Runs after the material is bound to a mesh
|
|
145
|
+
* @param mesh mesh bound
|
|
146
|
+
* @param effect bound effect used to render
|
|
147
|
+
*/
|
|
148
|
+
AttachAfterBind(mesh: Mesh | undefined, effect: Effect): void;
|
|
149
|
+
/**
|
|
150
|
+
* @internal
|
|
151
|
+
*/
|
|
152
|
+
ReviewUniform(name: string, arr: string[]): string[];
|
|
153
|
+
/**
|
|
154
|
+
* Builds the material
|
|
155
|
+
* @param shaderName name of the shader
|
|
156
|
+
* @param uniforms list of uniforms
|
|
157
|
+
* @param uniformBuffers list of uniform buffers
|
|
158
|
+
* @param samplers list of samplers
|
|
159
|
+
* @param defines list of defines
|
|
160
|
+
* @param attributes list of attributes
|
|
161
|
+
* @param options options to compile the shader
|
|
162
|
+
* @returns the shader name
|
|
163
|
+
*/
|
|
164
|
+
Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions): string;
|
|
165
|
+
protected _injectCustomCode(code: string, shaderType: string): string;
|
|
166
|
+
protected _getCustomCode(shaderType: string): {
|
|
167
|
+
[pointName: string]: string;
|
|
168
|
+
};
|
|
169
|
+
constructor(name: string, scene?: Scene);
|
|
170
|
+
protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>, subMesh?: SubMesh): void;
|
|
171
|
+
/**
|
|
172
|
+
* Adds a new uniform to the shader
|
|
173
|
+
* @param name the name of the uniform to add
|
|
174
|
+
* @param kind the type of the uniform to add
|
|
175
|
+
* @param param the value of the uniform to add
|
|
176
|
+
* @returns the current material
|
|
177
|
+
*/
|
|
178
|
+
AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
|
|
179
|
+
/**
|
|
180
|
+
* Adds a custom attribute
|
|
181
|
+
* @param name the name of the attribute
|
|
182
|
+
* @returns the current material
|
|
183
|
+
*/
|
|
184
|
+
AddAttribute(name: string): PBRCustomMaterial;
|
|
185
|
+
/**
|
|
186
|
+
* Sets the code on Fragment_Begin portion
|
|
187
|
+
* @param shaderPart the code string
|
|
188
|
+
* @returns the current material
|
|
189
|
+
*/
|
|
190
|
+
Fragment_Begin(shaderPart: string): PBRCustomMaterial;
|
|
191
|
+
/**
|
|
192
|
+
* Sets the code on Fragment_Definitions portion
|
|
193
|
+
* @param shaderPart the code string
|
|
194
|
+
* @returns the current material
|
|
195
|
+
*/
|
|
196
|
+
Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
|
|
197
|
+
/**
|
|
198
|
+
* Sets the code on Fragment_MainBegin portion
|
|
199
|
+
* @param shaderPart the code string
|
|
200
|
+
* @returns the current material
|
|
201
|
+
*/
|
|
202
|
+
Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
|
|
203
|
+
/**
|
|
204
|
+
* Sets the code on Fragment_Custom_Albedo portion
|
|
205
|
+
* @param shaderPart the code string
|
|
206
|
+
* @returns the current material
|
|
207
|
+
*/
|
|
208
|
+
Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
|
|
209
|
+
/**
|
|
210
|
+
* Sets the code on Fragment_Custom_Alpha portion
|
|
211
|
+
* @param shaderPart the code string
|
|
212
|
+
* @returns the current material
|
|
213
|
+
*/
|
|
214
|
+
Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
|
|
215
|
+
/**
|
|
216
|
+
* Sets the code on Fragment_Before_Lights portion
|
|
217
|
+
* @param shaderPart the code string
|
|
218
|
+
* @returns the current material
|
|
219
|
+
*/
|
|
220
|
+
Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
|
|
221
|
+
/**
|
|
222
|
+
* Sets the code on Fragment_Custom_MetallicRoughness portion
|
|
223
|
+
* @param shaderPart the code string
|
|
224
|
+
* @returns the current material
|
|
225
|
+
*/
|
|
226
|
+
Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
|
|
227
|
+
/**
|
|
228
|
+
* Sets the code on Fragment_Custom_MicroSurface portion
|
|
229
|
+
* @param shaderPart the code string
|
|
230
|
+
* @returns the current material
|
|
231
|
+
*/
|
|
232
|
+
Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
|
|
233
|
+
/**
|
|
234
|
+
* Sets the code on Fragment_Before_Fog portion
|
|
235
|
+
* @param shaderPart the code string
|
|
236
|
+
* @returns the current material
|
|
237
|
+
*/
|
|
238
|
+
Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
|
|
239
|
+
/**
|
|
240
|
+
* Sets the code on Fragment_Before_FinalColorComposition portion
|
|
241
|
+
* @param shaderPart the code string
|
|
242
|
+
* @returns the current material
|
|
243
|
+
*/
|
|
244
|
+
Fragment_Before_FinalColorComposition(shaderPart: string): PBRCustomMaterial;
|
|
245
|
+
/**
|
|
246
|
+
* Sets the code on Fragment_Before_FragColor portion
|
|
247
|
+
* @param shaderPart the code string
|
|
248
|
+
* @returns the current material
|
|
249
|
+
*/
|
|
250
|
+
Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
|
|
251
|
+
/**
|
|
252
|
+
* Sets the code on Fragment_MainEnd portion
|
|
253
|
+
* @param shaderPart the code string
|
|
254
|
+
* @returns the current material
|
|
255
|
+
*/
|
|
256
|
+
Fragment_MainEnd(shaderPart: string): PBRCustomMaterial;
|
|
257
|
+
/**
|
|
258
|
+
* Sets the code on Vertex_Begin portion
|
|
259
|
+
* @param shaderPart the code string
|
|
260
|
+
* @returns the current material
|
|
261
|
+
*/
|
|
262
|
+
Vertex_Begin(shaderPart: string): PBRCustomMaterial;
|
|
263
|
+
/**
|
|
264
|
+
* Sets the code on Vertex_Definitions portion
|
|
265
|
+
* @param shaderPart the code string
|
|
266
|
+
* @returns the current material
|
|
267
|
+
*/
|
|
268
|
+
Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
|
|
269
|
+
/**
|
|
270
|
+
* Sets the code on Vertex_MainBegin portion
|
|
271
|
+
* @param shaderPart the code string
|
|
272
|
+
* @returns the current material
|
|
273
|
+
*/
|
|
274
|
+
Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
|
|
275
|
+
/**
|
|
276
|
+
* Sets the code on Vertex_Before_PositionUpdated portion
|
|
277
|
+
* @param shaderPart the code string
|
|
278
|
+
* @returns the current material
|
|
279
|
+
*/
|
|
280
|
+
Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
|
|
281
|
+
/**
|
|
282
|
+
* Sets the code on Vertex_Before_NormalUpdated portion
|
|
283
|
+
* @param shaderPart the code string
|
|
284
|
+
* @returns the current material
|
|
285
|
+
*/
|
|
286
|
+
Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
|
|
287
|
+
/**
|
|
288
|
+
* Sets the code on Vertex_After_WorldPosComputed portion
|
|
289
|
+
* @param shaderPart the code string
|
|
290
|
+
* @returns the current material
|
|
291
|
+
*/
|
|
292
|
+
Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
|
|
293
|
+
/**
|
|
294
|
+
* Sets the code on Vertex_MainEnd portion
|
|
295
|
+
* @param shaderPart the code string
|
|
296
|
+
* @returns the current material
|
|
297
|
+
*/
|
|
298
|
+
Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
|
|
299
|
+
}
|
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import { Effect } from "@babylonjs/core/Materials/effect.js";
|
|
2
|
+
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
|
|
3
|
+
import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
|
|
4
|
+
import { ShaderCodeInliner } from "@babylonjs/core/Engines/Processors/shaderCodeInliner.js";
|
|
5
|
+
import { Color3, Color4 } from "@babylonjs/core/Maths/math.color.js";
|
|
6
|
+
import "@babylonjs/core/Shaders/pbr.vertex.js";
|
|
7
|
+
import "@babylonjs/core/Shaders/pbr.fragment.js";
|
|
8
|
+
/**
|
|
9
|
+
* Albedo parts of the shader
|
|
10
|
+
*/
|
|
11
|
+
export class ShaderAlbedoParts {
|
|
12
|
+
constructor() { }
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated use ShaderAlbedoParts instead.
|
|
16
|
+
*/
|
|
17
|
+
export const ShaderAlebdoParts = ShaderAlbedoParts;
|
|
18
|
+
export class PBRCustomMaterial extends PBRMaterial {
|
|
19
|
+
/**
|
|
20
|
+
* Runs after the material is bound to a mesh
|
|
21
|
+
* @param mesh mesh bound
|
|
22
|
+
* @param effect bound effect used to render
|
|
23
|
+
*/
|
|
24
|
+
AttachAfterBind(mesh, effect) {
|
|
25
|
+
if (this._newUniformInstances) {
|
|
26
|
+
for (const el in this._newUniformInstances) {
|
|
27
|
+
const ea = el.toString().split("-");
|
|
28
|
+
if (ea[0] == "vec2") {
|
|
29
|
+
effect.setVector2(ea[1], this._newUniformInstances[el]);
|
|
30
|
+
}
|
|
31
|
+
else if (ea[0] == "vec3") {
|
|
32
|
+
if (this._newUniformInstances[el] instanceof Color3) {
|
|
33
|
+
effect.setColor3(ea[1], this._newUniformInstances[el]);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
effect.setVector3(ea[1], this._newUniformInstances[el]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else if (ea[0] == "vec4") {
|
|
40
|
+
if (this._newUniformInstances[el] instanceof Color4) {
|
|
41
|
+
effect.setDirectColor4(ea[1], this._newUniformInstances[el]);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
effect.setVector4(ea[1], this._newUniformInstances[el]);
|
|
45
|
+
}
|
|
46
|
+
effect.setVector4(ea[1], this._newUniformInstances[el]);
|
|
47
|
+
}
|
|
48
|
+
else if (ea[0] == "mat4") {
|
|
49
|
+
effect.setMatrix(ea[1], this._newUniformInstances[el]);
|
|
50
|
+
}
|
|
51
|
+
else if (ea[0] == "float") {
|
|
52
|
+
effect.setFloat(ea[1], this._newUniformInstances[el]);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (this._newSamplerInstances) {
|
|
57
|
+
for (const el in this._newSamplerInstances) {
|
|
58
|
+
const ea = el.toString().split("-");
|
|
59
|
+
if (ea[0] == "sampler2D" && this._newSamplerInstances[el].isReady && this._newSamplerInstances[el].isReady()) {
|
|
60
|
+
effect.setTexture(ea[1], this._newSamplerInstances[el]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
ReviewUniform(name, arr) {
|
|
69
|
+
if (name == "uniform" && this._newUniforms) {
|
|
70
|
+
for (let ind = 0; ind < this._newUniforms.length; ind++) {
|
|
71
|
+
if (this._customUniform[ind].indexOf("sampler") == -1) {
|
|
72
|
+
arr.push(this._newUniforms[ind].replace(/\[\d*\]/g, ""));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (name == "sampler" && this._newUniforms) {
|
|
77
|
+
for (let ind = 0; ind < this._newUniforms.length; ind++) {
|
|
78
|
+
if (this._customUniform[ind].indexOf("sampler") != -1) {
|
|
79
|
+
arr.push(this._newUniforms[ind].replace(/\[\d*\]/g, ""));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return arr;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Builds the material
|
|
87
|
+
* @param shaderName name of the shader
|
|
88
|
+
* @param uniforms list of uniforms
|
|
89
|
+
* @param uniformBuffers list of uniform buffers
|
|
90
|
+
* @param samplers list of samplers
|
|
91
|
+
* @param defines list of defines
|
|
92
|
+
* @param attributes list of attributes
|
|
93
|
+
* @param options options to compile the shader
|
|
94
|
+
* @returns the shader name
|
|
95
|
+
*/
|
|
96
|
+
Builder(shaderName, uniforms, uniformBuffers, samplers, defines, attributes, options) {
|
|
97
|
+
if (options) {
|
|
98
|
+
const currentProcessing = options.processFinalCode;
|
|
99
|
+
options.processFinalCode = (type, code) => {
|
|
100
|
+
if (type === "vertex") {
|
|
101
|
+
return currentProcessing ? currentProcessing(type, code) : code;
|
|
102
|
+
}
|
|
103
|
+
const sci = new ShaderCodeInliner(code);
|
|
104
|
+
sci.inlineToken = "#define pbr_inline";
|
|
105
|
+
sci.processCode();
|
|
106
|
+
return currentProcessing ? currentProcessing(type, sci.code) : sci.code;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (attributes && this._customAttributes && this._customAttributes.length > 0) {
|
|
110
|
+
attributes.push(...this._customAttributes);
|
|
111
|
+
}
|
|
112
|
+
this.ReviewUniform("uniform", uniforms);
|
|
113
|
+
this.ReviewUniform("sampler", samplers);
|
|
114
|
+
const name = this._createdShaderName;
|
|
115
|
+
if (Effect.ShadersStore[name + "VertexShader"] && Effect.ShadersStore[name + "PixelShader"]) {
|
|
116
|
+
return name;
|
|
117
|
+
}
|
|
118
|
+
Effect.ShadersStore[name + "VertexShader"] = this._injectCustomCode(this.VertexShader, "vertex");
|
|
119
|
+
Effect.ShadersStore[name + "PixelShader"] = this._injectCustomCode(this.FragmentShader, "fragment");
|
|
120
|
+
return name;
|
|
121
|
+
}
|
|
122
|
+
_injectCustomCode(code, shaderType) {
|
|
123
|
+
const customCode = this._getCustomCode(shaderType);
|
|
124
|
+
for (const point in customCode) {
|
|
125
|
+
const injectedCode = customCode[point];
|
|
126
|
+
if (injectedCode && injectedCode.length > 0) {
|
|
127
|
+
const fullPointName = "#define " + point;
|
|
128
|
+
code = code.replace(fullPointName, "\n" + injectedCode + "\n" + fullPointName);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return code;
|
|
132
|
+
}
|
|
133
|
+
_getCustomCode(shaderType) {
|
|
134
|
+
if (shaderType === "vertex") {
|
|
135
|
+
return {
|
|
136
|
+
CUSTOM_VERTEX_BEGIN: this.CustomParts.Vertex_Begin,
|
|
137
|
+
CUSTOM_VERTEX_DEFINITIONS: (this._customUniform?.join("\n") || "") + (this.CustomParts.Vertex_Definitions || ""),
|
|
138
|
+
CUSTOM_VERTEX_MAIN_BEGIN: this.CustomParts.Vertex_MainBegin,
|
|
139
|
+
CUSTOM_VERTEX_UPDATE_POSITION: this.CustomParts.Vertex_Before_PositionUpdated,
|
|
140
|
+
CUSTOM_VERTEX_UPDATE_NORMAL: this.CustomParts.Vertex_Before_NormalUpdated,
|
|
141
|
+
CUSTOM_VERTEX_MAIN_END: this.CustomParts.Vertex_MainEnd,
|
|
142
|
+
CUSTOM_VERTEX_UPDATE_WORLDPOS: this.CustomParts.Vertex_After_WorldPosComputed,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
CUSTOM_FRAGMENT_BEGIN: this.CustomParts.Fragment_Begin,
|
|
147
|
+
CUSTOM_FRAGMENT_MAIN_BEGIN: this.CustomParts.Fragment_MainBegin,
|
|
148
|
+
CUSTOM_FRAGMENT_DEFINITIONS: (this._customUniform?.join("\n") || "") + (this.CustomParts.Fragment_Definitions || ""),
|
|
149
|
+
CUSTOM_FRAGMENT_UPDATE_ALBEDO: this.CustomParts.Fragment_Custom_Albedo,
|
|
150
|
+
CUSTOM_FRAGMENT_UPDATE_ALPHA: this.CustomParts.Fragment_Custom_Alpha,
|
|
151
|
+
CUSTOM_FRAGMENT_BEFORE_LIGHTS: this.CustomParts.Fragment_Before_Lights,
|
|
152
|
+
CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS: this.CustomParts.Fragment_Custom_MetallicRoughness,
|
|
153
|
+
CUSTOM_FRAGMENT_UPDATE_MICROSURFACE: this.CustomParts.Fragment_Custom_MicroSurface,
|
|
154
|
+
CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION: this.CustomParts.Fragment_Before_FinalColorComposition,
|
|
155
|
+
CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR: this.CustomParts.Fragment_Before_FragColor,
|
|
156
|
+
CUSTOM_FRAGMENT_MAIN_END: this.CustomParts.Fragment_MainEnd,
|
|
157
|
+
CUSTOM_FRAGMENT_BEFORE_FOG: this.CustomParts.Fragment_Before_Fog,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
constructor(name, scene) {
|
|
161
|
+
super(name, scene, true);
|
|
162
|
+
this.CustomParts = new ShaderAlbedoParts();
|
|
163
|
+
this.customShaderNameResolve = this.Builder;
|
|
164
|
+
this.FragmentShader = Effect.ShadersStore["pbrPixelShader"];
|
|
165
|
+
this.VertexShader = Effect.ShadersStore["pbrVertexShader"];
|
|
166
|
+
this.FragmentShader = this.FragmentShader.replace(/#include<pbrBlockAlbedoOpacity>/g, Effect.IncludesShadersStore["pbrBlockAlbedoOpacity"]);
|
|
167
|
+
this.FragmentShader = this.FragmentShader.replace(/#include<pbrBlockReflectivity>/g, Effect.IncludesShadersStore["pbrBlockReflectivity"]);
|
|
168
|
+
this.FragmentShader = this.FragmentShader.replace(/#include<pbrBlockFinalColorComposition>/g, Effect.IncludesShadersStore["pbrBlockFinalColorComposition"]);
|
|
169
|
+
PBRCustomMaterial.ShaderIndexer++;
|
|
170
|
+
this._createdShaderName = "custompbr_" + PBRCustomMaterial.ShaderIndexer;
|
|
171
|
+
}
|
|
172
|
+
_afterBind(mesh, effect = null, subMesh) {
|
|
173
|
+
if (!effect) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
this.AttachAfterBind(mesh, effect);
|
|
177
|
+
try {
|
|
178
|
+
super._afterBind(mesh, effect, subMesh);
|
|
179
|
+
}
|
|
180
|
+
catch (e) { }
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Adds a new uniform to the shader
|
|
184
|
+
* @param name the name of the uniform to add
|
|
185
|
+
* @param kind the type of the uniform to add
|
|
186
|
+
* @param param the value of the uniform to add
|
|
187
|
+
* @returns the current material
|
|
188
|
+
*/
|
|
189
|
+
AddUniform(name, kind, param) {
|
|
190
|
+
if (!this._customUniform) {
|
|
191
|
+
this._customUniform = [];
|
|
192
|
+
this._newUniforms = [];
|
|
193
|
+
this._newSamplerInstances = {};
|
|
194
|
+
this._newUniformInstances = {};
|
|
195
|
+
}
|
|
196
|
+
if (param) {
|
|
197
|
+
if (kind.indexOf("sampler") != -1) {
|
|
198
|
+
this._newSamplerInstances[kind + "-" + name] = param;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
this._newUniformInstances[kind + "-" + name] = param;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
this._customUniform.push("uniform " + kind + " " + name + ";");
|
|
205
|
+
this._newUniforms.push(name);
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Adds a custom attribute
|
|
210
|
+
* @param name the name of the attribute
|
|
211
|
+
* @returns the current material
|
|
212
|
+
*/
|
|
213
|
+
AddAttribute(name) {
|
|
214
|
+
if (!this._customAttributes) {
|
|
215
|
+
this._customAttributes = [];
|
|
216
|
+
}
|
|
217
|
+
this._customAttributes.push(name);
|
|
218
|
+
return this;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Sets the code on Fragment_Begin portion
|
|
222
|
+
* @param shaderPart the code string
|
|
223
|
+
* @returns the current material
|
|
224
|
+
*/
|
|
225
|
+
Fragment_Begin(shaderPart) {
|
|
226
|
+
this.CustomParts.Fragment_Begin = shaderPart;
|
|
227
|
+
return this;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Sets the code on Fragment_Definitions portion
|
|
231
|
+
* @param shaderPart the code string
|
|
232
|
+
* @returns the current material
|
|
233
|
+
*/
|
|
234
|
+
Fragment_Definitions(shaderPart) {
|
|
235
|
+
this.CustomParts.Fragment_Definitions = shaderPart;
|
|
236
|
+
return this;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Sets the code on Fragment_MainBegin portion
|
|
240
|
+
* @param shaderPart the code string
|
|
241
|
+
* @returns the current material
|
|
242
|
+
*/
|
|
243
|
+
Fragment_MainBegin(shaderPart) {
|
|
244
|
+
this.CustomParts.Fragment_MainBegin = shaderPart;
|
|
245
|
+
return this;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Sets the code on Fragment_Custom_Albedo portion
|
|
249
|
+
* @param shaderPart the code string
|
|
250
|
+
* @returns the current material
|
|
251
|
+
*/
|
|
252
|
+
Fragment_Custom_Albedo(shaderPart) {
|
|
253
|
+
this.CustomParts.Fragment_Custom_Albedo = shaderPart.replace("result", "surfaceAlbedo");
|
|
254
|
+
return this;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Sets the code on Fragment_Custom_Alpha portion
|
|
258
|
+
* @param shaderPart the code string
|
|
259
|
+
* @returns the current material
|
|
260
|
+
*/
|
|
261
|
+
Fragment_Custom_Alpha(shaderPart) {
|
|
262
|
+
this.CustomParts.Fragment_Custom_Alpha = shaderPart.replace("result", "alpha");
|
|
263
|
+
return this;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Sets the code on Fragment_Before_Lights portion
|
|
267
|
+
* @param shaderPart the code string
|
|
268
|
+
* @returns the current material
|
|
269
|
+
*/
|
|
270
|
+
Fragment_Before_Lights(shaderPart) {
|
|
271
|
+
this.CustomParts.Fragment_Before_Lights = shaderPart;
|
|
272
|
+
return this;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Sets the code on Fragment_Custom_MetallicRoughness portion
|
|
276
|
+
* @param shaderPart the code string
|
|
277
|
+
* @returns the current material
|
|
278
|
+
*/
|
|
279
|
+
Fragment_Custom_MetallicRoughness(shaderPart) {
|
|
280
|
+
this.CustomParts.Fragment_Custom_MetallicRoughness = shaderPart;
|
|
281
|
+
return this;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Sets the code on Fragment_Custom_MicroSurface portion
|
|
285
|
+
* @param shaderPart the code string
|
|
286
|
+
* @returns the current material
|
|
287
|
+
*/
|
|
288
|
+
Fragment_Custom_MicroSurface(shaderPart) {
|
|
289
|
+
this.CustomParts.Fragment_Custom_MicroSurface = shaderPart;
|
|
290
|
+
return this;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Sets the code on Fragment_Before_Fog portion
|
|
294
|
+
* @param shaderPart the code string
|
|
295
|
+
* @returns the current material
|
|
296
|
+
*/
|
|
297
|
+
Fragment_Before_Fog(shaderPart) {
|
|
298
|
+
this.CustomParts.Fragment_Before_Fog = shaderPart;
|
|
299
|
+
return this;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Sets the code on Fragment_Before_FinalColorComposition portion
|
|
303
|
+
* @param shaderPart the code string
|
|
304
|
+
* @returns the current material
|
|
305
|
+
*/
|
|
306
|
+
Fragment_Before_FinalColorComposition(shaderPart) {
|
|
307
|
+
this.CustomParts.Fragment_Before_FinalColorComposition = shaderPart;
|
|
308
|
+
return this;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Sets the code on Fragment_Before_FragColor portion
|
|
312
|
+
* @param shaderPart the code string
|
|
313
|
+
* @returns the current material
|
|
314
|
+
*/
|
|
315
|
+
Fragment_Before_FragColor(shaderPart) {
|
|
316
|
+
this.CustomParts.Fragment_Before_FragColor = shaderPart.replace("result", "color");
|
|
317
|
+
return this;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Sets the code on Fragment_MainEnd portion
|
|
321
|
+
* @param shaderPart the code string
|
|
322
|
+
* @returns the current material
|
|
323
|
+
*/
|
|
324
|
+
Fragment_MainEnd(shaderPart) {
|
|
325
|
+
this.CustomParts.Fragment_MainEnd = shaderPart;
|
|
326
|
+
return this;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Sets the code on Vertex_Begin portion
|
|
330
|
+
* @param shaderPart the code string
|
|
331
|
+
* @returns the current material
|
|
332
|
+
*/
|
|
333
|
+
Vertex_Begin(shaderPart) {
|
|
334
|
+
this.CustomParts.Vertex_Begin = shaderPart;
|
|
335
|
+
return this;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Sets the code on Vertex_Definitions portion
|
|
339
|
+
* @param shaderPart the code string
|
|
340
|
+
* @returns the current material
|
|
341
|
+
*/
|
|
342
|
+
Vertex_Definitions(shaderPart) {
|
|
343
|
+
this.CustomParts.Vertex_Definitions = shaderPart;
|
|
344
|
+
return this;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Sets the code on Vertex_MainBegin portion
|
|
348
|
+
* @param shaderPart the code string
|
|
349
|
+
* @returns the current material
|
|
350
|
+
*/
|
|
351
|
+
Vertex_MainBegin(shaderPart) {
|
|
352
|
+
this.CustomParts.Vertex_MainBegin = shaderPart;
|
|
353
|
+
return this;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Sets the code on Vertex_Before_PositionUpdated portion
|
|
357
|
+
* @param shaderPart the code string
|
|
358
|
+
* @returns the current material
|
|
359
|
+
*/
|
|
360
|
+
Vertex_Before_PositionUpdated(shaderPart) {
|
|
361
|
+
this.CustomParts.Vertex_Before_PositionUpdated = shaderPart.replace("result", "positionUpdated");
|
|
362
|
+
return this;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Sets the code on Vertex_Before_NormalUpdated portion
|
|
366
|
+
* @param shaderPart the code string
|
|
367
|
+
* @returns the current material
|
|
368
|
+
*/
|
|
369
|
+
Vertex_Before_NormalUpdated(shaderPart) {
|
|
370
|
+
this.CustomParts.Vertex_Before_NormalUpdated = shaderPart.replace("result", "normalUpdated");
|
|
371
|
+
return this;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Sets the code on Vertex_After_WorldPosComputed portion
|
|
375
|
+
* @param shaderPart the code string
|
|
376
|
+
* @returns the current material
|
|
377
|
+
*/
|
|
378
|
+
Vertex_After_WorldPosComputed(shaderPart) {
|
|
379
|
+
this.CustomParts.Vertex_After_WorldPosComputed = shaderPart;
|
|
380
|
+
return this;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Sets the code on Vertex_MainEnd portion
|
|
384
|
+
* @param shaderPart the code string
|
|
385
|
+
* @returns the current material
|
|
386
|
+
*/
|
|
387
|
+
Vertex_MainEnd(shaderPart) {
|
|
388
|
+
this.CustomParts.Vertex_MainEnd = shaderPart;
|
|
389
|
+
return this;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Index for each created shader
|
|
394
|
+
*/
|
|
395
|
+
PBRCustomMaterial.ShaderIndexer = 1;
|
|
396
|
+
RegisterClass("BABYLON.PBRCustomMaterial", PBRCustomMaterial);
|
|
397
|
+
//# sourceMappingURL=pbrCustomMaterial.js.map
|