Browse Source

fixing typedoc

Benjamin Guignabert 5 years ago
parent
commit
ca20b0b130

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

@@ -807,7 +807,7 @@ export abstract class PBRBaseMaterial extends PushMaterial {
     /**
     /**
      * Defines the SubSurface parameters for the material.
      * Defines the SubSurface parameters for the material.
      */
      */
-    public readonly subSurface = new PBRSubSurfaceConfiguration(this._markAllSubMeshesAsTexturesDirty.bind(this), this._markSceneDeferredDirty.bind(this));
+    public readonly subSurface = new PBRSubSurfaceConfiguration(this._markAllSubMeshesAsTexturesDirty.bind(this), this._markScenePrePassDirty.bind(this));
 
 
     /**
     /**
      * Defines the detail map parameters for the material.
      * Defines the detail map parameters for the material.

+ 7 - 6
src/Materials/PBR/pbrSubSurfaceConfiguration.ts

@@ -69,7 +69,7 @@ export class PBRSubSurfaceConfiguration {
      * Defines if the sub surface scattering is enabled in the material.
      * Defines if the sub surface scattering is enabled in the material.
      */
      */
     @serialize()
     @serialize()
-    @expandToProperty("_markSceneDeferredDirty")
+    @expandToProperty("_markScenePrePassDirty")
     public isScatteringEnabled = false;
     public isScatteringEnabled = false;
 
 
     /**
     /**
@@ -231,24 +231,25 @@ export class PBRSubSurfaceConfiguration {
 
 
     /** @hidden */
     /** @hidden */
     private _internalMarkAllSubMeshesAsTexturesDirty: () => void;
     private _internalMarkAllSubMeshesAsTexturesDirty: () => void;
-    private _internalMarkSceneDeferredDirty: () => void;
+    private _internalMarkScenePrePassDirty: () => void;
 
 
     /** @hidden */
     /** @hidden */
     public _markAllSubMeshesAsTexturesDirty(): void {
     public _markAllSubMeshesAsTexturesDirty(): void {
         this._internalMarkAllSubMeshesAsTexturesDirty();
         this._internalMarkAllSubMeshesAsTexturesDirty();
     }
     }
     /** @hidden */
     /** @hidden */
-    public _markSceneDeferredDirty(): void {
-        this._internalMarkSceneDeferredDirty();
+    public _markScenePrePassDirty(): void {
+        this._internalMarkScenePrePassDirty();
     }
     }
 
 
     /**
     /**
      * Instantiate a new istance of sub surface configuration.
      * Instantiate a new istance of sub surface configuration.
      * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
      * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
+     * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
      */
      */
-    constructor(markAllSubMeshesAsTexturesDirty: () => void, markSceneDeferredDirty: () => void) {
+    constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void) {
         this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
         this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
-        this._internalMarkSceneDeferredDirty = markSceneDeferredDirty;
+        this._internalMarkScenePrePassDirty = markScenePrePassDirty;
     }
     }
 
 
     /**
     /**

+ 4 - 1
src/Materials/material.ts

@@ -1241,7 +1241,10 @@ export class Material implements IAnimatable {
         }
         }
     }
     }
 
 
-    protected _markSceneDeferredDirty() {
+    /**
+     * Indicates that the scene should check if the rendering now needs a prepass
+     */
+    protected _markScenePrePassDirty() {
         if (this.getScene().blockMaterialDirtyMechanism) {
         if (this.getScene().blockMaterialDirtyMechanism) {
             return;
             return;
         }
         }

+ 2 - 2
src/Materials/materialHelper.ts

@@ -302,7 +302,7 @@ export class MaterialHelper {
      * @param shouldRenderToMRT Indicates if this material renders to several textures in the prepass
      * @param shouldRenderToMRT Indicates if this material renders to several textures in the prepass
      */
      */
     public static PrepareDefinesForPrePass(scene: Scene, defines: any, shouldRenderToMRT: boolean) {
     public static PrepareDefinesForPrePass(scene: Scene, defines: any, shouldRenderToMRT: boolean) {
-        var previousDeferred = defines.PREPASS;
+        var previousPrePass = defines.PREPASS;
 
 
         if (scene.prePassRenderer && shouldRenderToMRT) {
         if (scene.prePassRenderer && shouldRenderToMRT) {
             defines.PREPASS = true;
             defines.PREPASS = true;
@@ -311,7 +311,7 @@ export class MaterialHelper {
             defines.PREPASS = false;
             defines.PREPASS = false;
         }
         }
 
 
-        if (defines.PREPASS != previousDeferred) {
+        if (defines.PREPASS != previousPrePass) {
             defines.markAsUnprocessed();
             defines.markAsUnprocessed();
             defines.markAsImageProcessingDirty();
             defines.markAsImageProcessingDirty();
         }
         }

+ 1 - 1
src/PostProcesses/SubSurfaceScatteringPostProcess.ts

@@ -13,7 +13,7 @@ import "../Shaders/subSurfaceScattering.fragment";
 import "../Shaders/postprocess.vertex";
 import "../Shaders/postprocess.vertex";
 
 
 /**
 /**
- * Scene compositor post process
+ * Sub surface scattering post process
  */
  */
 export class SubSurfaceScatteringPostProcess extends PostProcess {
 export class SubSurfaceScatteringPostProcess extends PostProcess {
     /** @hidden */
     /** @hidden */

+ 102 - 15
src/Rendering/prePassRenderer.ts

@@ -10,6 +10,12 @@ import { Logger } from "../Misc/logger";
 import { _DevTools } from '../Misc/devTools';
 import { _DevTools } from '../Misc/devTools';
 import { Color3 } from "../Maths/math.color";
 import { Color3 } from "../Maths/math.color";
 
 
+/**
+ * Renders a pre pass of the scene
+ * This means every mesh in the scene will be rendered to a render target texture
+ * And then this texture will be composited to the rendering canvas with post processes
+ * It is necessary for effects like subsurface scattering or deferred shading
+ */
 export class PrePassRenderer {
 export class PrePassRenderer {
     /** @hidden */
     /** @hidden */
     public static _SceneComponentInitialization: (scene: Scene) => void = (_) => {
     public static _SceneComponentInitialization: (scene: Scene) => void = (_) => {
@@ -20,7 +26,14 @@ export class PrePassRenderer {
     private _engine: Engine;
     private _engine: Engine;
     private _isDirty: boolean = false;
     private _isDirty: boolean = false;
 
 
-    public mrtCount: number = 4;
+    /**
+     * Number of textures in the multi render target texture where the scene is directly rendered
+     */
+    public readonly mrtCount: number = 4;
+
+    /**
+     * The render target where the scene is directly rendered
+     */
     public prePassRT: MultiRenderTarget;
     public prePassRT: MultiRenderTarget;
     private _mrtTypes = [
     private _mrtTypes = [
         Constants.TEXTURETYPE_UNSIGNED_INT, // Original color
         Constants.TEXTURETYPE_UNSIGNED_INT, // Original color
@@ -32,9 +45,30 @@ export class PrePassRenderer {
     private _defaultAttachments: number[];
     private _defaultAttachments: number[];
     private _clearAttachments: number[];
     private _clearAttachments: number[];
 
 
-    public ssDiffusionS: number[] = [];
-    public ssFilterRadii: number[] = [];
-    public ssDiffusionD: number[] = [];
+    private _ssDiffusionS: number[] = [];
+    private _ssFilterRadii: number[] = [];
+    private _ssDiffusionD: number[] = [];
+
+    /**
+     * Diffusion profile color for subsurface scattering
+     */
+    public get ssDiffusionS() {
+        return this._ssDiffusionS;
+    }
+
+    /**
+     * Diffusion profile max color channel value for subsurface scattering
+     */
+    public get ssDiffusionD() {
+        return this._ssDiffusionD;
+    }
+
+    /**
+     * Diffusion profile filter radius for subsurface scattering
+     */
+    public get ssFilterRadii() {
+        return this._ssFilterRadii;
+    }
 
 
     /**
     /**
      * Defines the ratio real world => scene units.
      * Defines the ratio real world => scene units.
@@ -42,14 +76,27 @@ export class PrePassRenderer {
      */
      */
     public metersPerUnit: number = 1;
     public metersPerUnit: number = 1;
 
 
+    /**
+     * Image processing post process for composition
+     */
     public imageProcessingPostProcess: ImageProcessingPostProcess;
     public imageProcessingPostProcess: ImageProcessingPostProcess;
+
+    /**
+     * Post process for subsurface scattering
+     */
     public subSurfaceScatteringPostProcess: SubSurfaceScatteringPostProcess;
     public subSurfaceScatteringPostProcess: SubSurfaceScatteringPostProcess;
     private _enabled: boolean = false;
     private _enabled: boolean = false;
 
 
+    /**
+     * Indicates if the prepass is enabled
+     */
     public get enabled() {
     public get enabled() {
         return this._enabled;
         return this._enabled;
     }
     }
 
 
+    /**
+     * How many samples are used for MSAA of the scene render target
+     */
     public get samples() {
     public get samples() {
         return this.prePassRT.samples;
         return this.prePassRT.samples;
     }
     }
@@ -58,6 +105,10 @@ export class PrePassRenderer {
         this.prePassRT.samples = n;
         this.prePassRT.samples = n;
     }
     }
 
 
+    /**
+     * Instanciates a prepass renderer
+     * @param scene The scene
+     */
     constructor(scene: Scene) {
     constructor(scene: Scene) {
         this._scene = scene;
         this._scene = scene;
         this._engine = scene.getEngine();
         this._engine = scene.getEngine();
@@ -93,11 +144,18 @@ export class PrePassRenderer {
         }
         }
     }
     }
 
 
+    /**
+     * Indicates if rendering a prepass is supported
+     */
     public get isSupported() {
     public get isSupported() {
         // TODO
         // TODO
         return true;
         return true;
     }
     }
 
 
+    /**
+     * Sets the proper output textures to draw in the engine.
+     * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
+     */
     public drawBuffers(effect: Effect) {
     public drawBuffers(effect: Effect) {
         if (this.enabled) {
         if (this.enabled) {
             if (effect._multiTarget) {
             if (effect._multiTarget) {
@@ -108,6 +166,9 @@ export class PrePassRenderer {
         }
         }
     }
     }
 
 
+    /**
+     * @hidden
+     */
     public _beforeCameraDraw() {
     public _beforeCameraDraw() {
         if (this._isDirty) {
         if (this._isDirty) {
             this._update();
             this._update();
@@ -116,6 +177,9 @@ export class PrePassRenderer {
         this._bindFrameBuffer();
         this._bindFrameBuffer();
     }
     }
 
 
+    /**
+     * @hidden
+     */
     public _afterCameraDraw() {
     public _afterCameraDraw() {
         if (this._enabled) {
         if (this._enabled) {
             // this.imageProcessingPostProcess.activate(this._scene.activeCamera);
             // this.imageProcessingPostProcess.activate(this._scene.activeCamera);
@@ -154,6 +218,9 @@ export class PrePassRenderer {
         }
         }
     }
     }
 
 
+    /**
+     * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
+     */
     public clear() {
     public clear() {
         if (this._enabled) {
         if (this._enabled) {
             this._bindFrameBuffer();
             this._bindFrameBuffer();
@@ -177,6 +244,9 @@ export class PrePassRenderer {
         this.imageProcessingPostProcess.imageProcessingConfiguration.applyByPostProcess = false;
         this.imageProcessingPostProcess.imageProcessingConfiguration.applyByPostProcess = false;
     }
     }
 
 
+    /**
+     * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
+     */
     public markAsDirty() {
     public markAsDirty() {
         this._isDirty = true;
         this._isDirty = true;
     }
     }
@@ -203,6 +273,12 @@ export class PrePassRenderer {
         }
         }
     }
     }
 
 
+    /**
+     * Adds a new diffusion profile.
+     * Useful for more realistic subsurface scattering on diverse materials.
+     * @param color The color of the diffusion profile. Should be the average color of the material.
+     * @return The index of the diffusion profile for the material subsurface configuration
+     */
     public addDiffusionProfile(color: Color3) : number {
     public addDiffusionProfile(color: Color3) : number {
         if (this.ssDiffusionD.length >= 5) {
         if (this.ssDiffusionD.length >= 5) {
             // We only suppport 5 diffusion profiles
             // We only suppport 5 diffusion profiles
@@ -211,29 +287,36 @@ export class PrePassRenderer {
         }
         }
 
 
         // Do not add doubles
         // Do not add doubles
-        for (let i = 0; i < this.ssDiffusionS.length / 3; i++) {
-            if (this.ssDiffusionS[i * 3] === color.r &&
-                this.ssDiffusionS[i * 3 + 1] === color.g &&
-                this.ssDiffusionS[i * 3 + 2] === color.b) {
+        for (let i = 0; i < this._ssDiffusionS.length / 3; i++) {
+            if (this._ssDiffusionS[i * 3] === color.r &&
+                this._ssDiffusionS[i * 3 + 1] === color.g &&
+                this._ssDiffusionS[i * 3 + 2] === color.b) {
                 return i;
                 return i;
             }
             }
         }
         }
 
 
-        this.ssDiffusionS.push(color.r, color.b, color.g);
-        this.ssDiffusionD.push(Math.max(Math.max(color.r, color.b), color.g));
-        this.ssFilterRadii.push(this.getDiffusionProfileParameters(color));
+        this._ssDiffusionS.push(color.r, color.b, color.g);
+        this._ssDiffusionD.push(Math.max(Math.max(color.r, color.b), color.g));
+        this._ssFilterRadii.push(this.getDiffusionProfileParameters(color));
         this._scene.ssDiffusionProfileColors.push(color);
         this._scene.ssDiffusionProfileColors.push(color);
 
 
-        return this.ssDiffusionD.length - 1;
+        return this._ssDiffusionD.length - 1;
     }
     }
 
 
+    /**
+     * Deletes all diffusion profiles.
+     * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
+     */
     public clearAllDiffusionProfiles() {
     public clearAllDiffusionProfiles() {
-        this.ssDiffusionD = [];
-        this.ssDiffusionS = [];
-        this.ssFilterRadii = [];
+        this._ssDiffusionD = [];
+        this._ssDiffusionS = [];
+        this._ssFilterRadii = [];
         this._scene.ssDiffusionProfileColors = [];
         this._scene.ssDiffusionProfileColors = [];
     }
     }
 
 
+    /**
+     * @hidden
+     */
     public getDiffusionProfileParameters(color: Color3)
     public getDiffusionProfileParameters(color: Color3)
     {
     {
         const cdf = 0.997;
         const cdf = 0.997;
@@ -248,6 +331,7 @@ export class PrePassRenderer {
 
 
         return this._sampleBurleyDiffusionProfile(cdf, maxScatteringDistance);
         return this._sampleBurleyDiffusionProfile(cdf, maxScatteringDistance);
     }
     }
+
     // https://zero-radiance.github.io/post/sampling-diffusion/
     // https://zero-radiance.github.io/post/sampling-diffusion/
     // Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
     // Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
     // 'u' is the random number (the value of the CDF): [0, 1).
     // 'u' is the random number (the value of the CDF): [0, 1).
@@ -266,6 +350,9 @@ export class PrePassRenderer {
         return x * rcpS;
         return x * rcpS;
     }
     }
 
 
+    /**
+     * Disposes the prepass renderer.
+     */
     public dispose() {
     public dispose() {
         this.imageProcessingPostProcess.dispose();
         this.imageProcessingPostProcess.dispose();
         this.subSurfaceScatteringPostProcess.dispose();
         this.subSurfaceScatteringPostProcess.dispose();

+ 9 - 3
src/Rendering/prePassRendererSceneComponent.ts

@@ -11,7 +11,7 @@ declare module "../abstractScene" {
         _prePassRenderer: Nullable<PrePassRenderer>;
         _prePassRenderer: Nullable<PrePassRenderer>;
 
 
         /**
         /**
-         * Gets or Sets the current geometry buffer associated to the scene.
+         * Gets or Sets the current prepass renderer associated to the scene.
          */
          */
         prePassRenderer: Nullable<PrePassRenderer>;
         prePassRenderer: Nullable<PrePassRenderer>;
 
 
@@ -19,13 +19,19 @@ declare module "../abstractScene" {
          * Enables the prepass and associates it with the scene
          * Enables the prepass and associates it with the scene
          * @returns the PrePassRenderer
          * @returns the PrePassRenderer
          */
          */
-        enablePrePassRenderer(ratio?: number): Nullable<PrePassRenderer>;
+        enablePrePassRenderer(): Nullable<PrePassRenderer>;
 
 
         /**
         /**
          * Disables the prepass associated with the scene
          * Disables the prepass associated with the scene
          */
          */
         disablePrePassRenderer(): void;
         disablePrePassRenderer(): void;
 
 
+        /**
+         * Diffusion profile colors for subsurface scattering
+         * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
+         * See ...
+         * Note that you can only store up to 5 of them
+         */
         ssDiffusionProfileColors: Color3[];
         ssDiffusionProfileColors: Color3[];
     }
     }
 }
 }
@@ -43,7 +49,7 @@ Object.defineProperty(Scene.prototype, "prePassRenderer", {
     configurable: true
     configurable: true
 });
 });
 
 
-Scene.prototype.enablePrePassRenderer = function(ratio: number = 1): Nullable<PrePassRenderer> {
+Scene.prototype.enablePrePassRenderer = function(): Nullable<PrePassRenderer> {
     if (this._prePassRenderer) {
     if (this._prePassRenderer) {
         return this._prePassRenderer;
         return this._prePassRenderer;
     }
     }