Skip to content

Commit

Permalink
Merge pull request #13134 from BabylonJS/Popov72-patch-1
Browse files Browse the repository at this point in the history
Fix usage of useReverseDepthBuffer with orthographic cameras
  • Loading branch information
sebavan authored Oct 19, 2022
2 parents f05ce74 + a76bc2b commit c42b537
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/dev/core/src/Cameras/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ export class Camera extends Node {

const engine = this.getEngine();
const scene = this.getScene();
const reverseDepth = engine.useReverseDepthBuffer;
if (this.mode === Camera.PERSPECTIVE_CAMERA) {
this._cache.fov = this.fov;
this._cache.fovMode = this.fovMode;
Expand All @@ -886,7 +887,6 @@ export class Camera extends Node {
this.minZ = 0.1;
}

const reverseDepth = engine.useReverseDepthBuffer;
let getProjectionMatrix: (
fov: number,
aspect: number,
Expand All @@ -913,7 +913,7 @@ export class Camera extends Node {
this.fovMode === Camera.FOVMODE_VERTICAL_FIXED,
engine.isNDCHalfZRange,
this.projectionPlaneTilt,
engine.useReverseDepthBuffer
reverseDepth
);
} else {
const halfWidth = engine.getRenderWidth() / 2.0;
Expand All @@ -924,8 +924,8 @@ export class Camera extends Node {
this.orthoRight ?? halfWidth,
this.orthoBottom ?? -halfHeight,
this.orthoTop ?? halfHeight,
this.minZ,
this.maxZ,
reverseDepth ? this.maxZ : this.minZ,
reverseDepth ? this.minZ : this.maxZ,
this._projectionMatrix,
engine.isNDCHalfZRange
);
Expand All @@ -935,8 +935,8 @@ export class Camera extends Node {
this.orthoRight ?? halfWidth,
this.orthoBottom ?? -halfHeight,
this.orthoTop ?? halfHeight,
this.minZ,
this.maxZ,
reverseDepth ? this.maxZ : this.minZ,
reverseDepth ? this.minZ : this.maxZ,
this._projectionMatrix,
engine.isNDCHalfZRange
);
Expand Down

0 comments on commit c42b537

Please sign in to comment.