Skip to content

Commit

Permalink
Merge pull request #340 from simularium/fix/orthographic-camera-ssao
Browse files Browse the repository at this point in the history
Fix/orthographic camera ssao
  • Loading branch information
toloudis authored Nov 1, 2023
2 parents 27bd70d + e196dd5 commit 14756f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/visGeometry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,13 @@ class VisGeometry {
const v = new Vector3();
this.boundingBox.getSize(v);
const maxDim = Math.max(v.x, v.y, v.z);
this.renderer.setNearFar(this.boxNearZ, this.boxFarZ, maxDim);
// this.camera.zoom accounts for perspective vs ortho cameras
this.renderer.setNearFar(
this.boxNearZ,
this.boxFarZ,
maxDim,
this.camera.zoom
);
this.boundingBoxMesh.visible = false;
this.tickMarksMesh.visible = false;
this.agentPathGroup.visible = false;
Expand Down
12 changes: 10 additions & 2 deletions src/visGeometry/rendering/SimulariumRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class SimulariumRenderer {
private boundsNear: number;
private boundsFar: number;
private boundsMaxDim: number;
private cameraZoom: number;

public constructor() {
this.parameters = {
Expand Down Expand Up @@ -99,6 +100,7 @@ class SimulariumRenderer {
this.boundsNear = 0.0;
this.boundsFar = 100.0;
this.boundsMaxDim = 100.0;
this.cameraZoom = 1.0;

this.gbufferPass = new GBufferPass();

Expand Down Expand Up @@ -322,10 +324,16 @@ class SimulariumRenderer {
this.drawBufferPass.resize(x, y);
}

public setNearFar(n: number, f: number, boxMaxDim: number): void {
public setNearFar(
n: number,
f: number,
boxMaxDim: number,
cameraZoom: number
): void {
this.boundsNear = n;
this.boundsFar = f;
this.boundsMaxDim = boxMaxDim;
this.cameraZoom = cameraZoom;
}

public render(
Expand All @@ -343,7 +351,7 @@ class SimulariumRenderer {
this.ssao1Pass.pass.material.uniforms.intensity.value =
this.parameters.ao1.intensity;
this.ssao1Pass.pass.material.uniforms.scale.value =
(this.parameters.ao1.scale * sceneSize) / 100.0;
(this.parameters.ao1.scale * sceneSize * this.cameraZoom) / 100.0;
this.ssao1Pass.pass.material.uniforms.kernelRadius.value =
this.parameters.ao1.kernelRadius;
this.ssao1Pass.pass.material.uniforms.minResolution.value =
Expand Down

0 comments on commit 14756f2

Please sign in to comment.