Skip to content
Merged
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
12 changes: 8 additions & 4 deletions examples/webgpu_postprocessing_ao.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<script type="module">

import * as THREE from 'three/webgpu';
import { pass, mrt, output, normalView, velocity, vec3, vec4 } from 'three/tsl';
import { pass, mrt, output, normalView, velocity, vec3, vec4, directionToColor } from 'three/tsl';
import { ao } from 'three/addons/tsl/display/GTAONode.js';
import { traa } from 'three/addons/tsl/display/TRAANode.js';

Expand Down Expand Up @@ -114,15 +114,19 @@
return scenePass.getLinearDepthNode();

} );
const scenePassNormal = scenePass.getTextureNode( 'normal' ).toInspector( 'Normal' );
const scenePassNormal = scenePass.getTextureNode( 'normal' ).toInspector( 'Normal', () => {

return directionToColor( scenePassNormal.sample() );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentional that .sample() doesn't take a parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, but it should be designed to work like TSL.texture(t, /* optional uv */)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


} );
const scenePassVelocity = scenePass.getTextureNode( 'velocity' ).toInspector( 'Velocity' );

// ao

aoPass = ao( scenePassDepth, scenePassNormal, camera ).toInspector( 'AO' );
aoPass = ao( scenePassDepth, scenePassNormal, camera );
aoPass.resolutionScale = 0.5; // running AO in half resolution is often sufficient
aoPass.useTemporalFiltering = true;
blendPassAO = vec4( scenePassColor.rgb.mul( aoPass.r ), scenePassColor.a ); // the AO is stored only in the red channel
blendPassAO = vec4( scenePassColor.rgb.mul( aoPass.r.toInspector( 'AO' ) ), scenePassColor.a ); // the AO is stored only in the red channel

// traa

Expand Down