Benjamin Guignabert 5 år sedan
förälder
incheckning
fee78393bf

+ 1 - 1
package.json

@@ -113,4 +113,4 @@
         "xhr2": "^0.2.0",
         "xmlbuilder": "15.1.1"
     }
-}
+}

+ 36 - 0
src/Engines/constants.ts

@@ -484,4 +484,40 @@ export class Constants {
      * Detailled logging while loading
      */
     public static readonly SCENELOADER_DETAILED_LOGGING = 3;
+
+    /**
+     * Constant used to retrieve the irradiance texture index in the textures array in the prepass
+     * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
+     */
+    public static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE = 0;
+    /**
+     * Constant used to retrieve the position texture index in the textures array in the prepass
+     * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
+     */
+    public static readonly PREPASS_POSITION_TEXTURE_TYPE = 1;
+    /**
+     * Constant used to retrieve the velocity texture index in the textures array in the prepass
+     * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
+     */
+    public static readonly PREPASS_VELOCITY_TEXTURE_TYPE = 2;
+    /**
+     * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
+     * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
+     */
+    public static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE = 3;
+    /**
+     * Constant used to retrieve the lit color texture index in the textures array in the prepass
+     * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
+     */
+    public static readonly PREPASS_COLOR_TEXTURE_TYPE = 4;
+    /**
+     * Constant used to retrieve depth + normal index in the textures array in the prepass
+     * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
+     */
+    public static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE = 5;
+    /**
+     * Constant used to retrieve albedo index in the textures array in the prepass
+     * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
+     */
+    public static readonly PREPASS_ALBEDO_TEXTURE_TYPE = 6;
 }

+ 3 - 2
src/Materials/PBR/pbrAdditionnalPrePassConfiguration.ts

@@ -2,11 +2,12 @@ import { UniformBuffer } from "../../Materials/uniformBuffer";
 import { Matrix } from "../../Maths/math.vector";
 import { Mesh } from "../../Meshes/mesh";
 import { Scene } from "../../scene";
