Browse Source

Example `webgpu_backdrop_area`: Added blurred node (#26342)

sunag 2 years ago
parent
commit
3d857659ae
1 changed files with 12 additions and 2 deletions
  1. 12 2
      examples/webgpu_backdrop_area.html

+ 12 - 2
examples/webgpu_backdrop_area.html

@@ -79,7 +79,14 @@
 
 
 				// volume
 				// volume
 
 
-				const depthAlphaNode = depthTexture().distance( depth ).oneMinus().smoothstep( .90, 2 ).mul( 20 ).saturate();
+				const depthDistance = depthTexture().distance( depth );
+				const depthAlphaNode = depthDistance.oneMinus().smoothstep( .90, 2 ).mul( 20 ).saturate();
+				const depthBlurred = viewportMipTexture().bicubic( depthDistance.smoothstep( 0, .6 ).mul( 40 * 5 ).clamp( 0, 5 ) );
+
+				const blurredBlur = new MeshBasicNodeMaterial();
+				blurredBlur.backdropNode = depthBlurred.add( depthAlphaNode.mix( color( 0x0066ff ), 0 ) );
+				blurredBlur.transparent = true;
+				blurredBlur.side = THREE.DoubleSide;
 
 
 				const volumeMaterial = new MeshBasicNodeMaterial();
 				const volumeMaterial = new MeshBasicNodeMaterial();
 				volumeMaterial.colorNode = color( 0x0066ff );
 				volumeMaterial.colorNode = color( 0x0066ff );
@@ -133,6 +140,7 @@
 				// gui
 				// gui
 
 
 				const materials = {
 				const materials = {
+					'blurred': blurredBlur,
 					'volume': volumeMaterial,
 					'volume': volumeMaterial,
 					'depth': depthMaterial,
 					'depth': depthMaterial,
 					'bicubic': bicubicMaterial,
 					'bicubic': bicubicMaterial,
@@ -140,7 +148,9 @@
 				};
 				};
 
 
 				const gui = new GUI();
 				const gui = new GUI();
-				const options = { material: 'volume' };
+				const options = { material: 'blurred' };
+
+				box.material = materials[ options.material ];
 
 
 				gui.add( box.scale, 'x', 0.1, 2, 0.01 );
 				gui.add( box.scale, 'x', 0.1, 2, 0.01 );
 				gui.add( box.scale, 'z', 0.1, 2, 0.01 );
 				gui.add( box.scale, 'z', 0.1, 2, 0.01 );