Skip to content

Commit ddeab78

Browse files
authored
Examples: Improve AA approach in WebGPU water demo. (#31354)
1 parent 287727d commit ddeab78

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

examples/webgpu_water.html

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030

3131
import * as THREE from 'three';
3232

33-
import { pass, mrt, output, emissive, color, screenUV } from 'three/tsl';
33+
import { pass, mrt, output, emissive, renderOutput } from 'three/tsl';
3434
import { bloom } from 'three/addons/tsl/display/BloomNode.js';
35+
import { fxaa } from 'three/addons/tsl/display/FXAANode.js';
3536

3637
import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
3738

@@ -59,7 +60,7 @@
5960

6061
const loader = new UltraHDRLoader();
6162
loader.setDataType( THREE.HalfFloatType );
62-
loader.load( `textures/equirectangular/moonless_golf_2k.hdr.jpg`, function ( texture ) {
63+
loader.load( 'textures/equirectangular/moonless_golf_2k.hdr.jpg', function ( texture ) {
6364

6465
texture.mapping = THREE.EquirectangularReflectionMapping;
6566
texture.needsUpdate = true;
@@ -163,7 +164,7 @@
163164

164165
// renderer
165166

166-
renderer = new THREE.WebGPURenderer( { antialias: true } );
167+
renderer = new THREE.WebGPURenderer();
167168
renderer.setSize( window.innerWidth, window.innerHeight );
168169
renderer.setPixelRatio( window.devicePixelRatio );
169170
renderer.setAnimationLoop( animate );
@@ -181,12 +182,15 @@
181182
emissive
182183
} ) );
183184

184-
const outputPass = scenePass.getTextureNode();
185+
const beautyPass = scenePass.getTextureNode();
185186
const emissivePass = scenePass.getTextureNode( 'emissive' );
186187

187188
const bloomPass = bloom( emissivePass, 2 );
188189

189-
postProcessing.outputNode = outputPass.add( bloomPass );
190+
const outputPass = renderOutput( beautyPass.add( bloomPass ) );
191+
192+
const fxaaPass = fxaa( outputPass );
193+
postProcessing.outputNode = fxaaPass;
190194

191195
// gui
192196

@@ -222,7 +226,7 @@
222226

223227
controls = new OrbitControls( camera, renderer.domElement );
224228
controls.enableDamping = true;
225-
controls.target.set( 0, 0, -5 );
229+
controls.target.set( 0, 0, - 5 );
226230
controls.update();
227231

228232
//

0 commit comments

Comments
 (0)