浏览代码

VR cameras can disable distortion postprocess to get more performance

David Catuhe 10 年之前
父节点
当前提交
8bb397df80

+ 9 - 6
Babylon/Cameras/VR/babylon.vrCamera.js

@@ -22,7 +22,7 @@ var BABYLON;
     };
     var _VRInnerCamera = (function (_super) {
         __extends(_VRInnerCamera, _super);
-        function _VRInnerCamera(name, position, scene, isLeftEye) {
+        function _VRInnerCamera(name, position, scene, isLeftEye, compensateDistorsion) {
             _super.call(this, name, position, scene);
             this._workMatrix = new BABYLON.Matrix();
             this._actualUp = new BABYLON.Vector3(0, 0, 0);
@@ -34,8 +34,10 @@ var BABYLON;
             this._hMatrix = BABYLON.Matrix.Translation(isLeftEye ? h : -h, 0, 0);
             this.viewport = new BABYLON.Viewport(isLeftEye ? 0 : 0.5, 0, 0.5, 1.0);
             this._preViewMatrix = BABYLON.Matrix.Translation(isLeftEye ? .5 * DefaultVRConstants.InterpupillaryDistance : -.5 * DefaultVRConstants.InterpupillaryDistance, 0, 0);
-            // Postprocess
-            var postProcess = new BABYLON.VRDistortionCorrectionPostProcess("VR Distortion", this, !isLeftEye, DefaultVRConstants);
+            if (compensateDistorsion) {
+                // Postprocess
+                var postProcess = new BABYLON.VRDistortionCorrectionPostProcess("VR Distortion", this, !isLeftEye, DefaultVRConstants);
+            }
         }
         _VRInnerCamera.prototype.getProjectionMatrix = function () {
             BABYLON.Matrix.PerspectiveFovLHToRef(this._aspectRatioFov, this._aspectRatioAspectRatio, this.minZ, this.maxZ, this._workMatrix);
@@ -56,10 +58,11 @@ var BABYLON;
     })(BABYLON.FreeCamera);
     var VRCamera = (function (_super) {
         __extends(VRCamera, _super);
-        function VRCamera(name, position, scene) {
+        function VRCamera(name, position, scene, compensateDistorsion) {
+            if (compensateDistorsion === void 0) { compensateDistorsion = true; }
             _super.call(this, name, position, scene);
-            this._leftCamera = new _VRInnerCamera(name + "_left", position.clone(), scene, true);
-            this._rightCamera = new _VRInnerCamera(name + "_right", position.clone(), scene, false);
+            this._leftCamera = new _VRInnerCamera(name + "_left", position.clone(), scene, true, compensateDistorsion);
+            this._rightCamera = new _VRInnerCamera(name + "_right", position.clone(), scene, false, compensateDistorsion);
             this.subCameras.push(this._leftCamera);
             this.subCameras.push(this._rightCamera);
             this._deviceOrientationHandler = this._onOrientationEvent.bind(this);

+ 8 - 6
Babylon/Cameras/VR/babylon.vrCamera.ts

@@ -23,7 +23,7 @@
         private _preViewMatrix: Matrix;
         private _actualUp = new BABYLON.Vector3(0, 0, 0);
 
-        constructor(name: string, position: Vector3, scene: Scene, isLeftEye: boolean) {
+        constructor(name: string, position: Vector3, scene: Scene, isLeftEye: boolean, compensateDistorsion: boolean) {
             super(name, position, scene);
 
             // Constants
@@ -39,8 +39,10 @@
 
             this._preViewMatrix = BABYLON.Matrix.Translation(isLeftEye ? .5 * DefaultVRConstants.InterpupillaryDistance : -.5 * DefaultVRConstants.InterpupillaryDistance, 0, 0);
 
-            // Postprocess
-            var postProcess = new BABYLON.VRDistortionCorrectionPostProcess("VR Distortion", this, !isLeftEye, DefaultVRConstants);
+            if (compensateDistorsion) {
+                // Postprocess
+                var postProcess = new BABYLON.VRDistortionCorrectionPostProcess("VR Distortion", this, !isLeftEye, DefaultVRConstants);
+            }
         }
 
         public getProjectionMatrix(): Matrix {
@@ -71,11 +73,11 @@
         private _offsetOrientation: { yaw: number; pitch: number; roll: number };
         private _deviceOrientationHandler;
 
-        constructor(name: string, position: Vector3, scene: Scene) {
+        constructor(name: string, position: Vector3, scene: Scene, compensateDistorsion = true) {
             super(name, position, scene);
 
-            this._leftCamera = new _VRInnerCamera(name + "_left", position.clone(), scene, true);
-            this._rightCamera = new _VRInnerCamera(name + "_right", position.clone(), scene, false);
+            this._leftCamera = new _VRInnerCamera(name + "_left", position.clone(), scene, true, compensateDistorsion);
+            this._rightCamera = new _VRInnerCamera(name + "_right", position.clone(), scene, false, compensateDistorsion);
 
             this.subCameras.push(this._leftCamera);
             this.subCameras.push(this._rightCamera);

+ 9 - 6
babylon.2.1-beta.debug.js

@@ -23477,7 +23477,7 @@ var BABYLON;
     };
     var _VRInnerCamera = (function (_super) {
         __extends(_VRInnerCamera, _super);
-        function _VRInnerCamera(name, position, scene, isLeftEye) {
+        function _VRInnerCamera(name, position, scene, isLeftEye, compensateDistorsion) {
             _super.call(this, name, position, scene);
             this._workMatrix = new BABYLON.Matrix();
             this._actualUp = new BABYLON.Vector3(0, 0, 0);
@@ -23489,8 +23489,10 @@ var BABYLON;
             this._hMatrix = BABYLON.Matrix.Translation(isLeftEye ? h : -h, 0, 0);
             this.viewport = new BABYLON.Viewport(isLeftEye ? 0 : 0.5, 0, 0.5, 1.0);
             this._preViewMatrix = BABYLON.Matrix.Translation(isLeftEye ? .5 * DefaultVRConstants.InterpupillaryDistance : -.5 * DefaultVRConstants.InterpupillaryDistance, 0, 0);
-            // Postprocess
-            var postProcess = new BABYLON.VRDistortionCorrectionPostProcess("VR Distortion", this, !isLeftEye, DefaultVRConstants);
+            if (compensateDistorsion) {
+                // Postprocess
+                var postProcess = new BABYLON.VRDistortionCorrectionPostProcess("VR Distortion", this, !isLeftEye, DefaultVRConstants);
+            }
         }
         _VRInnerCamera.prototype.getProjectionMatrix = function () {
             BABYLON.Matrix.PerspectiveFovLHToRef(this._aspectRatioFov, this._aspectRatioAspectRatio, this.minZ, this.maxZ, this._workMatrix);
@@ -23511,10 +23513,11 @@ var BABYLON;
     })(BABYLON.FreeCamera);
     var VRCamera = (function (_super) {
         __extends(VRCamera, _super);
-        function VRCamera(name, position, scene) {
+        function VRCamera(name, position, scene, compensateDistorsion) {
+            if (compensateDistorsion === void 0) { compensateDistorsion = true; }
             _super.call(this, name, position, scene);
-            this._leftCamera = new _VRInnerCamera(name + "_left", position.clone(), scene, true);
-            this._rightCamera = new _VRInnerCamera(name + "_right", position.clone(), scene, false);
+            this._leftCamera = new _VRInnerCamera(name + "_left", position.clone(), scene, true, compensateDistorsion);
+            this._rightCamera = new _VRInnerCamera(name + "_right", position.clone(), scene, false, compensateDistorsion);
             this.subCameras.push(this._leftCamera);
             this.subCameras.push(this._rightCamera);
             this._deviceOrientationHandler = this._onOrientationEvent.bind(this);

文件差异内容过多而无法显示
+ 2 - 2
babylon.2.1-beta.js


文件差异内容过多而无法显示
+ 2 - 2
babylon.2.1-beta.noworker.js


+ 1 - 0
what's new - 2.1 - proposal.md

@@ -13,6 +13,7 @@
  - New Loaders folder with a first additionnal plugin: [STL](http://doc.babylonjs.com/page.php?p=25109)  ([raananw](http://www.github.com/raananw), [deltakosh](http://www.github.com/deltakosh))
  - Gulp building process revamped, updated and simplified and now includes a config.json ([raananw](http://www.github.com/raananw)) 
  - **Updates**
+ - VR cameras can disable distortion postprocess to get more performance ([deltakosh](http://www.github.com/deltakosh))
  - New ```MultiMaterial.clone()``` function ([deltakosh](http://www.github.com/deltakosh))
  - Faster ```mesh.computeNormals()``` function ([jbousquie](https://github.com/jbousquie))
  - Added the ability [to dynamically update or to morph](http://doc.babylonjs.com/page.php?p=25096) an mesh instance ([jbousquie](https://github.com/jbousquie))