babylon.oculusDistortionCorrectionPostProcess.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. var __extends = this.__extends || function (d, b) {
  2. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3. function __() { this.constructor = d; }
  4. __.prototype = b.prototype;
  5. d.prototype = new __();
  6. };
  7. var BABYLON;
  8. (function (BABYLON) {
  9. var OculusDistortionCorrectionPostProcess = (function (_super) {
  10. __extends(OculusDistortionCorrectionPostProcess, _super);
  11. //ANY
  12. function OculusDistortionCorrectionPostProcess(name, camera, isRightEye, cameraSettings) {
  13. var _this = this;
  14. _super.call(this, name, "oculusDistortionCorrection", [
  15. 'LensCenter',
  16. 'Scale',
  17. 'ScaleIn',
  18. 'HmdWarpParam'
  19. ], null, cameraSettings.PostProcessScaleFactor, camera, BABYLON.Texture.BILINEAR_SAMPLINGMODE, null, null);
  20. this._isRightEye = isRightEye;
  21. this._distortionFactors = cameraSettings.DistortionK;
  22. this._postProcessScaleFactor = cameraSettings.PostProcessScaleFactor;
  23. this._lensCenterOffset = cameraSettings.LensCenterOffset;
  24. this.onSizeChanged = function () {
  25. _this.aspectRatio = _this.width * .5 / _this.height;
  26. _this._scaleIn = new BABYLON.Vector2(2, 2 / _this.aspectRatio);
  27. _this._scaleFactor = new BABYLON.Vector2(.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  28. _this._lensCenter = new BABYLON.Vector2(_this._isRightEye ? 0.5 - _this._lensCenterOffset * 0.5 : 0.5 + _this._lensCenterOffset * 0.5, 0.5);
  29. };
  30. this.onApply = function (effect) {
  31. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  32. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  33. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  34. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  35. };
  36. }
  37. return OculusDistortionCorrectionPostProcess;
  38. })(BABYLON.PostProcess);
  39. BABYLON.OculusDistortionCorrectionPostProcess = OculusDistortionCorrectionPostProcess;
  40. })(BABYLON || (BABYLON = {}));
  41. //# sourceMappingURL=../PostProcess/babylon.oculusDistortionCorrectionPostProcess.js.map