|
36 | 36 | <script type="module"> |
37 | 37 |
|
38 | 38 | import * as THREE from 'three/webgpu'; |
39 | | - import { sample, pass, mrt, context, screenUV, normalView, velocity, vec3, vec4, directionToColor, colorToDirection, colorSpaceToWorking } from 'three/tsl'; |
| 39 | + import { sample, pass, mrt, screenUV, normalView, velocity, vec3, vec4, directionToColor, colorToDirection, colorSpaceToWorking, builtinAOContext } from 'three/tsl'; |
40 | 40 | import { ao } from 'three/addons/tsl/display/GTAONode.js'; |
41 | 41 | import { traa } from 'three/addons/tsl/display/TRAANode.js'; |
42 | 42 |
|
|
49 | 49 |
|
50 | 50 | let camera, scene, renderer, postProcessing, controls; |
51 | 51 |
|
52 | | - let aoPass, traaPass; |
| 52 | + let aoPass, traaPass, transparentMesh; |
53 | 53 |
|
54 | 54 | const params = { |
55 | 55 | samples: 16, |
|
58 | 58 | radius: 0.25, |
59 | 59 | scale: 1, |
60 | 60 | thickness: 1, |
61 | | - aoOnly: false |
| 61 | + aoOnly: false, |
| 62 | + transparentOpacity: 0.3 |
62 | 63 | }; |
63 | 64 |
|
64 | 65 | init(); |
|
142 | 143 |
|
143 | 144 | // scene context |
144 | 145 |
|
145 | | - scenePass.contextNode = context( { |
146 | | - ao: aoPassOutput.sample( screenUV ).r |
147 | | - } ); |
| 146 | + scenePass.contextNode = builtinAOContext( aoPassOutput.sample( screenUV ).r ); |
148 | 147 |
|
149 | 148 | // final output + traa |
150 | 149 |
|
|
170 | 169 |
|
171 | 170 | // |
172 | 171 |
|
173 | | - const transparentMesh = new THREE.Mesh( new THREE.PlaneGeometry( 1.8, 2 ), new THREE.MeshStandardNodeMaterial( { transparent: true, opacity: .1 } ) ); |
174 | | - transparentMesh.material.transparent = true; |
| 172 | + transparentMesh = new THREE.Mesh( new THREE.PlaneGeometry( 1.8, 2 ), new THREE.MeshStandardNodeMaterial( { transparent: true, opacity: params.transparentOpacity } ) ); |
175 | 173 | transparentMesh.position.z = 0; |
176 | 174 | transparentMesh.position.y = 0.5; |
177 | 175 | transparentMesh.visible = false; |
|
192 | 190 | gui.add( params, 'thickness', 0.01, 2 ).onChange( updateParameters ); |
193 | 191 | gui.add( aoPass, 'useTemporalFiltering' ).name( 'temporal filtering' ); |
194 | 192 | gui.add( transparentMesh, 'visible' ).name( 'show transparent mesh' ); |
| 193 | + gui.add( params, 'transparentOpacity', 0, 1, 0.01 ).name( 'transparent opacity' ).onChange( updateParameters ); |
195 | 194 | gui.add( params, 'aoOnly' ).onChange( ( value ) => { |
196 | 195 |
|
197 | 196 | if ( value === true ) { |
|
220 | 219 | aoPass.scale.value = params.scale; |
221 | 220 | aoPass.thickness.value = params.thickness; |
222 | 221 |
|
| 222 | + transparentMesh.material.opacity = params.transparentOpacity; |
| 223 | + |
223 | 224 | } |
224 | 225 |
|
225 | 226 | function onWindowResize() { |
|
0 commit comments