@babylonjs/materials 5.0.0-beta.9 → 5.0.0-rc.10
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 +17 -17
- package/cell/cell.fragment.js +20 -18
- package/cell/cell.fragment.js.map +1 -1
- package/cell/cell.vertex.d.ts +18 -18
- package/cell/cell.vertex.js +21 -19
- package/cell/cell.vertex.js.map +1 -1
- package/cell/cellMaterial.d.ts +37 -37
- package/cell/cellMaterial.js +304 -290
- package/cell/cellMaterial.js.map +1 -1
- package/cell/index.d.ts +1 -1
- package/cell/index.js +1 -1
- package/cell/index.js.map +1 -1
- package/custom/customMaterial.d.ts +69 -69
- package/custom/customMaterial.js +216 -218
- package/custom/customMaterial.js.map +1 -1
- package/custom/index.d.ts +2 -2
- package/custom/index.js +2 -2
- package/custom/index.js.map +1 -1
- package/custom/pbrCustomMaterial.d.ts +71 -71
- package/custom/pbrCustomMaterial.js +241 -243
- package/custom/pbrCustomMaterial.js.map +1 -1
- package/fire/fire.fragment.d.ts +11 -11
- package/fire/fire.fragment.js +14 -12
- package/fire/fire.fragment.js.map +1 -1
- package/fire/fire.vertex.d.ts +15 -15
- package/fire/fire.vertex.js +18 -16
- package/fire/fire.vertex.js.map +1 -1
- package/fire/fireMaterial.d.ts +38 -38
- package/fire/fireMaterial.js +342 -327
- package/fire/fireMaterial.js.map +1 -1
- package/fire/index.d.ts +1 -1
- package/fire/index.js +1 -1
- package/fire/index.js.map +1 -1
- package/fur/fur.fragment.d.ts +17 -17
- package/fur/fur.fragment.js +20 -18
- package/fur/fur.fragment.js.map +1 -1
- package/fur/fur.vertex.d.ts +18 -18
- package/fur/fur.vertex.js +21 -19
- package/fur/fur.vertex.js.map +1 -1
- package/fur/furMaterial.d.ts +57 -56
- package/fur/furMaterial.js +500 -480
- package/fur/furMaterial.js.map +1 -1
- package/fur/index.d.ts +1 -1
- package/fur/index.js +1 -1
- package/fur/index.js.map +1 -1
- package/gradient/gradient.fragment.d.ts +17 -17
- package/gradient/gradient.fragment.js +20 -18
- package/gradient/gradient.fragment.js.map +1 -1
- package/gradient/gradient.vertex.d.ts +18 -18
- package/gradient/gradient.vertex.js +21 -19
- package/gradient/gradient.vertex.js.map +1 -1
- package/gradient/gradientMaterial.d.ts +37 -37
- package/gradient/gradientMaterial.js +275 -259
- package/gradient/gradientMaterial.js.map +1 -1
- package/gradient/index.d.ts +1 -1
- package/gradient/index.js +1 -1
- package/gradient/index.js.map +1 -1
- package/grid/grid.fragment.d.ts +8 -8
- package/grid/grid.fragment.js +11 -9
- package/grid/grid.fragment.js.map +1 -1
- package/grid/grid.vertex.d.ts +9 -9
- package/grid/grid.vertex.js +12 -10
- package/grid/grid.vertex.js.map +1 -1
- package/grid/gridMaterial.d.ts +78 -77
- package/grid/gridMaterial.js +276 -261
- package/grid/gridMaterial.js.map +1 -1
- package/grid/index.d.ts +1 -1
- package/grid/index.js +1 -1
- package/grid/index.js.map +1 -1
- package/index.d.ts +15 -15
- package/index.js +16 -15
- package/index.js.map +1 -1
- package/lava/index.d.ts +1 -1
- package/lava/index.js +1 -1
- package/lava/index.js.map +1 -1
- package/lava/lava.fragment.d.ts +17 -17
- package/lava/lava.fragment.js +20 -18
- package/lava/lava.fragment.js.map +1 -1
- package/lava/lava.vertex.d.ts +18 -18
- package/lava/lava.vertex.js +21 -19
- package/lava/lava.vertex.js.map +1 -1
- package/lava/lavaMaterial.d.ts +45 -45
- package/lava/lavaMaterial.js +394 -378
- package/lava/lavaMaterial.js.map +1 -1
- package/legacy/legacy-cell.d.ts +1 -1
- package/legacy/legacy-cell.js +13 -12
- package/legacy/legacy-cell.js.map +1 -1
- package/legacy/legacy-custom.d.ts +1 -1
- package/legacy/legacy-custom.js +13 -12
- package/legacy/legacy-custom.js.map +1 -1
- package/legacy/legacy-fire.d.ts +1 -1
- package/legacy/legacy-fire.js +13 -12
- package/legacy/legacy-fire.js.map +1 -1
- package/legacy/legacy-fur.d.ts +1 -1
- package/legacy/legacy-fur.js +13 -12
- package/legacy/legacy-fur.js.map +1 -1
- package/legacy/legacy-gradient.d.ts +1 -1
- package/legacy/legacy-gradient.js +13 -12
- package/legacy/legacy-gradient.js.map +1 -1
- package/legacy/legacy-grid.d.ts +1 -1
- package/legacy/legacy-grid.js +13 -12
- package/legacy/legacy-grid.js.map +1 -1
- package/legacy/legacy-lava.d.ts +1 -1
- package/legacy/legacy-lava.js +13 -12
- package/legacy/legacy-lava.js.map +1 -1
- package/legacy/legacy-mix.d.ts +1 -1
- package/legacy/legacy-mix.js +13 -12
- package/legacy/legacy-mix.js.map +1 -1
- package/legacy/legacy-normal.d.ts +1 -1
- package/legacy/legacy-normal.js +13 -12
- package/legacy/legacy-normal.js.map +1 -1
- package/legacy/legacy-shadowOnly.d.ts +1 -1
- package/legacy/legacy-shadowOnly.js +13 -12
- package/legacy/legacy-shadowOnly.js.map +1 -1
- package/legacy/legacy-simple.d.ts +1 -1
- package/legacy/legacy-simple.js +13 -12
- package/legacy/legacy-simple.js.map +1 -1
- package/legacy/legacy-sky.d.ts +1 -1
- package/legacy/legacy-sky.js +13 -12
- package/legacy/legacy-sky.js.map +1 -1
- package/legacy/legacy-terrain.d.ts +1 -1
- package/legacy/legacy-terrain.js +13 -12
- package/legacy/legacy-terrain.js.map +1 -1
- package/legacy/legacy-triPlanar.d.ts +1 -1
- package/legacy/legacy-triPlanar.js +13 -12
- package/legacy/legacy-triPlanar.js.map +1 -1
- package/legacy/legacy-water.d.ts +1 -1
- package/legacy/legacy-water.js +13 -12
- package/legacy/legacy-water.js.map +1 -1
- package/legacy/legacy.d.ts +1 -1
- package/legacy/legacy.js +16 -15
- package/legacy/legacy.js.map +1 -1
- package/mix/index.d.ts +1 -1
- package/mix/index.js +1 -1
- package/mix/index.js.map +1 -1
- package/mix/mix.fragment.d.ts +17 -17
- package/mix/mix.fragment.js +20 -18
- package/mix/mix.fragment.js.map +1 -1
- package/mix/mix.vertex.d.ts +18 -18
- package/mix/mix.vertex.js +21 -19
- package/mix/mix.vertex.js.map +1 -1
- package/mix/mixMaterial.d.ts +65 -65
- package/mix/mixMaterial.js +510 -483
- package/mix/mixMaterial.js.map +1 -1
- package/normal/index.d.ts +1 -1
- package/normal/index.js +1 -1
- package/normal/index.js.map +1 -1
- package/normal/normal.fragment.d.ts +17 -17
- package/normal/normal.fragment.js +20 -18
- package/normal/normal.fragment.js.map +1 -1
- package/normal/normal.vertex.d.ts +18 -18
- package/normal/normal.vertex.js +21 -19
- package/normal/normal.vertex.js.map +1 -1
- package/normal/normalMaterial.d.ts +36 -36
- package/normal/normalMaterial.js +336 -322
- package/normal/normalMaterial.js.map +1 -1
- package/package.json +22 -254
- package/readme.md +2 -2
- package/shadowOnly/index.d.ts +1 -1
- package/shadowOnly/index.js +1 -1
- package/shadowOnly/index.js.map +1 -1
- package/shadowOnly/shadowOnly.fragment.d.ts +16 -16
- package/shadowOnly/shadowOnly.fragment.js +19 -17
- package/shadowOnly/shadowOnly.fragment.js.map +1 -1
- package/shadowOnly/shadowOnly.vertex.d.ts +18 -18
- package/shadowOnly/shadowOnly.vertex.js +21 -19
- package/shadowOnly/shadowOnly.vertex.js.map +1 -1
- package/shadowOnly/shadowOnlyMaterial.d.ts +30 -30
- package/shadowOnly/shadowOnlyMaterial.js +254 -240
- package/shadowOnly/shadowOnlyMaterial.js.map +1 -1
- package/simple/index.d.ts +1 -1
- package/simple/index.js +1 -1
- package/simple/index.js.map +1 -1
- package/simple/simple.fragment.d.ts +17 -17
- package/simple/simple.fragment.js +20 -18
- package/simple/simple.fragment.js.map +1 -1
- package/simple/simple.vertex.d.ts +18 -18
- package/simple/simple.vertex.js +21 -19
- package/simple/simple.vertex.js.map +1 -1
- package/simple/simpleMaterial.d.ts +35 -35
- package/simple/simpleMaterial.js +295 -281
- package/simple/simpleMaterial.js.map +1 -1
- package/sky/index.d.ts +1 -1
- package/sky/index.js +1 -1
- package/sky/index.js.map +1 -1
- package/sky/sky.fragment.d.ts +10 -10
- package/sky/sky.fragment.js +13 -11
- package/sky/sky.fragment.js.map +1 -1
- package/sky/sky.vertex.d.ts +9 -9
- package/sky/sky.vertex.js +12 -10
- package/sky/sky.vertex.js.map +1 -1
- package/sky/skyMaterial.d.ts +147 -147
- package/sky/skyMaterial.js +359 -340
- package/sky/skyMaterial.js.map +1 -1
- package/terrain/index.d.ts +1 -1
- package/terrain/index.js +1 -1
- package/terrain/index.js.map +1 -1
- package/terrain/terrain.fragment.d.ts +17 -17
- package/terrain/terrain.fragment.js +20 -18
- package/terrain/terrain.fragment.js.map +1 -1
- package/terrain/terrain.vertex.d.ts +18 -18
- package/terrain/terrain.vertex.js +21 -19
- package/terrain/terrain.vertex.js.map +1 -1
- package/terrain/terrainMaterial.d.ts +50 -50
- package/terrain/terrainMaterial.js +426 -411
- package/terrain/terrainMaterial.js.map +1 -1
- package/triPlanar/index.d.ts +1 -1
- package/triPlanar/index.js +1 -1
- package/triPlanar/index.js.map +1 -1
- package/triPlanar/triPlanarMaterial.d.ts +49 -49
- package/triPlanar/triPlanarMaterial.js +403 -391
- package/triPlanar/triPlanarMaterial.js.map +1 -1
- package/triPlanar/triplanar.fragment.d.ts +17 -17
- package/triPlanar/triplanar.fragment.js +20 -18
- package/triPlanar/triplanar.fragment.js.map +1 -1
- package/triPlanar/triplanar.vertex.d.ts +18 -18
- package/triPlanar/triplanar.vertex.js +21 -19
- package/triPlanar/triplanar.vertex.js.map +1 -1
- package/water/index.d.ts +1 -1
- package/water/index.js +1 -1
- package/water/index.js.map +1 -1
- package/water/water.fragment.d.ts +19 -19
- package/water/water.fragment.js +22 -20
- package/water/water.fragment.js.map +1 -1
- package/water/water.vertex.d.ts +20 -20
- package/water/water.vertex.js +23 -21
- package/water/water.vertex.js.map +1 -1
- package/water/waterMaterial.d.ts +135 -132
- package/water/waterMaterial.js +736 -705
- package/water/waterMaterial.js.map +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"shadowOnly.vertex.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"shadowOnly.vertex.js","sourceRoot":"","sources":["../../../../../lts/materials/generated/shadowOnly/shadowOnly.vertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,oEAAsD;AACtD,mFAAqE;AACrE,wEAA0D;AAC1D,8EAAgE;AAChE,wEAA0D;AAC1D,4EAA8D;AAC9D,uEAAyD;AACzD,mEAAqD;AACrD,+DAAiD;AACjD,wEAA0D;AAC1D,mEAAqD;AACrD,6DAA+C;AAC/C,iEAAmD;AAEnD,IAAM,IAAI,GAAG,wBAAwB,CAAC;AACtC,IAAM,MAAM,GAAG,wmCA2Cd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,cAAc;AACd,MAAM,CAAC,IAAM,sBAAsB,GAAG,EAAE,IAAI,MAAA,EAAE,MAAM,QAAA,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"core/Shaders/ShadersInclude/bonesDeclaration\";\nimport \"core/Shaders/ShadersInclude/bakedVertexAnimationDeclaration\";\nimport \"core/Shaders/ShadersInclude/instancesDeclaration\";\nimport \"core/Shaders/ShadersInclude/clipPlaneVertexDeclaration\";\nimport \"core/Shaders/ShadersInclude/fogVertexDeclaration\";\nimport \"core/Shaders/ShadersInclude/lightFragmentDeclaration\";\nimport \"core/Shaders/ShadersInclude/lightUboDeclaration\";\nimport \"core/Shaders/ShadersInclude/instancesVertex\";\nimport \"core/Shaders/ShadersInclude/bonesVertex\";\nimport \"core/Shaders/ShadersInclude/bakedVertexAnimation\";\nimport \"core/Shaders/ShadersInclude/clipPlaneVertex\";\nimport \"core/Shaders/ShadersInclude/fogVertex\";\nimport \"core/Shaders/ShadersInclude/shadowsVertex\";\n\nconst name = \"shadowOnlyVertexShader\";\nconst shader = `precision highp float;\rattribute vec3 position;\r#ifdef NORMAL\nattribute vec3 normal;\r#endif\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;\runiform mat4 viewProjection;\r#ifdef POINTSIZE\nuniform float pointSize;\r#endif\nvarying vec3 vPositionW;\r#ifdef NORMAL\nvarying vec3 vNormalW;\r#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\r#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\r#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);\rgl_Position=viewProjection*worldPos;\rvPositionW=vec3(worldPos);\r#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\r#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\r#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\r`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @hidden */\nexport const shadowOnlyVertexShader = { name, shader };\n"]}
|
@@ -1,30 +1,30 @@
|
|
1
|
-
import { Nullable } from "@babylonjs/core/types";
|
2
|
-
import { Matrix } from "@babylonjs/core/Maths/math.vector";
|
3
|
-
import { Color3 } from "@babylonjs/core/Maths/math.color";
|
4
|
-
import { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture";
|
5
|
-
import { IShadowLight } from "@babylonjs/core/Lights/shadowLight";
|
6
|
-
import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial";
|
7
|
-
import { AbstractMesh } from "@babylonjs/core/Meshes/abstractMesh";
|
8
|
-
import { SubMesh } from "@babylonjs/core/Meshes/subMesh";
|
9
|
-
import { Mesh } from "@babylonjs/core/Meshes/mesh";
|
10
|
-
import { Scene } from "@babylonjs/core/scene";
|
11
|
-
import "./shadowOnly.fragment";
|
12
|
-
import "./shadowOnly.vertex";
|
13
|
-
export declare class ShadowOnlyMaterial extends PushMaterial {
|
14
|
-
private _activeLight;
|
15
|
-
private _needAlphaBlending;
|
16
|
-
constructor(name: string, scene?: Scene);
|
17
|
-
shadowColor: Color3;
|
18
|
-
needAlphaBlending(): boolean;
|
19
|
-
needAlphaTesting(): boolean;
|
20
|
-
getAlphaTestTexture(): Nullable<BaseTexture>;
|
21
|
-
get activeLight(): IShadowLight;
|
22
|
-
set activeLight(light: IShadowLight);
|
23
|
-
private _getFirstShadowLightForMesh;
|
24
|
-
isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
|
25
|
-
bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
|
26
|
-
clone(name: string): ShadowOnlyMaterial;
|
27
|
-
serialize(): any;
|
28
|
-
getClassName(): string;
|
29
|
-
static Parse(source: any, scene: Scene, rootUrl: string): ShadowOnlyMaterial;
|
30
|
-
}
|
1
|
+
import type { Nullable } from "@babylonjs/core/types.js";
|
2
|
+
import type { Matrix } from "@babylonjs/core/Maths/math.vector.js";
|
3
|
+
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
4
|
+
import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
|
5
|
+
import type { IShadowLight } from "@babylonjs/core/Lights/shadowLight.js";
|
6
|
+
import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
|
7
|
+
import type { AbstractMesh } from "@babylonjs/core/Meshes/abstractMesh.js";
|
8
|
+
import type { SubMesh } from "@babylonjs/core/Meshes/subMesh.js";
|
9
|
+
import type { Mesh } from "@babylonjs/core/Meshes/mesh.js";
|
10
|
+
import { Scene } from "@babylonjs/core/scene.js";
|
11
|
+
import "./shadowOnly.fragment";
|
12
|
+
import "./shadowOnly.vertex";
|
13
|
+
export declare class ShadowOnlyMaterial extends PushMaterial {
|
14
|
+
private _activeLight;
|
15
|
+
private _needAlphaBlending;
|
16
|
+
constructor(name: string, scene?: Scene);
|
17
|
+
shadowColor: Color3;
|
18
|
+
needAlphaBlending(): boolean;
|
19
|
+
needAlphaTesting(): boolean;
|
20
|
+
getAlphaTestTexture(): Nullable<BaseTexture>;
|
21
|
+
get activeLight(): IShadowLight;
|
22
|
+
set activeLight(light: IShadowLight);
|
23
|
+
private _getFirstShadowLightForMesh;
|
24
|
+
isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
|
25
|
+
bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
|
26
|
+
clone(name: string): ShadowOnlyMaterial;
|
27
|
+
serialize(): any;
|
28
|
+
getClassName(): string;
|
29
|
+
static Parse(source: any, scene: Scene, rootUrl: string): ShadowOnlyMaterial;
|
30
|
+
}
|
@@ -1,241 +1,255 @@
|
|
1
|
-
import { __extends } from "tslib";
|
2
|
-
import { SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
|
3
|
-
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
4
|
-
import { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
|
5
|
-
import { MaterialHelper } from "@babylonjs/core/Materials/materialHelper.js";
|
6
|
-
import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
|
7
|
-
import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
|
8
|
-
import { Scene } from "@babylonjs/core/scene.js";
|
9
|
-
import { RegisterClass } from
|
10
|
-
import "./shadowOnly.fragment
|
11
|
-
import "./shadowOnly.vertex
|
12
|
-
import { EffectFallbacks } from
|
13
|
-
var ShadowOnlyMaterialDefines = /** @class */ (function (_super) {
|
14
|
-
__extends(ShadowOnlyMaterialDefines, _super);
|
15
|
-
function ShadowOnlyMaterialDefines() {
|
16
|
-
var _this = _super.call(this) || this;
|
17
|
-
_this.CLIPPLANE = false;
|
18
|
-
_this.CLIPPLANE2 = false;
|
19
|
-
_this.CLIPPLANE3 = false;
|
20
|
-
_this.CLIPPLANE4 = false;
|
21
|
-
_this.CLIPPLANE5 = false;
|
22
|
-
_this.CLIPPLANE6 = false;
|
23
|
-
_this.POINTSIZE = false;
|
24
|
-
_this.FOG = false;
|
25
|
-
_this.NORMAL = false;
|
26
|
-
_this.NUM_BONE_INFLUENCERS = 0;
|
27
|
-
_this.BonesPerMesh = 0;
|
28
|
-
_this.INSTANCES = false;
|
29
|
-
_this.IMAGEPROCESSINGPOSTPROCESS = false;
|
30
|
-
_this.SKIPFINALCOLORCLAMP = false;
|
31
|
-
_this.rebuild();
|
32
|
-
return _this;
|
33
|
-
}
|
34
|
-
return ShadowOnlyMaterialDefines;
|
35
|
-
}(MaterialDefines));
|
36
|
-
var ShadowOnlyMaterial = /** @class */ (function (_super) {
|
37
|
-
__extends(ShadowOnlyMaterial, _super);
|
38
|
-
function ShadowOnlyMaterial(name, scene) {
|
39
|
-
var _this = _super.call(this, name, scene) || this;
|
40
|
-
_this._needAlphaBlending = true;
|
41
|
-
_this.shadowColor = Color3.Black();
|
42
|
-
return _this;
|
43
|
-
}
|
44
|
-
ShadowOnlyMaterial.prototype.needAlphaBlending = function () {
|
45
|
-
return this._needAlphaBlending;
|
46
|
-
};
|
47
|
-
ShadowOnlyMaterial.prototype.needAlphaTesting = function () {
|
48
|
-
return false;
|
49
|
-
};
|
50
|
-
ShadowOnlyMaterial.prototype.getAlphaTestTexture = function () {
|
51
|
-
return null;
|
52
|
-
};
|
53
|
-
Object.defineProperty(ShadowOnlyMaterial.prototype, "activeLight", {
|
54
|
-
get: function () {
|
55
|
-
return this._activeLight;
|
56
|
-
},
|
57
|
-
set: function (light) {
|
58
|
-
this._activeLight = light;
|
59
|
-
},
|
60
|
-
enumerable: false,
|
61
|
-
configurable: true
|
62
|
-
});
|
63
|
-
ShadowOnlyMaterial.prototype._getFirstShadowLightForMesh = function (mesh) {
|
64
|
-
for (var _i = 0, _a = mesh.lightSources; _i < _a.length; _i++) {
|
65
|
-
var light = _a[_i];
|
66
|
-
if (light.shadowEnabled) {
|
67
|
-
return light;
|
68
|
-
}
|
69
|
-
}
|
70
|
-
return null;
|
71
|
-
};
|
72
|
-
// Methods
|
73
|
-
ShadowOnlyMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
|
74
|
-
var _a;
|
75
|
-
if (this.isFrozen) {
|
76
|
-
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
|
77
|
-
return true;
|
78
|
-
}
|
79
|
-
}
|
80
|
-
if (!subMesh.materialDefines) {
|
81
|
-
subMesh.materialDefines = new ShadowOnlyMaterialDefines();
|
82
|
-
}
|
83
|
-
var defines = subMesh.materialDefines;
|
84
|
-
var scene = this.getScene();
|
85
|
-
if (this._isReadyForSubMesh(subMesh)) {
|
86
|
-
return true;
|
87
|
-
}
|
88
|
-
var engine = scene.getEngine();
|
89
|
-
// Ensure that active light is the first shadow light
|
90
|
-
if (this._activeLight) {
|
91
|
-
for (var _i = 0, _b = mesh.lightSources; _i < _b.length; _i++) {
|
92
|
-
var light = _b[_i];
|
93
|
-
if (light.shadowEnabled) {
|
94
|
-
if (this._activeLight === light) {
|
95
|
-
break; // We are good
|
96
|
-
}
|
97
|
-
var lightPosition = mesh.lightSources.indexOf(this._activeLight);
|
98
|
-
if (lightPosition !== -1) {
|
99
|
-
mesh.lightSources.splice(lightPosition, 1);
|
100
|
-
mesh.lightSources.splice(0, 0, this._activeLight);
|
101
|
-
}
|
102
|
-
break;
|
103
|
-
}
|
104
|
-
}
|
105
|
-
}
|
106
|
-
MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
|
107
|
-
MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
|
108
|
-
defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, 1);
|
109
|
-
var shadowGenerator = (_a = this._getFirstShadowLightForMesh(mesh)) === null || _a === void 0 ? void 0 : _a.getShadowGenerator();
|
110
|
-
this._needAlphaBlending = true;
|
111
|
-
if (shadowGenerator && shadowGenerator.getClassName && shadowGenerator.getClassName() ===
|
112
|
-
var csg = shadowGenerator;
|
113
|
-
this._needAlphaBlending = !csg.autoCalcDepthBounds;
|
114
|
-
}
|
115
|
-
// Attribs
|
116
|
-
MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);
|
117
|
-
// Get correct effect
|
118
|
-
if (defines.isDirty) {
|
119
|
-
defines.markAsProcessed();
|
120
|
-
scene.resetCachedMaterial();
|
121
|
-
// Fallbacks
|
122
|
-
var fallbacks = new EffectFallbacks();
|
123
|
-
if (defines.FOG) {
|
124
|
-
fallbacks.addFallback(1, "FOG");
|
125
|
-
}
|
126
|
-
MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, 1);
|
127
|
-
if (defines.NUM_BONE_INFLUENCERS > 0) {
|
128
|
-
fallbacks.addCPUSkinningFallback(0, mesh);
|
129
|
-
}
|
130
|
-
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
|
131
|
-
//Attributes
|
132
|
-
var attribs = [VertexBuffer.PositionKind];
|
133
|
-
if (defines.NORMAL) {
|
134
|
-
attribs.push(VertexBuffer.NormalKind);
|
135
|
-
}
|
136
|
-
MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
|
137
|
-
MaterialHelper.PrepareAttributesForInstances(attribs, defines);
|
138
|
-
var shaderName = "shadowOnly";
|
139
|
-
var join = defines.toString();
|
140
|
-
var uniforms = [
|
141
|
-
"
|
142
|
-
"
|
143
|
-
"
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
if (!effect) {
|
181
|
-
return;
|
182
|
-
}
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
}
|
239
|
-
|
240
|
-
|
1
|
+
import { __extends } from "tslib";
|
2
|
+
import { SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
|
3
|
+
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
4
|
+
import { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
|
5
|
+
import { MaterialHelper } from "@babylonjs/core/Materials/materialHelper.js";
|
6
|
+
import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
|
7
|
+
import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
|
8
|
+
import { Scene } from "@babylonjs/core/scene.js";
|
9
|
+
import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
|
10
|
+
import "./shadowOnly.fragment";
|
11
|
+
import "./shadowOnly.vertex";
|
12
|
+
import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
|
13
|
+
var ShadowOnlyMaterialDefines = /** @class */ (function (_super) {
|
14
|
+
__extends(ShadowOnlyMaterialDefines, _super);
|
15
|
+
function ShadowOnlyMaterialDefines() {
|
16
|
+
var _this = _super.call(this) || this;
|
17
|
+
_this.CLIPPLANE = false;
|
18
|
+
_this.CLIPPLANE2 = false;
|
19
|
+
_this.CLIPPLANE3 = false;
|
20
|
+
_this.CLIPPLANE4 = false;
|
21
|
+
_this.CLIPPLANE5 = false;
|
22
|
+
_this.CLIPPLANE6 = false;
|
23
|
+
_this.POINTSIZE = false;
|
24
|
+
_this.FOG = false;
|
25
|
+
_this.NORMAL = false;
|
26
|
+
_this.NUM_BONE_INFLUENCERS = 0;
|
27
|
+
_this.BonesPerMesh = 0;
|
28
|
+
_this.INSTANCES = false;
|
29
|
+
_this.IMAGEPROCESSINGPOSTPROCESS = false;
|
30
|
+
_this.SKIPFINALCOLORCLAMP = false;
|
31
|
+
_this.rebuild();
|
32
|
+
return _this;
|
33
|
+
}
|
34
|
+
return ShadowOnlyMaterialDefines;
|
35
|
+
}(MaterialDefines));
|
36
|
+
var ShadowOnlyMaterial = /** @class */ (function (_super) {
|
37
|
+
__extends(ShadowOnlyMaterial, _super);
|
38
|
+
function ShadowOnlyMaterial(name, scene) {
|
39
|
+
var _this = _super.call(this, name, scene) || this;
|
40
|
+
_this._needAlphaBlending = true;
|
41
|
+
_this.shadowColor = Color3.Black();
|
42
|
+
return _this;
|
43
|
+
}
|
44
|
+
ShadowOnlyMaterial.prototype.needAlphaBlending = function () {
|
45
|
+
return this._needAlphaBlending;
|
46
|
+
};
|
47
|
+
ShadowOnlyMaterial.prototype.needAlphaTesting = function () {
|
48
|
+
return false;
|
49
|
+
};
|
50
|
+
ShadowOnlyMaterial.prototype.getAlphaTestTexture = function () {
|
51
|
+
return null;
|
52
|
+
};
|
53
|
+
Object.defineProperty(ShadowOnlyMaterial.prototype, "activeLight", {
|
54
|
+
get: function () {
|
55
|
+
return this._activeLight;
|
56
|
+
},
|
57
|
+
set: function (light) {
|
58
|
+
this._activeLight = light;
|
59
|
+
},
|
60
|
+
enumerable: false,
|
61
|
+
configurable: true
|
62
|
+
});
|
63
|
+
ShadowOnlyMaterial.prototype._getFirstShadowLightForMesh = function (mesh) {
|
64
|
+
for (var _i = 0, _a = mesh.lightSources; _i < _a.length; _i++) {
|
65
|
+
var light = _a[_i];
|
66
|
+
if (light.shadowEnabled) {
|
67
|
+
return light;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
return null;
|
71
|
+
};
|
72
|
+
// Methods
|
73
|
+
ShadowOnlyMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
|
74
|
+
var _a;
|
75
|
+
if (this.isFrozen) {
|
76
|
+
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
|
77
|
+
return true;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
if (!subMesh.materialDefines) {
|
81
|
+
subMesh.materialDefines = new ShadowOnlyMaterialDefines();
|
82
|
+
}
|
83
|
+
var defines = subMesh.materialDefines;
|
84
|
+
var scene = this.getScene();
|
85
|
+
if (this._isReadyForSubMesh(subMesh)) {
|
86
|
+
return true;
|
87
|
+
}
|
88
|
+
var engine = scene.getEngine();
|
89
|
+
// Ensure that active light is the first shadow light
|
90
|
+
if (this._activeLight) {
|
91
|
+
for (var _i = 0, _b = mesh.lightSources; _i < _b.length; _i++) {
|
92
|
+
var light = _b[_i];
|
93
|
+
if (light.shadowEnabled) {
|
94
|
+
if (this._activeLight === light) {
|
95
|
+
break; // We are good
|
96
|
+
}
|
97
|
+
var lightPosition = mesh.lightSources.indexOf(this._activeLight);
|
98
|
+
if (lightPosition !== -1) {
|
99
|
+
mesh.lightSources.splice(lightPosition, 1);
|
100
|
+
mesh.lightSources.splice(0, 0, this._activeLight);
|
101
|
+
}
|
102
|
+
break;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
|
107
|
+
MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
|
108
|
+
defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, 1);
|
109
|
+
var shadowGenerator = (_a = this._getFirstShadowLightForMesh(mesh)) === null || _a === void 0 ? void 0 : _a.getShadowGenerator();
|
110
|
+
this._needAlphaBlending = true;
|
111
|
+
if (shadowGenerator && shadowGenerator.getClassName && shadowGenerator.getClassName() === "CascadedShadowGenerator") {
|
112
|
+
var csg = shadowGenerator;
|
113
|
+
this._needAlphaBlending = !csg.autoCalcDepthBounds;
|
114
|
+
}
|
115
|
+
// Attribs
|
116
|
+
MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);
|
117
|
+
// Get correct effect
|
118
|
+
if (defines.isDirty) {
|
119
|
+
defines.markAsProcessed();
|
120
|
+
scene.resetCachedMaterial();
|
121
|
+
// Fallbacks
|
122
|
+
var fallbacks = new EffectFallbacks();
|
123
|
+
if (defines.FOG) {
|
124
|
+
fallbacks.addFallback(1, "FOG");
|
125
|
+
}
|
126
|
+
MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, 1);
|
127
|
+
if (defines.NUM_BONE_INFLUENCERS > 0) {
|
128
|
+
fallbacks.addCPUSkinningFallback(0, mesh);
|
129
|
+
}
|
130
|
+
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
|
131
|
+
//Attributes
|
132
|
+
var attribs = [VertexBuffer.PositionKind];
|
133
|
+
if (defines.NORMAL) {
|
134
|
+
attribs.push(VertexBuffer.NormalKind);
|
135
|
+
}
|
136
|
+
MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
|
137
|
+
MaterialHelper.PrepareAttributesForInstances(attribs, defines);
|
138
|
+
var shaderName = "shadowOnly";
|
139
|
+
var join = defines.toString();
|
140
|
+
var uniforms = [
|
141
|
+
"world",
|
142
|
+
"view",
|
143
|
+
"viewProjection",
|
144
|
+
"vEyePosition",
|
145
|
+
"vLightsType",
|
146
|
+
"vFogInfos",
|
147
|
+
"vFogColor",
|
148
|
+
"pointSize",
|
149
|
+
"alpha",
|
150
|
+
"shadowColor",
|
151
|
+
"mBones",
|
152
|
+
"vClipPlane",
|
153
|
+
"vClipPlane2",
|
154
|
+
"vClipPlane3",
|
155
|
+
"vClipPlane4",
|
156
|
+
"vClipPlane5",
|
157
|
+
"vClipPlane6",
|
158
|
+
];
|
159
|
+
var samplers = new Array();
|
160
|
+
var uniformBuffers = new Array();
|
161
|
+
MaterialHelper.PrepareUniformsAndSamplersList({
|
162
|
+
uniformsNames: uniforms,
|
163
|
+
uniformBuffersNames: uniformBuffers,
|
164
|
+
samplers: samplers,
|
165
|
+
defines: defines,
|
166
|
+
maxSimultaneousLights: 1,
|
167
|
+
});
|
168
|
+
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
|
169
|
+
attributes: attribs,
|
170
|
+
uniformsNames: uniforms,
|
171
|
+
uniformBuffersNames: uniformBuffers,
|
172
|
+
samplers: samplers,
|
173
|
+
defines: join,
|
174
|
+
fallbacks: fallbacks,
|
175
|
+
onCompiled: this.onCompiled,
|
176
|
+
onError: this.onError,
|
177
|
+
indexParameters: { maxSimultaneousLights: 1 },
|
178
|
+
}, engine), defines, this._materialContext);
|
179
|
+
}
|
180
|
+
if (!subMesh.effect || !subMesh.effect.isReady()) {
|
181
|
+
return false;
|
182
|
+
}
|
183
|
+
defines._renderId = scene.getRenderId();
|
184
|
+
subMesh.effect._wasPreviouslyReady = true;
|
185
|
+
return true;
|
186
|
+
};
|
187
|
+
ShadowOnlyMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
|
188
|
+
var scene = this.getScene();
|
189
|
+
var defines = subMesh.materialDefines;
|
190
|
+
if (!defines) {
|
191
|
+
return;
|
192
|
+
}
|
193
|
+
var effect = subMesh.effect;
|
194
|
+
if (!effect) {
|
195
|
+
return;
|
196
|
+
}
|
197
|
+
this._activeEffect = effect;
|
198
|
+
// Matrices
|
199
|
+
this.bindOnlyWorldMatrix(world);
|
200
|
+
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
|
201
|
+
// Bones
|
202
|
+
MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
|
203
|
+
if (this._mustRebind(scene, effect)) {
|
204
|
+
// Clip plane
|
205
|
+
MaterialHelper.BindClipPlane(this._activeEffect, scene);
|
206
|
+
// Point size
|
207
|
+
if (this.pointsCloud) {
|
208
|
+
this._activeEffect.setFloat("pointSize", this.pointSize);
|
209
|
+
}
|
210
|
+
this._activeEffect.setFloat("alpha", this.alpha);
|
211
|
+
this._activeEffect.setColor3("shadowColor", this.shadowColor);
|
212
|
+
scene.bindEyePosition(effect);
|
213
|
+
}
|
214
|
+
// Lights
|
215
|
+
if (scene.lightsEnabled) {
|
216
|
+
MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, 1);
|
217
|
+
var light = this._getFirstShadowLightForMesh(mesh);
|
218
|
+
if (light) {
|
219
|
+
// Make sure the uniforms for this light will be rebound for other materials using this light when rendering the current frame.
|
220
|
+
// Indeed, there is an optimization in Light that binds the light uniforms only once per frame for a given light (if using ubo).
|
221
|
+
// Doing this way assumes that all uses of this light are the same, meaning all parameters passed to Light._bindLlight
|
222
|
+
// are the same, notably useSpecular. However, isReadyForSubMesh (see above) is passing false for this parameter, which may not be
|
223
|
+
// the value the other materials may pass.
|
224
|
+
light._renderId = -1;
|
225
|
+
}
|
226
|
+
}
|
227
|
+
// View
|
228
|
+
if ((scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) || defines["SHADOWCSM0"]) {
|
229
|
+
this._activeEffect.setMatrix("view", scene.getViewMatrix());
|
230
|
+
}
|
231
|
+
// Fog
|
232
|
+
MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
|
233
|
+
this._afterBind(mesh, this._activeEffect);
|
234
|
+
};
|
235
|
+
ShadowOnlyMaterial.prototype.clone = function (name) {
|
236
|
+
var _this = this;
|
237
|
+
return SerializationHelper.Clone(function () { return new ShadowOnlyMaterial(name, _this.getScene()); }, this);
|
238
|
+
};
|
239
|
+
ShadowOnlyMaterial.prototype.serialize = function () {
|
240
|
+
var serializationObject = _super.prototype.serialize.call(this);
|
241
|
+
serializationObject.customType = "BABYLON.ShadowOnlyMaterial";
|
242
|
+
return serializationObject;
|
243
|
+
};
|
244
|
+
ShadowOnlyMaterial.prototype.getClassName = function () {
|
245
|
+
return "ShadowOnlyMaterial";
|
246
|
+
};
|
247
|
+
// Statics
|
248
|
+
ShadowOnlyMaterial.Parse = function (source, scene, rootUrl) {
|
249
|
+
return SerializationHelper.Parse(function () { return new ShadowOnlyMaterial(source.name, scene); }, source, scene, rootUrl);
|
250
|
+
};
|
251
|
+
return ShadowOnlyMaterial;
|
252
|
+
}(PushMaterial));
|
253
|
+
export { ShadowOnlyMaterial };
|
254
|
+
RegisterClass("BABYLON.ShadowOnlyMaterial", ShadowOnlyMaterial);
|
241
255
|
//# sourceMappingURL=shadowOnlyMaterial.js.map
|