Procházet zdrojové kódy

Added hdr support to ReflectionProbe

David Catuhe před 7 roky
rodič
revize
9fea7ad7b1

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 8310 - 8290
Playground/babylon.d.txt


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 12817 - 12787
dist/preview release/babylon.d.ts


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
dist/preview release/babylon.js


+ 34 - 4
dist/preview release/babylon.max.js

@@ -101514,19 +101514,35 @@ var BABYLON;
 
 var BABYLON;
 (function (BABYLON) {
+    /**
+     * Class used to generate realtime reflection / refraction cube textures
+     * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
+     */
     var ReflectionProbe = /** @class */ (function () {
-        function ReflectionProbe(name, size, scene, generateMipMaps) {
+        /**
+         * Creates a new reflection probe
+         * @param name defines the name of the probe
+         * @param size defines the texture resolution (for each face)
+         * @param scene defines the hosting scene
+         * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
+         * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
+         */
+        function ReflectionProbe(
+        /** defines the name of the probe */
+        name, size, scene, generateMipMaps, useFloat) {
             if (generateMipMaps === void 0) { generateMipMaps = true; }
+            if (useFloat === void 0) { useFloat = false; }
             var _this = this;
             this.name = name;
             this._viewMatrix = BABYLON.Matrix.Identity();
             this._target = BABYLON.Vector3.Zero();
             this._add = BABYLON.Vector3.Zero();
             this._invertYAxis = false;
+            /** Gets or sets probe position (center of the cube map) */
             this.position = BABYLON.Vector3.Zero();
             this._scene = scene;
             this._scene.reflectionProbes.push(this);
-            this._renderTargetTexture = new BABYLON.RenderTargetTexture(name, size, scene, generateMipMaps, true, BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, true);
+            this._renderTargetTexture = new BABYLON.RenderTargetTexture(name, size, scene, generateMipMaps, true, useFloat ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, true);
             this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
                 switch (faceIndex) {
                     case 0:
@@ -101565,6 +101581,7 @@ var BABYLON;
             }
         }
         Object.defineProperty(ReflectionProbe.prototype, "samples", {
+            /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
             get: function () {
                 return this._renderTargetTexture.samples;
             },
@@ -101575,6 +101592,7 @@ var BABYLON;
             configurable: true
         });
         Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
+            /** Gets or sets the refresh rate to use (on every frame by default) */
             get: function () {
                 return this._renderTargetTexture.refreshRate;
             },
@@ -101584,10 +101602,15 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        /**
+         * Gets the hosting scene
+         * @returns a Scene
+         */
         ReflectionProbe.prototype.getScene = function () {
             return this._scene;
         };
         Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
+            /** Gets the internal CubeTexture used to render to */
             get: function () {
                 return this._renderTargetTexture;
             },
@@ -101595,24 +101618,31 @@ var BABYLON;
             configurable: true
         });
         Object.defineProperty(ReflectionProbe.prototype, "renderList", {
+            /** Gets the list of meshes to render */
             get: function () {
                 return this._renderTargetTexture.renderList;
             },
             enumerable: true,
             configurable: true
         });
+        /**
+         * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
+         * @param mesh defines the mesh to attach to
+         */
         ReflectionProbe.prototype.attachToMesh = function (mesh) {
             this._attachedMesh = mesh;
         };
         /**
-         * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
-         *
+         * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
          * @param renderingGroupId The rendering group id corresponding to its index
          * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
          */
         ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
             this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
         };
+        /**
+         * Clean all associated resources
+         */
         ReflectionProbe.prototype.dispose = function () {
             var index = this._scene.reflectionProbes.indexOf(this);
             if (index !== -1) {

+ 34 - 4
dist/preview release/babylon.no-module.max.js

@@ -101481,19 +101481,35 @@ var BABYLON;
 
 var BABYLON;
 (function (BABYLON) {
+    /**
+     * Class used to generate realtime reflection / refraction cube textures
+     * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
+     */
     var ReflectionProbe = /** @class */ (function () {
-        function ReflectionProbe(name, size, scene, generateMipMaps) {
+        /**
+         * Creates a new reflection probe
+         * @param name defines the name of the probe
+         * @param size defines the texture resolution (for each face)
+         * @param scene defines the hosting scene
+         * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
+         * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
+         */
+        function ReflectionProbe(
+        /** defines the name of the probe */
+        name, size, scene, generateMipMaps, useFloat) {
             if (generateMipMaps === void 0) { generateMipMaps = true; }
+            if (useFloat === void 0) { useFloat = false; }
             var _this = this;
             this.name = name;
             this._viewMatrix = BABYLON.Matrix.Identity();
             this._target = BABYLON.Vector3.Zero();
             this._add = BABYLON.Vector3.Zero();
             this._invertYAxis = false;
+            /** Gets or sets probe position (center of the cube map) */
             this.position = BABYLON.Vector3.Zero();
             this._scene = scene;
             this._scene.reflectionProbes.push(this);
-            this._renderTargetTexture = new BABYLON.RenderTargetTexture(name, size, scene, generateMipMaps, true, BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, true);
+            this._renderTargetTexture = new BABYLON.RenderTargetTexture(name, size, scene, generateMipMaps, true, useFloat ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, true);
             this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
                 switch (faceIndex) {
                     case 0:
@@ -101532,6 +101548,7 @@ var BABYLON;
             }
         }
         Object.defineProperty(ReflectionProbe.prototype, "samples", {
+            /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
             get: function () {
                 return this._renderTargetTexture.samples;
             },
@@ -101542,6 +101559,7 @@ var BABYLON;
             configurable: true
         });
         Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
+            /** Gets or sets the refresh rate to use (on every frame by default) */
             get: function () {
                 return this._renderTargetTexture.refreshRate;
             },
@@ -101551,10 +101569,15 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        /**
+         * Gets the hosting scene
+         * @returns a Scene
+         */
         ReflectionProbe.prototype.getScene = function () {
             return this._scene;
         };
         Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
+            /** Gets the internal CubeTexture used to render to */
             get: function () {
                 return this._renderTargetTexture;
             },
@@ -101562,24 +101585,31 @@ var BABYLON;
             configurable: true
         });
         Object.defineProperty(ReflectionProbe.prototype, "renderList", {
+            /** Gets the list of meshes to render */
             get: function () {
                 return this._renderTargetTexture.renderList;
             },
             enumerable: true,
             configurable: true
         });
+        /**
+         * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
+         * @param mesh defines the mesh to attach to
+         */
         ReflectionProbe.prototype.attachToMesh = function (mesh) {
             this._attachedMesh = mesh;
         };
         /**
-         * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
-         *
+         * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
          * @param renderingGroupId The rendering group id corresponding to its index
          * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
          */
         ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
             this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
         };
+        /**
+         * Clean all associated resources
+         */
         ReflectionProbe.prototype.dispose = function () {
             var index = this._scene.reflectionProbes.indexOf(this);
             if (index !== -1) {

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
dist/preview release/babylon.worker.js


+ 34 - 4
dist/preview release/es6.js

@@ -101481,19 +101481,35 @@ var BABYLON;
 
 var BABYLON;
 (function (BABYLON) {
+    /**
+     * Class used to generate realtime reflection / refraction cube textures
+     * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
+     */
     var ReflectionProbe = /** @class */ (function () {
-        function ReflectionProbe(name, size, scene, generateMipMaps) {
+        /**
+         * Creates a new reflection probe
+         * @param name defines the name of the probe
+         * @param size defines the texture resolution (for each face)
+         * @param scene defines the hosting scene
+         * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
+         * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
+         */
+        function ReflectionProbe(
+        /** defines the name of the probe */
+        name, size, scene, generateMipMaps, useFloat) {
             if (generateMipMaps === void 0) { generateMipMaps = true; }
+            if (useFloat === void 0) { useFloat = false; }
             var _this = this;
             this.name = name;
             this._viewMatrix = BABYLON.Matrix.Identity();
             this._target = BABYLON.Vector3.Zero();
             this._add = BABYLON.Vector3.Zero();
             this._invertYAxis = false;
+            /** Gets or sets probe position (center of the cube map) */
             this.position = BABYLON.Vector3.Zero();
             this._scene = scene;
             this._scene.reflectionProbes.push(this);
-            this._renderTargetTexture = new BABYLON.RenderTargetTexture(name, size, scene, generateMipMaps, true, BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, true);
+            this._renderTargetTexture = new BABYLON.RenderTargetTexture(name, size, scene, generateMipMaps, true, useFloat ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, true);
             this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
                 switch (faceIndex) {
                     case 0:
@@ -101532,6 +101548,7 @@ var BABYLON;
             }
         }
         Object.defineProperty(ReflectionProbe.prototype, "samples", {
+            /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
             get: function () {
                 return this._renderTargetTexture.samples;
             },
@@ -101542,6 +101559,7 @@ var BABYLON;
             configurable: true
         });
         Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
+            /** Gets or sets the refresh rate to use (on every frame by default) */
             get: function () {
                 return this._renderTargetTexture.refreshRate;
             },
@@ -101551,10 +101569,15 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        /**
+         * Gets the hosting scene
+         * @returns a Scene
+         */
         ReflectionProbe.prototype.getScene = function () {
             return this._scene;
         };
         Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
+            /** Gets the internal CubeTexture used to render to */
             get: function () {
                 return this._renderTargetTexture;
             },
@@ -101562,24 +101585,31 @@ var BABYLON;
             configurable: true
         });
         Object.defineProperty(ReflectionProbe.prototype, "renderList", {
+            /** Gets the list of meshes to render */
             get: function () {
                 return this._renderTargetTexture.renderList;
             },
             enumerable: true,
             configurable: true
         });
+        /**
+         * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
+         * @param mesh defines the mesh to attach to
+         */
         ReflectionProbe.prototype.attachToMesh = function (mesh) {
             this._attachedMesh = mesh;
         };
         /**
-         * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
-         *
+         * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
          * @param renderingGroupId The rendering group id corresponding to its index
          * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
          */
         ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
             this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
         };
+        /**
+         * Clean all associated resources
+         */
         ReflectionProbe.prototype.dispose = function () {
             var index = this._scene.reflectionProbes.indexOf(this);
             if (index !== -1) {

+ 2 - 94
dist/preview release/typedocValidationBaseline.json

@@ -1,7 +1,7 @@
 {
-  "errors": 4238,
+  "errors": 4222,
   "babylon.typedoc.json": {
-    "errors": 4238,
+    "errors": 4222,
     "AbstractMesh": {
       "Property": {
         "showBoundingBox": {
@@ -14142,98 +14142,6 @@
         }
       }
     },
-    "ReflectionProbe": {
-      "Class": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Constructor": {
-        "new ReflectionProbe": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "name": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "size": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "scene": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "generateMipMaps": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      },
-      "Property": {
-        "cubeTexture": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "name": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "position": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "refreshRate": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "renderList": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "samples": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      },
-      "Method": {
-        "attachToMesh": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "mesh": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "dispose": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "getScene": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      }
-    },
     "RefractionPostProcess": {
       "Class": {
         "Comments": {

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
dist/preview release/viewer/babylon.viewer.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


+ 1 - 0
dist/preview release/what's new.md

@@ -85,6 +85,7 @@
 - Added gltf light falloff [Issue 4148](https://github.com/BabylonJS/Babylon.js/issues/4148) ([sebavan](http://www.github.com/sebavan))
 - Added falloff type per light to prevent material only inconsistencies [Issue 4148](https://github.com/BabylonJS/Babylon.js/issues/4148) ([sebavan](http://www.github.com/sebavan))
 - Added WeightedSound; selects one from many Sounds with random weight for playback. ([najadojo](https://github.com/najadojo))
+- Added HDR support to ReflectionProbe ([Deltakosh](https://github.com/deltakosh))
 
 ### glTF Loader
 

+ 35 - 4
src/Probes/babylon.reflectionProbe.ts

@@ -1,4 +1,8 @@
 module BABYLON {
+    /** 
+     * Class used to generate realtime reflection / refraction cube textures
+     * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
+     */
     export class ReflectionProbe{  
         private _scene: Scene;
         private _renderTargetTexture: RenderTargetTexture;
@@ -9,14 +13,27 @@
         private _attachedMesh: AbstractMesh;
 
         private _invertYAxis = false;
+
+        /** Gets or sets probe position (center of the cube map) */
         public position = Vector3.Zero();
           
-        constructor(public name: string, size: number, scene: Scene, generateMipMaps = true) {
+        /**
+         * Creates a new reflection probe
+         * @param name defines the name of the probe
+         * @param size defines the texture resolution (for each face)
+         * @param scene defines the hosting scene
+         * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
+         * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
+         */
+        constructor(
+            /** defines the name of the probe */
+            public name: string, 
+            size: number, scene: Scene, generateMipMaps = true, useFloat = false) {
             this._scene = scene;
 
             this._scene.reflectionProbes.push(this);
 
-            this._renderTargetTexture = new RenderTargetTexture(name, size, scene, generateMipMaps, true, Engine.TEXTURETYPE_UNSIGNED_INT, true);
+            this._renderTargetTexture = new RenderTargetTexture(name, size, scene, generateMipMaps, true, useFloat ? Engine.TEXTURETYPE_FLOAT : Engine.TEXTURETYPE_UNSIGNED_INT, true);
 
             this._renderTargetTexture.onBeforeRenderObservable.add((faceIndex: number) => {
                 switch (faceIndex) {
@@ -64,6 +81,7 @@
             }
         }
 
+        /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
         public get samples(): number {
             return this._renderTargetTexture.samples;
         }
@@ -72,6 +90,7 @@
             this._renderTargetTexture.samples = value;
         }
 
+        /** Gets or sets the refresh rate to use (on every frame by default) */
         public get refreshRate(): number {
             return this._renderTargetTexture.refreshRate;
         }
@@ -80,25 +99,34 @@
             this._renderTargetTexture.refreshRate = value;
         }
 
+        /** 
+         * Gets the hosting scene
+         * @returns a Scene
+         */
         public getScene(): Scene {
             return this._scene;
         }
 
+        /** Gets the internal CubeTexture used to render to */
         public get cubeTexture(): RenderTargetTexture {
             return this._renderTargetTexture;
         }
 
+        /** Gets the list of meshes to render */
         public get renderList(): Nullable<AbstractMesh[]> {
             return this._renderTargetTexture.renderList;
         }
 
+        /**
+         * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
+         * @param mesh defines the mesh to attach to
+         */
         public attachToMesh(mesh: AbstractMesh): void {
             this._attachedMesh = mesh;
         }
         
         /**
-         * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
-         * 
+         * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
          * @param renderingGroupId The rendering group id corresponding to its index
          * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
          */
@@ -106,6 +134,9 @@
             this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
         }
 
+        /**
+         * Clean all associated resources
+         */
         public dispose() {
             var index = this._scene.reflectionProbes.indexOf(this);