Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/orthographic camera ssao #340

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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