소스 검색

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js

sebavan 6 년 전
부모
커밋
b4c4fbf971

+ 16 - 3
Playground/babylon.d.txt

@@ -34560,9 +34560,8 @@ declare module BABYLON {
         protected _checkLimits(): void;
         /**
          * Rebuilds angles (alpha, beta) and radius from the give position and target
-         * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
          */
-        rebuildAnglesAndRadius(updateView?: boolean): void;
+        rebuildAnglesAndRadius(): void;
         /**
          * Use a position to define the current camera related information like aplha, beta and radius
          * @param position Defines the position to set the camera at
@@ -46960,6 +46959,7 @@ declare module BABYLON {
         private _fixedTimeStep;
         private _cannonRaycastResult;
         private _raycastResult;
+        private _removeAfterStep;
         BJSCANNON: any;
         constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
         setGravity(gravity: Vector3): void;
@@ -52807,8 +52807,11 @@ declare module BABYLON {
          */
         horizontalBlur: boolean;
         /**
-         * Sets the overall exposure used by the pipeline
+         * Gets the overall exposure used by the pipeline
          */
+        /**
+        * Sets the overall exposure used by the pipeline
+        */
         exposure: number;
         /**
          * Texture used typically to simulate "dirty" on camera lens
@@ -52845,6 +52848,13 @@ declare module BABYLON {
          */
         hdrIncreaseRate: number;
         /**
+         * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
+         */
+        /**
+        * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
+        */
+        hdrAutoExposure: boolean;
+        /**
          * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
          */
         lensColorTexture: Nullable<Texture>;
@@ -52897,6 +52907,9 @@ declare module BABYLON {
         private _scene;
         private _currentDepthOfFieldSource;
         private _basePostProcess;
+        private _fixedExposure;
+        private _currentExposure;
+        private _hdrAutoExposure;
         private _hdrCurrentLuminance;
         private _floatTextureType;
         private _ratio;

+ 16 - 3
dist/preview release/babylon.d.ts

@@ -35164,9 +35164,8 @@ declare module BABYLON {
         protected _checkLimits(): void;
         /**
          * Rebuilds angles (alpha, beta) and radius from the give position and target
-         * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
          */
-        rebuildAnglesAndRadius(updateView?: boolean): void;
+        rebuildAnglesAndRadius(): void;
         /**
          * Use a position to define the current camera related information like aplha, beta and radius
          * @param position Defines the position to set the camera at
@@ -47640,6 +47639,7 @@ declare module BABYLON {
         private _fixedTimeStep;
         private _cannonRaycastResult;
         private _raycastResult;
+        private _removeAfterStep;
         BJSCANNON: any;
         constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
         setGravity(gravity: Vector3): void;
@@ -53539,8 +53539,11 @@ declare module BABYLON {
          */
         horizontalBlur: boolean;
         /**
-         * Sets the overall exposure used by the pipeline
+         * Gets the overall exposure used by the pipeline
          */
+        /**
+        * Sets the overall exposure used by the pipeline
+        */
         exposure: number;
         /**
          * Texture used typically to simulate "dirty" on camera lens
@@ -53577,6 +53580,13 @@ declare module BABYLON {
          */
         hdrIncreaseRate: number;
         /**
+         * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
+         */
+        /**
+        * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
+        */
+        hdrAutoExposure: boolean;
+        /**
          * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
          */
         lensColorTexture: Nullable<Texture>;
@@ -53629,6 +53639,9 @@ declare module BABYLON {
         private _scene;
         private _currentDepthOfFieldSource;
         private _basePostProcess;
+        private _fixedExposure;
+        private _currentExposure;
+        private _hdrAutoExposure;
         private _hdrCurrentLuminance;
         private _floatTextureType;
         private _ratio;

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
dist/preview release/babylon.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 101 - 47
dist/preview release/babylon.max.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
dist/preview release/babylon.max.js.map


+ 32 - 6
dist/preview release/babylon.module.d.ts

@@ -36096,9 +36096,8 @@ declare module "babylonjs/Cameras/arcRotateCamera" {
         protected _checkLimits(): void;
         /**
          * Rebuilds angles (alpha, beta) and radius from the give position and target
-         * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
          */
-        rebuildAnglesAndRadius(updateView?: boolean): void;
+        rebuildAnglesAndRadius(): void;
         /**
          * Use a position to define the current camera related information like aplha, beta and radius
          * @param position Defines the position to set the camera at
@@ -49630,6 +49629,7 @@ declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
         private _fixedTimeStep;
         private _cannonRaycastResult;
         private _raycastResult;
+        private _removeAfterStep;
         BJSCANNON: any;
         constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
         setGravity(gravity: Vector3): void;
@@ -56043,8 +56043,11 @@ declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderi
          */
         horizontalBlur: boolean;
         /**
-         * Sets the overall exposure used by the pipeline
+         * Gets the overall exposure used by the pipeline
          */
+        /**
+        * Sets the overall exposure used by the pipeline
+        */
         exposure: number;
         /**
          * Texture used typically to simulate "dirty" on camera lens
@@ -56081,6 +56084,13 @@ declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderi
          */
         hdrIncreaseRate: number;
         /**
+         * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
+         */
+        /**
+        * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
+        */
+        hdrAutoExposure: boolean;
+        /**
          * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
          */
         lensColorTexture: Nullable<Texture>;
@@ -56133,6 +56143,9 @@ declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderi
         private _scene;
         private _currentDepthOfFieldSource;
         private _basePostProcess;
+        private _fixedExposure;
+        private _currentExposure;
+        private _hdrAutoExposure;
         private _hdrCurrentLuminance;
         private _floatTextureType;
         private _ratio;
@@ -94325,9 +94338,8 @@ declare module BABYLON {
         protected _checkLimits(): void;
         /**
          * Rebuilds angles (alpha, beta) and radius from the give position and target
-         * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
          */
-        rebuildAnglesAndRadius(updateView?: boolean): void;
+        rebuildAnglesAndRadius(): void;
         /**
          * Use a position to define the current camera related information like aplha, beta and radius
          * @param position Defines the position to set the camera at
@@ -106801,6 +106813,7 @@ declare module BABYLON {
         private _fixedTimeStep;
         private _cannonRaycastResult;
         private _raycastResult;
+        private _removeAfterStep;
         BJSCANNON: any;
         constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
         setGravity(gravity: Vector3): void;
@@ -112700,8 +112713,11 @@ declare module BABYLON {
          */
         horizontalBlur: boolean;
         /**
-         * Sets the overall exposure used by the pipeline
+         * Gets the overall exposure used by the pipeline
          */
+        /**
+        * Sets the overall exposure used by the pipeline
+        */
         exposure: number;
         /**
          * Texture used typically to simulate "dirty" on camera lens
@@ -112738,6 +112754,13 @@ declare module BABYLON {
          */
         hdrIncreaseRate: number;
         /**
+         * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
+         */
+        /**
+        * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
+        */
+        hdrAutoExposure: boolean;
+        /**
          * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
          */
         lensColorTexture: Nullable<Texture>;
@@ -112790,6 +112813,9 @@ declare module BABYLON {
         private _scene;
         private _currentDepthOfFieldSource;
         private _basePostProcess;
+        private _fixedExposure;
+        private _currentExposure;
+        private _hdrAutoExposure;
         private _hdrCurrentLuminance;
         private _floatTextureType;
         private _ratio;

+ 32 - 6
dist/preview release/viewer/babylon.module.d.ts

@@ -36096,9 +36096,8 @@ declare module "babylonjs/Cameras/arcRotateCamera" {
         protected _checkLimits(): void;
         /**
          * Rebuilds angles (alpha, beta) and radius from the give position and target
-         * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
          */
-        rebuildAnglesAndRadius(updateView?: boolean): void;
+        rebuildAnglesAndRadius(): void;
         /**
          * Use a position to define the current camera related information like aplha, beta and radius
          * @param position Defines the position to set the camera at
@@ -49630,6 +49629,7 @@ declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
         private _fixedTimeStep;
         private _cannonRaycastResult;
         private _raycastResult;
+        private _removeAfterStep;
         BJSCANNON: any;
         constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
         setGravity(gravity: Vector3): void;
@@ -56043,8 +56043,11 @@ declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderi
          */
         horizontalBlur: boolean;
         /**
-         * Sets the overall exposure used by the pipeline
+         * Gets the overall exposure used by the pipeline
          */
+        /**
+        * Sets the overall exposure used by the pipeline
+        */
         exposure: number;
         /**
          * Texture used typically to simulate "dirty" on camera lens
@@ -56081,6 +56084,13 @@ declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderi
          */
         hdrIncreaseRate: number;
         /**
+         * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
+         */
+        /**
+        * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
+        */
+        hdrAutoExposure: boolean;
+        /**
          * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
          */
         lensColorTexture: Nullable<Texture>;
@@ -56133,6 +56143,9 @@ declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderi
         private _scene;
         private _currentDepthOfFieldSource;
         private _basePostProcess;
+        private _fixedExposure;
+        private _currentExposure;
+        private _hdrAutoExposure;
         private _hdrCurrentLuminance;
         private _floatTextureType;
         private _ratio;
@@ -94325,9 +94338,8 @@ declare module BABYLON {
         protected _checkLimits(): void;
         /**
          * Rebuilds angles (alpha, beta) and radius from the give position and target
-         * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
          */
-        rebuildAnglesAndRadius(updateView?: boolean): void;
+        rebuildAnglesAndRadius(): void;
         /**
          * Use a position to define the current camera related information like aplha, beta and radius
          * @param position Defines the position to set the camera at
@@ -106801,6 +106813,7 @@ declare module BABYLON {
         private _fixedTimeStep;
         private _cannonRaycastResult;
         private _raycastResult;
+        private _removeAfterStep;
         BJSCANNON: any;
         constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
         setGravity(gravity: Vector3): void;
@@ -112700,8 +112713,11 @@ declare module BABYLON {
          */
         horizontalBlur: boolean;
         /**
-         * Sets the overall exposure used by the pipeline
+         * Gets the overall exposure used by the pipeline
          */
+        /**
+        * Sets the overall exposure used by the pipeline
+        */
         exposure: number;
         /**
          * Texture used typically to simulate "dirty" on camera lens
@@ -112738,6 +112754,13 @@ declare module BABYLON {
          */
         hdrIncreaseRate: number;
         /**
+         * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
+         */
+        /**
+        * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
+        */
+        hdrAutoExposure: boolean;
+        /**
          * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
          */
         lensColorTexture: Nullable<Texture>;
@@ -112790,6 +112813,9 @@ declare module BABYLON {
         private _scene;
         private _currentDepthOfFieldSource;
         private _basePostProcess;
+        private _fixedExposure;
+        private _currentExposure;
+        private _hdrAutoExposure;
         private _hdrCurrentLuminance;
         private _floatTextureType;
         private _ratio;

+ 1 - 15
dist/preview release/viewer/babylon.viewer.d.ts

@@ -951,7 +951,7 @@ declare module BabylonViewer {
       * @param name the name of the custom optimizer configuration
       * @param upgrade set to true if you want to upgrade optimizer and false if you want to degrade
       */
-    export function getCustomOptimizerByName(name: string, upgrade?: boolean): typeof extendedUpgrade;
+    export function getCustomOptimizerByName(name: string, upgrade?: boolean): (sceneManager: SceneManager) => boolean;
     export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
 }
 declare module BabylonViewer {
@@ -1594,20 +1594,6 @@ declare module BabylonViewer {
     export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
 }
 declare module BabylonViewer {
-    /**
-        * A custom upgrade-oriented function configuration for the scene optimizer.
-        *
-        * @param viewer the viewer to optimize
-        */
-    export function extendedUpgrade(sceneManager: SceneManager): boolean;
-    /**
-        * A custom degrade-oriented function configuration for the scene optimizer.
-        *
-        * @param viewer the viewer to optimize
-        */
-    export function extendedDegrade(sceneManager: SceneManager): boolean;
-}
-declare module BabylonViewer {
     export interface IEnvironmentMapConfiguration {
             /**
                 * Environment map texture path in relative to the asset folder.

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 12 - 12
dist/preview release/viewer/babylon.viewer.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


+ 1 - 18
dist/preview release/viewer/babylon.viewer.module.d.ts

@@ -1031,14 +1031,13 @@ declare module 'babylonjs-viewer/templating/viewerTemplatePlugin' {
 }
 
 declare module 'babylonjs-viewer/optimizer/custom' {
-    import { extendedUpgrade } from "babylonjs-viewer/optimizer/custom/extended";
     import { SceneManager } from "babylonjs-viewer/managers/sceneManager";
     /**
       *
       * @param name the name of the custom optimizer configuration
       * @param upgrade set to true if you want to upgrade optimizer and false if you want to degrade
       */
-    export function getCustomOptimizerByName(name: string, upgrade?: boolean): typeof extendedUpgrade;
+    export function getCustomOptimizerByName(name: string, upgrade?: boolean): (sceneManager: SceneManager) => boolean;
     export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
 }
 
@@ -1738,22 +1737,6 @@ declare module 'babylonjs-viewer/loader/plugins' {
     export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
 }
 
-declare module 'babylonjs-viewer/optimizer/custom/extended' {
-    import { SceneManager } from 'babylonjs-viewer/managers/sceneManager';
-    /**
-        * A custom upgrade-oriented function configuration for the scene optimizer.
-        *
-        * @param viewer the viewer to optimize
-        */
-    export function extendedUpgrade(sceneManager: SceneManager): boolean;
-    /**
-        * A custom degrade-oriented function configuration for the scene optimizer.
-        *
-        * @param viewer the viewer to optimize
-        */
-    export function extendedDegrade(sceneManager: SceneManager): boolean;
-}
-
 declare module 'babylonjs-viewer/configuration/interfaces' {
     export * from 'babylonjs-viewer/configuration/interfaces/cameraConfiguration';
     export * from 'babylonjs-viewer/configuration/interfaces/colorGradingConfiguration';

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

@@ -132,7 +132,8 @@
 - DeviceOrientationCamera will no longer be modified by mouse input if the orientation sensor is active ([TrevorDev](https://github.com/TrevorDev))
 - Added LoadScriptAsync tools helper function [MackeyK24](https://github.com/mackeyk24))  
 - Added customShaderNameResolve to PBRMaterialBase to allow subclasses to specify custom shader information [MackeyK24](https://github.com/mackeyk24))
-- Added PBRCustomMaterial to material library to allow easy subclassing of PBR materials [MackeyK24](https://github.com/mackeyk24))    
+- Added PBRCustomMaterial to material library to allow easy subclassing of PBR materials [MackeyK24](https://github.com/mackeyk24))
+- Added `auto-exposure` support in `StandardRenderingPipeline` when `HDR` is enabled ([julien-moreau](https://github.com/julien-moreau))
 
 ### OBJ Loader
 - Add color vertex support (not part of standard) ([brianzinn](https://github.com/brianzinn))
@@ -211,6 +212,7 @@
 - AssetContainer should not dispose objects it doesn't contain. Support for environmentTexture add/remove ([TrevorDev](https://github.com/TrevorDev))
 - Fix `mesh.visibility` not working properly when certain material properties are set that changes the interpretation of alpha (e.g. refraction, specular over alpha, etc.) ([bghgary](https://github.com/bghgary))
 - Fix material and texture leak when loading/removing GLTF with AssetContainer ([TrevorDev](https://github.com/TrevorDev))
+- Avoid exception when removing impostor during cannon world step ([TrevorDev](https://github.com/TrevorDev))
 
 ### Core Engine
 - Fixed a bug with `mesh.alwaysSelectAsActiveMesh` preventing layerMask to be taken in account ([Deltakosh](https://github.com/deltakosh))

+ 2 - 7
src/Cameras/arcRotateCamera.ts

@@ -856,13 +856,8 @@ export class ArcRotateCamera extends TargetCamera {
 
     /**
      * Rebuilds angles (alpha, beta) and radius from the give position and target
-     * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
      */
-    public rebuildAnglesAndRadius(updateView = true): void {
-        if (updateView) {
-            this.getViewMatrix(); // Force position update
-        }
-
+    public rebuildAnglesAndRadius(): void {
         this._position.subtractToRef(this._getTargetPosition(), this._computationVector);
         this.radius = this._computationVector.length();
 
@@ -893,7 +888,7 @@ export class ArcRotateCamera extends TargetCamera {
         }
         this._position.copyFrom(position);
 
-        this.rebuildAnglesAndRadius(false);
+        this.rebuildAnglesAndRadius();
     }
 
     /**

+ 10 - 1
src/Physics/Plugins/cannonJSPlugin.ts

@@ -21,6 +21,7 @@ export class CannonJSPlugin implements IPhysicsEnginePlugin {
     private _fixedTimeStep: number = 1 / 60;
     private _cannonRaycastResult: any;
     private _raycastResult: PhysicsRaycastResult;
+    private _removeAfterStep = new Array<PhysicsImpostor>();
     //See https://github.com/schteppe/CANNON.js/blob/gh-pages/demos/collisionFilter.html
     public BJSCANNON: any;
 
@@ -54,6 +55,12 @@ export class CannonJSPlugin implements IPhysicsEnginePlugin {
 
     public executeStep(delta: number): void {
         this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
+        if (this._removeAfterStep.length > 0) {
+            this._removeAfterStep.forEach((impostor) => {
+                this.world.remove(impostor.physicsBody);
+            });
+            this._removeAfterStep = [];
+        }
     }
 
     public applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3) {
@@ -165,7 +172,9 @@ export class CannonJSPlugin implements IPhysicsEnginePlugin {
         impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
         this.world.removeEventListener("preStep", impostor.beforeStep);
         this.world.removeEventListener("postStep", impostor.afterStep);
-        this.world.remove(impostor.physicsBody);
+
+        // Only remove the physics body after the physics step to avoid disrupting cannon's internal state
+        this._removeAfterStep.push(impostor);
     }
 
     public generateJoint(impostorJoint: PhysicsImpostorJoint) {

+ 1 - 2
src/Physics/physicsEngine.ts

@@ -117,8 +117,7 @@ export class PhysicsEngine implements IPhysicsEngine {
             var removed = this._impostors.splice(index, 1);
             //Is it needed?
             if (removed.length) {
-                //this will also remove it from the world.
-                removed[0].physicsBody = null;
+                this.getPhysicsPlugin().removePhysicsBody(impostor);
             }
         }
     }

+ 46 - 7
src/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts

@@ -146,10 +146,19 @@ export class StandardRenderingPipeline extends PostProcessRenderPipeline impleme
     public horizontalBlur: boolean = false;
 
     /**
-     * Sets the overall exposure used by the pipeline
+     * Gets the overall exposure used by the pipeline
      */
     @serialize()
-    public exposure: number = 1.0;
+    public get exposure(): number {
+        return this._fixedExposure;
+    }
+    /**
+     * Sets the overall exposure used by the pipeline
+     */
+    public set exposure(value: number) {
+        this._fixedExposure = value;
+        this._currentExposure = value;
+    }
 
     /**
      * Texture used typically to simulate "dirty" on camera lens
@@ -194,6 +203,26 @@ export class StandardRenderingPipeline extends PostProcessRenderPipeline impleme
      */
     @serialize()
     public hdrIncreaseRate: number = 0.5;
+    /**
+     * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
+     */
+    @serialize()
+    public get hdrAutoExposure(): boolean {
+        return this._hdrAutoExposure;
+    }
+    /**
+     * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
+     */
+    public set hdrAutoExposure(value: boolean) {
+        this._hdrAutoExposure = value;
+        if (this.hdrPostProcess) {
+            const defines = ["#define HDR"];
+            if (value) {
+                defines.push("#define AUTO_EXPOSURE");
+            }
+            this.hdrPostProcess.updateEffect(defines.join("\n"));
+        }
+    }
 
     /**
      * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
@@ -263,6 +292,9 @@ export class StandardRenderingPipeline extends PostProcessRenderPipeline impleme
     private _currentDepthOfFieldSource: Nullable<PostProcess> = null;
     private _basePostProcess: Nullable<PostProcess>;
 
+    private _fixedExposure: number = 1.0;
+    private _currentExposure: number = 1.0;
+    private _hdrAutoExposure: boolean = false;
     private _hdrCurrentLuminance: number = 1.0;
 
     private _floatTextureType: number;
@@ -675,7 +707,7 @@ export class StandardRenderingPipeline extends PostProcessRenderPipeline impleme
             effect.setTextureFromPostProcess("otherSampler", this._vlsEnabled ? this._currentDepthOfFieldSource : this.originalPostProcess);
             effect.setTexture("lensSampler", this.lensTexture);
 
-            effect.setFloat("exposure", this.exposure);
+            effect.setFloat("exposure", this._currentExposure);
 
             this._currentDepthOfFieldSource = this.textureAdderFinalPostProcess;
         };
@@ -824,7 +856,11 @@ export class StandardRenderingPipeline extends PostProcessRenderPipeline impleme
 
     // Create HDR post-process
     private _createHdrPostProcess(scene: Scene, ratio: number): void {
-        this.hdrPostProcess = new PostProcess("HDR", "standard", ["averageLuminance"], ["textureAdderSampler"], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define HDR", Constants.TEXTURETYPE_UNSIGNED_INT);
+        const defines = ["#define HDR"];
+        if (this._hdrAutoExposure) {
+            defines.push("#define AUTO_EXPOSURE");
+        }
+        this.hdrPostProcess = new PostProcess("HDR", "standard", ["averageLuminance"], ["textureAdderSampler"], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, defines.join("\n"), Constants.TEXTURETYPE_UNSIGNED_INT);
 
         var outputLiminance = 1;
         var time = 0;
@@ -851,9 +887,12 @@ export class StandardRenderingPipeline extends PostProcessRenderPipeline impleme
                 }
             }
 
-            outputLiminance = Scalar.Clamp(outputLiminance, this.hdrMinimumLuminance, 1e20);
-
-            effect.setFloat("averageLuminance", outputLiminance);
+            if (this.hdrAutoExposure) {
+                this._currentExposure = this._fixedExposure / outputLiminance;
+            } else {
+                outputLiminance = Scalar.Clamp(outputLiminance, this.hdrMinimumLuminance, 1e20);
+                effect.setFloat("averageLuminance", outputLiminance);
+            }
 
             lastTime = time;
 

+ 4 - 1
src/Shaders/standard.fragment.fx

@@ -251,11 +251,14 @@ uniform float averageLuminance;
 void main()
 {
 	vec4 color = texture2D(textureAdderSampler, vUV);
+
+	#ifndef AUTO_EXPOSURE
 	vec4 adjustedColor = color / averageLuminance;
 
 	color = adjustedColor;
 	color.a = 1.0;
-
+	#endif
+	
 	gl_FragColor = color;
 }
 #endif

BIN
tests/validation/ReferenceImages/DefaultRenderingPipeline.png


BIN
tests/validation/ReferenceImages/clipplanes.png


BIN
tests/validation/ReferenceImages/pbrglossy.png


BIN
tests/validation/ReferenceImages/pbrrough.png


BIN
tests/validation/ReferenceImages/shadowOnlyMaterial.png


+ 2 - 2
what's new.md

@@ -193,7 +193,7 @@
 - Fixed issue where VRExperienceHelper.onExitingVR observable was being fired twice ([atulyar](https://github.com/atulyar))
 - Avoid firing onExitingVR observable multiple times when calling exitVR() and add observables to Viewer that can be used instead of the ones in VRExperienceHelper ([atulyar](https://github.com/atulyar))
 - GizmoManager should hide existing gizmos if a non-attachable mesh is selected ([TrevorDev](https://github.com/TrevorDev))
-- Ignore isPickable = false for vr ray casting if the mesh's name matches the specified floorMeshName to maintain backwards compatability ([TrevorDev](https://github.com/TrevorDev))
+- Ignore isPickable = false for vr ray casting if the mesh's name matches the specified floorMeshName to maintain backwards compatibility ([TrevorDev](https://github.com/TrevorDev))
 - Fix File Loading if hosted from `file:`-Protocol ([ltetzlaff](https://github.com/ltetzlaff))
 - Do not throw error when updating a controller with no left stick ([TrevorDev](https://github.com/TrevorDev))
 - Exiting VR can result in messed up view ([TrevorDev](https://github.com/TrevorDev))
@@ -236,7 +236,7 @@
 - Animation navbar now updates correctly when a new model is loaded ([RaananW](https://github.com/RaananW))
 - Non-normalized meshes didn't center and focus correctly ([RaananW](https://github.com/RaananW))
 - Meshes with skeletons could have incorrect animations ([RaananW](https://github.com/RaananW))
-- Removed element IDs from viewer's templates to allow muitiple viewers in a single page ([RaananW](https://github.com/RaananW))
+- Removed element IDs from viewer's templates to allow multiple viewers in a single page ([RaananW](https://github.com/RaananW))
 - Viewer is not using Engine.LastCreatedScene anymore, to support multiple viewers in a single page ([RaananW](https://github.com/RaananW))
 - Template location was ignored if html was defined ([RaananW](https://github.com/RaananW))
 - Drag and Drop only worked if a model was already loaded before ([RaananW](https://github.com/RaananW))