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

How can i fixed this? #37

Open RyugaRyuzaki opened 1 week ago

RyugaRyuzaki commented 1 week ago

Hi i create n8ao with config :

   const {configuration} = this._n8ao;
    configuration.aoSamples = 16;
    configuration.denoiseSamples = 8;
    configuration.denoiseRadius = 12;
    configuration.aoRadius = 1;
    configuration.distanceFalloff = 4;
    configuration.intensity = 4;
    configuration.halfRes = true;
    configuration.color = new THREE.Color().setHex(0xcccccc, "srgb-linear");

renderer :

  this.renderer = new THREE.WebGLRenderer({
      canvas: this.canvas,
      context: this.canvas.getContext("webgl2")!,
      antialias: true,
      precision: "highp", // 'lowp', 'mediump', 'highp'
      alpha: false,
      stencil: false,
      powerPreference: "high-performance",
      logarithmicDepthBuffer: true,
      preserveDrawingBuffer: false,
    });
    this.renderer.setSize(width, height);

    this.renderer.setPixelRatio(pixelRatio);

    this.renderer.outputColorSpace = "srgb";

    this.renderer.localClippingEnabled = true;

    this.renderer.toneMapping = THREE.ACESFilmicToneMapping;

    this.renderer.toneMappingExposure = 1.2;

    this.renderer.shadowMap.enabled = true;

    this.renderer.shadowMap.type = THREE.VSMShadowMap;

    this.renderer.shadowMap.autoUpdate = false;

    this.renderer.shadowMap.needsUpdate = true;

    this.renderer.autoClearStencil = false;

    this.renderer.outputColorSpace = THREE.SRGBColorSpace;

    this.renderer.xr.enabled = true;

How ever when i rotate camera it looks not good like these image image

N8python commented 6 days ago

Turn off half res, increase bias, and reduce radius.

RyugaRyuzaki commented 6 days ago

It did not work!

N8python commented 5 days ago

could you send me a copy of your code? Ensure your depth buffer is high-precision.

RyugaRyuzaki commented 4 days ago

Hi, all code in upper.I copy exactly this

N8python commented 4 days ago

Okay - are you sure the scale of your scene is near the radius of N8AO. Try enabling screenSpaceRadius

RyugaRyuzaki commented 4 days ago

screenSpaceRadius

where can i enable "screenSpaceRadius"?

N8python commented 4 days ago

In 'configuration'.

RyugaRyuzaki commented 4 days ago

screenSpaceRadius

HI after change , it works but nothing different base renderer

  // this.composer.addPass(this.n8ao);
    const {configuration} = this._n8ao;
    configuration.aoSamples = 32;
    configuration.denoiseSamples = 1;
    configuration.denoiseRadius = 13;
    configuration.aoRadius = 1;
    configuration.distanceFalloff = 4;
    configuration.intensity = 5;
    configuration.halfRes = true;
    configuration.color = new THREE.Color().setHex(0xcccccc, "srgb-linear");
    configuration.screenSpaceRadius = true;

Base renderer

    this.renderer = new THREE.WebGLRenderer({
      canvas: this.canvas,
      context: this.canvas.getContext("webgl2")!,
      antialias: true,
      precision: "highp", // 'lowp', 'mediump', 'highp'
      stencil: false,
      powerPreference: "high-performance",
      logarithmicDepthBuffer: true,
      preserveDrawingBuffer: false,
    });
    this.renderer.setSize(width, height);

    this.renderer.setPixelRatio(pixelRatio);

    this.renderer.localClippingEnabled = true;

    this.renderer.toneMapping = THREE.ACESFilmicToneMapping;

    this.renderer.toneMappingExposure = 1.2;

    this.renderer.shadowMap.enabled = true;

    this.renderer.shadowMap.type = THREE.VSMShadowMap;

    this.renderer.shadowMap.autoUpdate = false;

    this.renderer.shadowMap.needsUpdate = true;

    this.renderer.autoClearStencil = false;

    this.renderer.outputColorSpace = THREE.SRGBColorSpace;

    this.renderer.xr.enabled = true;    

image

N8python commented 4 days ago

Increase the radius to ~48.

RyugaRyuzaki commented 2 days ago

Increase the radius to ~48.

It does not work. Btw i use unique vertices when i calculate posistion in this. And after create geometry i call geometry.computeVertexNormal() and material is :

  private readonly material = new THREE.MeshLambertMaterial({
    transparent: false,
    flatShading: true,
    side: THREE.DoubleSide,
    clipShadows: true,
    clipIntersection: true,
  });