Skip to content

Commit ae575fd

Browse files
authored
Fix examples to avoid fading alpha (#33450)
1 parent 2e97f79 commit ae575fd

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

examples/jsm/tsl/display/PixelationPassNode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { NearestFilter, Vector4, TempNode, NodeUpdateType, PassNode } from 'three/webgpu';
2-
import { nodeObject, Fn, float, uv, uniform, convertToTexture, vec2, vec3, clamp, floor, dot, smoothstep, If, sign, step, mrt, output, normalView, property } from 'three/tsl';
2+
import { nodeObject, Fn, float, uv, uniform, convertToTexture, vec2, vec3, clamp, floor, dot, smoothstep, If, sign, step, mrt, output, normalView, property, vec4 } from 'three/tsl';
33

44
/**
55
* A inner node definition that implements the actual pixelation TSL code.
@@ -202,7 +202,7 @@ class PixelationNode extends TempNode {
202202

203203
const strength = dei.greaterThan( 0 ).select( float( 1.0 ).sub( dei.mul( this.depthEdgeStrength ) ), nei.mul( this.normalEdgeStrength ).add( 1 ) );
204204

205-
return texel.mul( strength );
205+
return vec4( texel.mul( strength ).rgb, texel.a );
206206

207207
} );
208208

examples/webgpu_mesh_batch.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
3939
import { radixSort } from 'three/addons/utils/SortUtils.js';
4040

41-
import { normalView, directionToColor, diffuseColor } from 'three/tsl';
41+
import { normalView, directionToColor, diffuseColor, vec4 } from 'three/tsl';
4242

4343
let camera, scene, renderer;
4444
let controls;
@@ -126,7 +126,10 @@
126126
if ( ! material ) {
127127

128128
material = new THREE.MeshBasicNodeMaterial();
129-
material.outputNode = diffuseColor.mul( directionToColor( normalView ).y.add( 0.5 ) );
129+
material.outputNode = vec4(
130+
diffuseColor.mul( directionToColor( normalView ).y.add( 0.5 ) ).rgb,
131+
diffuseColor.a,
132+
);
130133

131134
}
132135

examples/webgpu_postprocessing_motion_blur.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<script type="module">
3333

3434
import * as THREE from 'three/webgpu';
35-
import { pass, texture, uniform, output, mrt, velocity, uv, screenUV } from 'three/tsl';
35+
import { pass, texture, uniform, output, mrt, velocity, uv, screenUV, vec4 } from 'three/tsl';
3636
import { motionBlur } from 'three/addons/tsl/display/MotionBlur.js';
3737

3838
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
@@ -194,7 +194,7 @@
194194
const vignette = screenUV.distance( .5 ).remap( .6, 1 ).mul( 2 ).clamp().oneMinus();
195195

196196
renderPipeline = new THREE.RenderPipeline( renderer );
197-
renderPipeline.outputNode = mBlur.mul( vignette );
197+
renderPipeline.outputNode = vec4( mBlur.mul( vignette ).rgb, mBlur.a );
198198

199199
//
200200

0 commit comments

Comments
 (0)