|
@@ -63,6 +63,16 @@ export class ShadowDepthWrapper {
|
|
/** @hidden */
|
|
/** @hidden */
|
|
public _matriceNames: any;
|
|
public _matriceNames: any;
|
|
|
|
|
|
|
|
+ /** Gets the standalone status of the wrapper */
|
|
|
|
+ public get standalone(): boolean {
|
|
|
|
+ return this._options?.standalone ?? false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /** Gets the base material the wrapper is built upon */
|
|
|
|
+ public get baseMaterial(): Material {
|
|
|
|
+ return this._baseMaterial;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Instantiate a new shadow depth wrapper.
|
|
* Instantiate a new shadow depth wrapper.
|
|
* It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
|
|
* It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
|
|
@@ -134,7 +144,7 @@ export class ShadowDepthWrapper {
|
|
* @returns a boolean indicating that the submesh is ready or not
|
|
* @returns a boolean indicating that the submesh is ready or not
|
|
*/
|
|
*/
|
|
public isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean {
|
|
public isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean {
|
|
- if (this._options?.standalone) {
|
|
|
|
|
|
+ if (this.standalone) {
|
|
// will ensure the effect is (re)created for the base material
|
|
// will ensure the effect is (re)created for the base material
|
|
this._baseMaterial.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances);
|
|
this._baseMaterial.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances);
|
|
}
|
|
}
|
|
@@ -194,7 +204,7 @@ export class ShadowDepthWrapper {
|
|
fragmentBlockCode = Effect.IncludesShadersStore["shadowMapFragment"];
|
|
fragmentBlockCode = Effect.IncludesShadersStore["shadowMapFragment"];
|
|
|
|
|
|
vertexCode = vertexCode.replace(/void\s+?main/g, Effect.IncludesShadersStore["shadowMapVertexDeclaration"] + "\r\nvoid main");
|
|
vertexCode = vertexCode.replace(/void\s+?main/g, Effect.IncludesShadersStore["shadowMapVertexDeclaration"] + "\r\nvoid main");
|
|
- vertexCode = vertexCode.replace(/#define SHADOWDEPTH_NORMALBIAS/g, vertexNormalBiasCode);
|
|
|
|
|
|
+ vertexCode = vertexCode.replace(/#define SHADOWDEPTH_NORMALBIAS|#define CUSTOM_VERTEX_UPDATE_WORLDPOS/g, vertexNormalBiasCode);
|
|
|
|
|
|
if (vertexCode.indexOf("#define SHADOWDEPTH_METRIC") !== -1) {
|
|
if (vertexCode.indexOf("#define SHADOWDEPTH_METRIC") !== -1) {
|
|
vertexCode = vertexCode.replace(/#define SHADOWDEPTH_METRIC/g, vertexMetricCode);
|
|
vertexCode = vertexCode.replace(/#define SHADOWDEPTH_METRIC/g, vertexMetricCode);
|
|
@@ -205,7 +215,7 @@ export class ShadowDepthWrapper {
|
|
|
|
|
|
fragmentCode = fragmentCode.replace(/void\s+?main/g, Effect.IncludesShadersStore["shadowMapFragmentDeclaration"] + "\r\nvoid main");
|
|
fragmentCode = fragmentCode.replace(/void\s+?main/g, Effect.IncludesShadersStore["shadowMapFragmentDeclaration"] + "\r\nvoid main");
|
|
if (fragmentCode.indexOf("#define SHADOWDEPTH_FRAGMENT") !== -1) {
|
|
if (fragmentCode.indexOf("#define SHADOWDEPTH_FRAGMENT") !== -1) {
|
|
- fragmentCode = vertexCode.replace(/#define SHADOWDEPTH_FRAGMENT/g, fragmentBlockCode);
|
|
|
|
|
|
+ fragmentCode = fragmentCode.replace(/#define SHADOWDEPTH_FRAGMENT/g, fragmentBlockCode);
|
|
} else {
|
|
} else {
|
|
fragmentCode = fragmentCode.replace(/}\s*$/g, fragmentBlockCode + "\r\n}");
|
|
fragmentCode = fragmentCode.replace(/}\s*$/g, fragmentBlockCode + "\r\n}");
|
|
}
|
|
}
|