Skip to content

Commit

Permalink
cannot receive ao property
Browse files Browse the repository at this point in the history
  • Loading branch information
N8 committed Aug 14, 2024
1 parent 3b797d5 commit b660221
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 20 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,13 @@ You can also force N8AO to treat a transparent object as opaque (useful if you a
mesh.userData.treatAsOpaque = true;
```

You can also simply have an object not receive AO at all (this requires rendering it twice, so it is not recommended for performance-critical applications) by setting `cannotReceiveAO` to `true` in the object's `userData`:

```js
mesh.userData.cannotReceiveAO = false;
```


# Accumulation

When the camera is still, you can enable the accumulation of samples across frames, which will reduce noise and improve the quality of the AO effect. This is done by setting `configuration.accumulate` to `true`:
Expand Down
4 changes: 2 additions & 2 deletions dist/N8AO.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/N8AO.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions example/N8AO.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/N8AO.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions example_postprocessing/N8AO.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example_postprocessing/N8AO.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "n8ao",
"version": "1.8.3",
"version": "1.8.4",
"description": "An efficient and visually pleasing implementation of SSAO with an emphasis on temporal stability and artist control.",
"main": "dist/N8AO.js",
"scripts": {
Expand Down
9 changes: 4 additions & 5 deletions src/N8AOPass.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,15 @@ class N8AOPass extends Pass {
if (this.configuration.halfRes) {
this.depthDownsampleTarget = THREE.REVISION > 161 ? new THREE.WebGLRenderTarget(
this.width / 2,
this.height / 2,
{
count : 2
this.height / 2, {
count: 2
}
) : new THREE.WebGLMultipleRenderTargets(
this.width / 2,
this.height / 2,
2
);

if (THREE.REVISION <= 161) {
this.depthDownsampleTarget.textures = this.depthDownsampleTarget.texture;
}
Expand Down Expand Up @@ -353,7 +352,7 @@ class N8AOPass extends Pass {
renderer.setRenderTarget(this.transparencyRenderTargetDWFalse);
this.scene.traverse((obj) => {
if (obj.material) {
obj.visible = oldVisibility.get(obj) && obj.material.transparent && !obj.material.depthWrite && !obj.userData.treatAsOpaque;
obj.visible = oldVisibility.get(obj) && ((obj.material.transparent && !obj.material.depthWrite && !obj.userData.treatAsOpaque) || !!obj.userData.cannotReceiveAO);
}
});
renderer.clear(true, true, true);
Expand Down
9 changes: 4 additions & 5 deletions src/N8AOPostPass.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,8 @@ class N8AOPostPass extends Pass {
if (this.configuration.halfRes) {
this.depthDownsampleTarget = THREE.REVISION > 161 ? new THREE.WebGLRenderTarget(
this.width / 2,
this.height / 2,
{
count : 2
this.height / 2, {
count: 2
}
) : new THREE.WebGLMultipleRenderTargets(
this.width / 2,
Expand All @@ -252,7 +251,7 @@ class N8AOPostPass extends Pass {
if (THREE.REVISION <= 161) {
this.depthDownsampleTarget.textures = this.depthDownsampleTarget.texture;
}

this.depthDownsampleTarget.textures[0].format = THREE.RedFormat;
this.depthDownsampleTarget.textures[0].type = THREE.FloatType;
this.depthDownsampleTarget.textures[0].minFilter = THREE.NearestFilter;
Expand Down Expand Up @@ -361,7 +360,7 @@ class N8AOPostPass extends Pass {
renderer.setRenderTarget(this.transparencyRenderTargetDWFalse);
this.scene.traverse((obj) => {
if (obj.material) {
obj.visible = oldVisibility.get(obj) && obj.material.transparent && !obj.material.depthWrite && !obj.userData.treatAsOpaque;
obj.visible = oldVisibility.get(obj) && ((obj.material.transparent && !obj.material.depthWrite && !obj.userData.treatAsOpaque) || !!obj.userData.cannotReceiveAO);
}
});
renderer.clear(true, true, true);
Expand Down

0 comments on commit b660221

Please sign in to comment.