Skip to content

Commit

Permalink
chore: seed SSAO kernel generation to avoid flaky SSAO visual test (#…
Browse files Browse the repository at this point in the history
…3415)

* chore: seed SSAO kernel generation to avoid flaky SSAO visual test
  • Loading branch information
haakonflatval-cognite authored Jun 26, 2023
1 parent 97796ca commit 65c4001
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions viewer/packages/rendering/src/render-passes/SSAOPass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { SsaoParameters } from '../rendering/types';
import { RenderPass } from '../RenderPass';
import { createFullScreenTriangleMesh, unitOrthographicCamera } from '../utilities/renderUtilities';

import SeededRandom from 'random-seed';

export class SSAOPass implements RenderPass {
private readonly _fullScreenTriangle: THREE.Mesh;
private readonly _ssaoShaderMaterial: THREE.RawShaderMaterial;
Expand Down Expand Up @@ -63,14 +65,15 @@ export class SSAOPass implements RenderPass {
}

private createKernel(kernelSize: number): THREE.Vector3[] {
const random = SeededRandom.create('some_seed');
const result: THREE.Vector3[] = [];
for (let i = 0; i < kernelSize; i++) {
const sample = new THREE.Vector3(1, 1, 1);
while (sample.length() > 1.0) {
// Ensure some distance in samples
sample.x = Math.random() * 2 - 1;
sample.y = Math.random() * 2 - 1;
sample.z = Math.random();
sample.x = random.random() * 2 - 1;
sample.y = random.random() * 2 - 1;
sample.z = random.random();
}
sample.normalize();
let scale = i / kernelSize;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 65c4001

Please sign in to comment.