N8python / n8ao

An efficient and visually pleasing implementation of SSAO with an emphasis on temporal stability and artist control.
Creative Commons Zero v1.0 Universal
378 stars 14 forks source link

1.9.0: Orthographic Camera support #33

Closed gpeu closed 2 months ago

gpeu commented 2 months ago

I think 1.9.0 introduced a typo:

https://github.com/N8python/n8ao/commit/c36cae48c26265c4d402738b4d8ffd52d5ec521d#diff-b2f10412321e2b27f8c3677485159748118b3e526673303c7d017ed5388e2ef0R431

-    configureDenoisePass(logarithmicDepthBuffer = false) {
+    configureDenoisePass(logarithmicDepthBuffer = false, ortho = false) {
        this.firstFrame();
        this.samplesDenoise = this.generateDenoiseSamples(this.configuration.denoiseSamples, 11);
        const p = {...PoissionBlur };
        p.fragmentShader = p.fragmentShader.replace("16", this.configuration.denoiseSamples);
        if (logarithmicDepthBuffer) {
            p.fragmentShader = "#define LOGDEPTH\n" + p.fragmentShader;
        }
+        if (ortho) {
+            e.fragmentShader = "#define ORTHO\n" + e.fragmentShader;
+        }
        if (this.poissonBlurQuad) {
            this.poissonBlurQuad.material.dispose();
            this.poissonBlurQuad.material = new THREE.ShaderMaterial(p);
        } else {
            this.poissonBlurQuad = new FullScreenTriangle(new THREE.ShaderMaterial(p));
        }
    }

The shader is p in the other function, but it is e in this one.

Unfortunately I failed to make the example work with an Orthographic camera. No AO shadow is visible with this change.

  // const camera = new THREE.PerspectiveCamera(75, clientWidth / clientHeight, 0.1, 1000);
  const camera = new THREE.OrthographicCamera();
N8python commented 2 months ago

This is true - multiple errors introduced. Expect a fix for 1.9.1

N8python commented 2 months ago

Orthographic camera support reintroduced. Log depth buffers don't work with ortho cameras.

gpeu commented 2 months ago

Yay! Well done