-import { PrePassRenderer } from "../../Rendering/prePassRenderer";
+import { Constants } from "../../Engines/constants";
 
 export class PBRAdditionnalPrePassConfiguration {
     public previousWorldMatrices: { [index: number]: Matrix } = {};
     public previousViewProjection: Matrix;
+    public previousBones: { [index: number]: number[] } = {};
 
     constructor() {
 
@@ -50,7 +51,7 @@ export class PBRAdditionnalPrePassConfiguration {
 
         if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
             if (scene.prePassRenderer && scene.prePassRenderer.enabled) {
-                if (scene.prePassRenderer.getIndex(PrePassRenderer.VELOCITY_TEXTURE_TYPE) !== -1) {
+                if (scene.prePassRenderer.getIndex(Constants.PREPASS_VELOCITY_TEXTURE_TYPE) !== -1) {
                     if (!this.previousWorldMatrices[mesh.uniqueId]) {
                         this.previousWorldMatrices[mesh.uniqueId] = Matrix.Identity();
                     }

+ 1 - 1
src/Materials/PBR/pbrBaseMaterial.ts

@@ -1775,7 +1775,7 @@ export abstract class PBRBaseMaterial extends PushMaterial {
         let mustRebind = this._mustRebind(scene, effect, mesh.visibility);
 
         // Bones
-        MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
+        MaterialHelper.BindBonesParameters(mesh, this._activeEffect, this.additionnalPrePass);
 
         let reflectionTexture: Nullable<BaseTexture> = null;
         if (mustRebind) {

+ 29 - 18
src/Materials/Textures/multiRenderTarget.ts

@@ -138,22 +138,9 @@ export class MultiRenderTarget extends RenderTargetTexture {
             return;
         }
 
-        var types = [];
-        var samplingModes = [];
-
-        for (var i = 0; i < count; i++) {
-            if (options && options.types && options.types[i] !== undefined) {
-                types.push(options.types[i]);
-            } else {
-                types.push(options && options.defaultType ? options.defaultType : Constants.TEXTURETYPE_UNSIGNED_INT);
-            }
-
-            if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
-                samplingModes.push(options.samplingModes[i]);
-            } else {
-                samplingModes.push(Texture.BILINEAR_SAMPLINGMODE);
-            }
-        }
+        var types: number[] = [];
+        var samplingModes: number[] = [];
+        this._initTypes(count, types, samplingModes, options);
 
         var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
         var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
@@ -175,6 +162,22 @@ export class MultiRenderTarget extends RenderTargetTexture {
         this._createTextures();
     }
 
+    private _initTypes(count: number, types: number[], samplingModes: number[], options?: IMultiRenderTargetOptions) {
+        for (var i = 0; i < count; i++) {
+            if (options && options.types && options.types[i] !== undefined) {
+                types.push(options.types[i]);
+            } else {
+                types.push(options && options.defaultType ? options.defaultType : Constants.TEXTURETYPE_UNSIGNED_INT);
+            }
+
+            if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
+                samplingModes.push(options.samplingModes[i]);
+            } else {
+                samplingModes.push(Texture.BILINEAR_SAMPLINGMODE);
+            }
+        }
+    }
+
     /** @hidden */
     public _rebuild(forceFullRebuild: boolean = false): void {
         this.releaseInternalTextures();
@@ -241,11 +244,19 @@ export class MultiRenderTarget extends RenderTargetTexture {
     /**
      * Changes the number of render targets in this MRT
      * Be careful as it will recreate all the data in the new texture.
-     * @param size Defines
+     * @param count new texture count
+     * @param options Specifies texture types and sampling modes for new textures
      */
-    public updateCount(count: number) {
+    public updateCount(count: number, options?: IMultiRenderTargetOptions) {
         this._multiRenderTargetOptions.textureCount = count;
         this._count = count;
+
+        const types: number[] = [];
+        const samplingModes: number[] = [];
+
+        this._initTypes(count, types, samplingModes, options);
+        this._multiRenderTargetOptions.types = types;
+        this._multiRenderTargetOptions.samplingModes = samplingModes;
         this._rebuild(true);
     }
 

+ 11 - 10
src/Materials/materialHelper.ts

@@ -8,7 +8,8 @@ import { AbstractMesh } from "../Meshes/abstractMesh";
 import { Mesh } from "../Meshes/mesh";
 import { VertexBuffer } from "../Meshes/buffer";
 import { Light } from "../Lights/light";
-import { PrePassRenderer } from "../Rendering/prePassRenderer";
+import { Constants } from "../Engines/constants";
+import { PBRAdditionnalPrePassConfiguration } from "../Materials/PBR/pbrAdditionnalPrePassConfiguration";
 
 import { UniformBuffer } from "./uniformBuffer";
 import { Effect, IEffectCreationOptions } from "./effect";
@@ -306,32 +307,32 @@ export class MaterialHelper {
         const previousPrePass = defines.PREPASS;
         const texturesList = [
         {
-            type: PrePassRenderer.POSITION_TEXTURE_TYPE,
+            type: Constants.PREPASS_POSITION_TEXTURE_TYPE,
             define: "PREPASS_POSITION",
             index: "POSITION_TEXTURE_TYPE",
         },
         {
-            type: PrePassRenderer.VELOCITY_TEXTURE_TYPE,
+            type: Constants.PREPASS_VELOCITY_TEXTURE_TYPE,
             define: "PREPASS_VELOCITY",
             index: "PREPASS_VELOCITY_INDEX",
         },
         {
-            type: PrePassRenderer.REFLECTIVITY_TEXTURE_TYPE,
+            type: Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE,
             define: "PREPASS_REFLECTIVITY",
             index: "PREPASS_REFLECTIVITY_INDEX",
         },
         {
-            type: PrePassRenderer.IRRADIANCE_TEXTURE_TYPE,
+            type: Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE,
             define: "PREPASS_IRRADIANCE",
             index: "PREPASS_IRRADIANCE_INDEX",
         },
         {
-            type: PrePassRenderer.ALBEDO_TEXTURE_TYPE,
+            type: Constants.PREPASS_ALBEDO_TEXTURE_TYPE,
             define: "PREPASS_ALBEDO",
             index: "PREPASS_ALBEDO_INDEX",
         },
         {
-            type: PrePassRenderer.DEPTHNORMAL_TEXTURE_TYPE,
+            type: Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE,
             define: "PREPASS_DEPTHNORMAL",
             index: "PREPASS_DEPTHNORMAL_INDEX",
         }];
@@ -821,7 +822,7 @@ export class MaterialHelper {
      * @param mesh The mesh we are binding the information to render
      * @param effect The effect we are binding the data to
      */
-    public static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void {
+    public static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PBRAdditionnalPrePassConfiguration): void {
         if (!effect || !mesh) {
             return;
         }
@@ -841,8 +842,8 @@ export class MaterialHelper {
 
                 if (matrices) {
                     effect.setMatrices("mBones", matrices);
-                    if (mesh.getScene().prePassRenderer && mesh.getScene().prePassRenderer.getIndex()) {
-                        effect.setMatrices("mPreviousBones", this._previousBonesTransformationMatrices[renderingMesh.uniqueId]);
+                    if (prePassConfiguration && mesh.getScene().prePassRenderer && mesh.getScene().prePassRenderer!.getIndex(Constants.PREPASS_VELOCITY_TEXTURE_TYPE)) {
+                        effect.setMatrices("mPreviousBones", prePassConfiguration.previousBones[mesh.uniqueId]);
                     }
                 }
             }

+ 4 - 3
src/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts

@@ -14,6 +14,7 @@ import { _TypeStore } from '../../../Misc/typeStore';
 import { EngineStore } from '../../../Engines/engineStore';
 import { SSAO2Configuration } from "../../../Rendering/ssao2Configuration";
 import { PrePassRenderer } from "../../../Rendering/prePassRenderer";
+import { Constants } from "../../../Engines/constants";
 
 import "../../../PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
 
@@ -294,7 +295,7 @@ export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
             if (this._forceGeometryBuffer) {
                 effect.setTexture("depthNormalSampler", this._scene.enableGeometryBufferRenderer()!.getGBuffer().textures[0]);
             } else {
-                effect.setTexture("depthNormalSampler", this._prePassRenderer.prePassRT.textures[this._prePassRenderer.getIndex(PrePassRenderer.DEPTHNORMAL_TEXTURE_TYPE)]);
+                effect.setTexture("depthNormalSampler", this._prePassRenderer.prePassRT.textures[this._prePassRenderer.getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]);
             }
             effect.setArray("samplerOffsets", this._samplerOffsets);
         };
@@ -312,7 +313,7 @@ export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
             if (this._forceGeometryBuffer) {
                 effect.setTexture("depthNormalSampler", this._scene.enableGeometryBufferRenderer()!.getGBuffer().textures[0]);
             } else {
-                effect.setTexture("depthNormalSampler", this._prePassRenderer.prePassRT.textures[this._prePassRenderer.getIndex(PrePassRenderer.DEPTHNORMAL_TEXTURE_TYPE)]);
+                effect.setTexture("depthNormalSampler", this._prePassRenderer.prePassRT.textures[this._prePassRenderer.getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]);
             }
             effect.setArray("samplerOffsets", this._samplerOffsets);
 
@@ -430,7 +431,7 @@ export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
                 effect.setTexture("depthSampler", this._scene.enableGeometryBufferRenderer()!.getGBuffer().textures[0]);
                 effect.setTexture("normalSampler", this._scene.enableGeometryBufferRenderer()!.getGBuffer().textures[1]);
             } else {
-                effect.setTexture("depthNormalSampler", this._prePassRenderer.prePassRT.textures[this._prePassRenderer.getIndex(PrePassRenderer.DEPTHNORMAL_TEXTURE_TYPE)]);
+                effect.setTexture("depthNormalSampler", this._prePassRenderer.prePassRT.textures[this._prePassRenderer.getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]);
             }
             effect.setTexture("randomSampler", this._randomTexture);
         };

+ 1 - 1
src/PostProcesses/motionBlurPostProcess.ts

@@ -116,7 +116,7 @@ export class MotionBlurPostProcess extends PostProcess {
                     const velocityIndex = this._geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE);
                     effect.setTexture("velocitySampler", this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
                 } else {
-                    const velocityIndex = this._prePassRenderer.getIndex(PrePassRenderer.VELOCITY_TEXTURE_TYPE);
+                    const velocityIndex = this._prePassRenderer.getIndex(Constants.PREPASS_VELOCITY_TEXTURE_TYPE);
                     effect.setTexture("velocitySampler", this._prePassRenderer.prePassRT.textures[velocityIndex]);
                 }
             };

+ 3 - 4
src/PostProcesses/subSurfaceScatteringPostProcess.ts

@@ -6,7 +6,6 @@ import { PostProcess, PostProcessOptions } from "./postProcess";
 import { Engine } from "../Engines/engine";
 import { Scene } from "../scene";
 import { Constants } from "../Engines/constants";
-import { PrePassRenderer } from "../Rendering/prePassRenderer";
 import { Logger } from "../Misc/logger";
 
 import "../Shaders/imageProcessing.fragment";
@@ -39,9 +38,9 @@ export class SubSurfaceScatteringPostProcess extends PostProcess {
             var texelSize = this.texelSize;
             effect.setFloat("metersPerUnit", scene.subSurfaceConfiguration.metersPerUnit);
             effect.setFloat2("texelSize", texelSize.x, texelSize.y);
-            effect.setTexture("irradianceSampler", scene.prePassRenderer.prePassRT.textures[scene.prePassRenderer.getIndex(PrePassRenderer.IRRADIANCE_TEXTURE_TYPE)]);
-            effect.setTexture("depthSampler", scene.prePassRenderer.prePassRT.textures[scene.prePassRenderer.getIndex(PrePassRenderer.DEPTHNORMAL_TEXTURE_TYPE)]);
-            effect.setTexture("albedoSampler", scene.prePassRenderer.prePassRT.textures[scene.prePassRenderer.getIndex(PrePassRenderer.ALBEDO_TEXTURE_TYPE)]);
+            effect.setTexture("irradianceSampler", scene.prePassRenderer.prePassRT.textures[scene.prePassRenderer.getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)]);
+            effect.setTexture("depthSampler", scene.prePassRenderer.prePassRT.textures[scene.prePassRenderer.getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]);
+            effect.setTexture("albedoSampler", scene.prePassRenderer.prePassRT.textures[scene.prePassRenderer.getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)]);
             effect.setFloat2("viewportSize",
                 Math.tan(scene.activeCamera!.fov / 2) * scene.getEngine().getAspectRatio(scene.activeCamera!, true),
                 Math.tan(scene.activeCamera!.fov / 2));

+ 2 - 2
src/Rendering/motionBlurConfiguration.ts

@@ -1,4 +1,4 @@
-import { PrePassRenderer } from "./prePassRenderer";
+import { Constants } from "../Engines/constants";
 import { PrePassEffectConfiguration } from "./prePassEffectConfiguration";
 import { _DevTools } from '../Misc/devTools';
 
@@ -21,7 +21,7 @@ export class MotionBlurConfiguration implements PrePassEffectConfiguration {
      * Textures that should be present in the MRT for this effect to work
      */
     public readonly texturesRequired: number[] = [
-        PrePassRenderer.VELOCITY_TEXTURE_TYPE
+        Constants.PREPASS_VELOCITY_TEXTURE_TYPE
     ];
 
     /**

+ 15 - 49
src/Rendering/prePassRenderer.ts

@@ -8,8 +8,6 @@ import { Effect } from "../Materials/effect";
 import { _DevTools } from '../Misc/devTools';
 import { Color4 } from "../Maths/math.color";
 import { PrePassEffectConfiguration } from "./prePassEffectConfiguration";
-
-export type PrePassLayout = number[];
 /**
  * Renders a pre pass of the scene
  * This means every mesh in the scene will be rendered to a render target texture
@@ -22,69 +20,33 @@ export class PrePassRenderer {
         throw _DevTools.WarnImport("PrePassRendererSceneComponent");
     }
 
-    /**
-     * Constant used to retrieve the irradiance texture index in the textures array
-     * using getIndex(PrePassRenderer.IRRADIANCE_TEXTURE_TYPE)
-     */
-    public static readonly IRRADIANCE_TEXTURE_TYPE = 0;
-    /**
-     * Constant used to retrieve the position texture index in the textures array
-     * using getIndex(PrePassRenderer.POSITION_TEXTURE_INDEX)
-     */
-    public static readonly POSITION_TEXTURE_TYPE = 1;
-    /**
-     * Constant used to retrieve the velocity texture index in the textures array
-     * using getIndex(PrePassRenderer.VELOCITY_TEXTURE_INDEX)
-     */
-    public static readonly VELOCITY_TEXTURE_TYPE = 2;
-    /**
-     * Constant used to retrieve the reflectivity texture index in the textures array
-     * using the getIndex(PrePassRenderer.REFLECTIVITY_TEXTURE_TYPE)
-     */
-    public static readonly REFLECTIVITY_TEXTURE_TYPE = 3;
-    /**
-     * Constant used to retrieve the lit color texture index in the textures array
-     * using the getIndex(PrePassRenderer.COLOR_TEXTURE_TYPE)
-     */
-    public static readonly COLOR_TEXTURE_TYPE = 4;
-    /**
-     * Constant used to retrieve depth + normal index in the textures array
-     * using the getIndex(PrePassRenderer.DEPTHNORMAL_TEXTURE_TYPE)
-     */
-    public static readonly DEPTHNORMAL_TEXTURE_TYPE = 5;
-    /**
-     * Constant used to retrieve albedo index in the textures array
-     * using the getIndex(PrePassRenderer.ALBEDO_TEXTURE_TYPE)
-     */
-    public static readonly ALBEDO_TEXTURE_TYPE = 6;
-
     private _textureFormats = [
         {
-            type: PrePassRenderer.IRRADIANCE_TEXTURE_TYPE,
+            type: Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE,
             format: Constants.TEXTURETYPE_HALF_FLOAT,
         },
         {
-            type: PrePassRenderer.POSITION_TEXTURE_TYPE,
+            type: Constants.PREPASS_POSITION_TEXTURE_TYPE,
             format: Constants.TEXTURETYPE_HALF_FLOAT,
         },
         {
-            type: PrePassRenderer.VELOCITY_TEXTURE_TYPE,
+            type: Constants.PREPASS_VELOCITY_TEXTURE_TYPE,
             format: Constants.TEXTURETYPE_HALF_FLOAT,
         },
         {
-            type: PrePassRenderer.REFLECTIVITY_TEXTURE_TYPE,
+            type: Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE,
             format: Constants.TEXTURETYPE_UNSIGNED_INT,
         },
         {
-            type: PrePassRenderer.COLOR_TEXTURE_TYPE,
+            type: Constants.PREPASS_COLOR_TEXTURE_TYPE,
             format: Constants.TEXTURETYPE_HALF_FLOAT,
         },
         {
-            type: PrePassRenderer.DEPTHNORMAL_TEXTURE_TYPE,
+            type: Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE,
             format: Constants.TEXTURETYPE_HALF_FLOAT,
         },
         {
-            type: PrePassRenderer.ALBEDO_TEXTURE_TYPE,
+            type: Constants.PREPASS_ALBEDO_TEXTURE_TYPE,
             format: Constants.TEXTURETYPE_UNSIGNED_INT,
         },
 ];
@@ -287,7 +249,11 @@ export class PrePassRenderer {
     }
 
     /**
-     * Adds an effect configuration
+     * Adds an effect configuration to the prepass.
+     * If an effect has already been added, it won't add it twice and will return the configuration
+     * already present.
+     * @param cfg the effect configuration
+     * @return the effect configuration now used by the prepass
      */
     public addEffectConfiguration(cfg: PrePassEffectConfiguration) : PrePassEffectConfiguration {
         // Do not add twice
@@ -320,7 +286,7 @@ export class PrePassRenderer {
         }
 
         if (this.prePassRT && this.mrtCount !== previousMrtCount) {
-            this.prePassRT.updateCount(this.mrtCount);
+            this.prePassRT.updateCount(this.mrtCount, { types: this._mrtFormats });
         }
 
         this._resetPostProcessChain();
@@ -362,8 +328,8 @@ export class PrePassRenderer {
             this._textureIndices[this._textureFormats[i].type] = -1;
         }
 
-        this._textureIndices[PrePassRenderer.COLOR_TEXTURE_TYPE] = 0;
-        this._mrtLayout = [PrePassRenderer.COLOR_TEXTURE_TYPE];
+        this._textureIndices[Constants.PREPASS_COLOR_TEXTURE_TYPE] = 0;
+        this._mrtLayout = [Constants.PREPASS_COLOR_TEXTURE_TYPE];
         this._mrtFormats = [Constants.TEXTURETYPE_HALF_FLOAT];
         this.mrtCount = 1;
     }

+ 6 - 3
src/Rendering/ssao2Configuration.ts

@@ -1,4 +1,4 @@
-import { PrePassRenderer } from "./prePassRenderer";
+import { Constants } from "../Engines/constants";
 import { PrePassEffectConfiguration } from "./prePassEffectConfiguration";
 import { _DevTools } from '../Misc/devTools';
 
@@ -21,7 +21,7 @@ export class SSAO2Configuration implements PrePassEffectConfiguration {
      * Textures that should be present in the MRT for this effect to work
      */
     public readonly texturesRequired: number[] = [
-        PrePassRenderer.DEPTHNORMAL_TEXTURE_TYPE
+        Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE
     ];
 
     /**
@@ -32,7 +32,10 @@ export class SSAO2Configuration implements PrePassEffectConfiguration {
 
     }
 
+    /**
+     * Disposes the configuration
+     */
     public dispose() {
-
+        // pass
     }
 }

+ 5 - 5
src/Rendering/subSurfaceConfiguration.ts

@@ -2,10 +2,10 @@ import { Logger } from "../Misc/logger";
 import { Scene } from "../scene";
 import { Color3 } from "../Maths/math.color";
 import { SubSurfaceScatteringPostProcess } from "../PostProcesses/subSurfaceScatteringPostProcess";
-import { PrePassRenderer } from "./prePassRenderer";
 import { SceneComponentConstants } from "../sceneComponent";
 import { PrePassEffectConfiguration } from "./prePassEffectConfiguration";
 import { _DevTools } from '../Misc/devTools';
+import { Constants } from "../Engines/constants";
 
 /**
  * Contains all parameters needed for the prepass to perform
@@ -75,10 +75,10 @@ export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
      * Textures that should be present in the MRT for this effect to work
      */
     public readonly texturesRequired: number[] = [
-        PrePassRenderer.DEPTHNORMAL_TEXTURE_TYPE,
-        PrePassRenderer.ALBEDO_TEXTURE_TYPE,
-        PrePassRenderer.COLOR_TEXTURE_TYPE,
-        PrePassRenderer.IRRADIANCE_TEXTURE_TYPE,
+        Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE,
+        Constants.PREPASS_ALBEDO_TEXTURE_TYPE,
+        Constants.PREPASS_COLOR_TEXTURE_TYPE,
+        Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE,
     ];
 
     private _scene: Scene;

+ 4 - 0
src/Shaders/pbr.fragment.fx

@@ -528,6 +528,10 @@ void main(void) {
         vec3 sqAlbedo = sqrt(surfaceAlbedo); // for pre and post scatter
         gl_FragData[0] = vec4(finalColor.rgb - irradiance, finalColor.a); // Split irradiance from final color
         irradiance /= sqAlbedo;
+        
+        #ifndef SS_SCATTERING
+            float scatteringDiffusionProfile = 255.;
+        #endif
         gl_FragData[PREPASS_IRRADIANCE_INDEX] = vec4(tagLightingForSSS(irradiance), scatteringDiffusionProfile / 255.); // Irradiance + SS diffusion profile
     #else
         gl_FragData[0] = vec4(finalColor.rgb, finalColor.a);