Skip to content

Commit 2054e99

Browse files
committed
improve shapeCircle
1 parent 567e6de commit 2054e99

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/nodes/shapes/Shapes.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Fn, float } from '../tsl/TSLBase.js';
1+
import { Fn, float, select } from '../tsl/TSLBase.js';
22
import { lengthSq, smoothstep } from '../math/MathNode.js';
33
import { uv } from '../accessors/UV.js';
44

@@ -12,18 +12,19 @@ import { uv } from '../accessors/UV.js';
1212
*/
1313
export const shapeCircle = Fn( ( [ coord = uv() ], { renderer, material } ) => {
1414

15-
const alpha = float( 1 ).toVar();
1615
const len2 = lengthSq( coord.mul( 2 ).sub( 1 ) );
1716

17+
let alpha;
18+
1819
if ( material.alphaToCoverage && renderer.samples > 1 ) {
1920

2021
const dlen = float( len2.fwidth() ).toVar();
2122

22-
alpha.assign( smoothstep( dlen.oneMinus(), dlen.add( 1 ), len2 ).oneMinus() );
23+
alpha = smoothstep( dlen.oneMinus(), dlen.add( 1 ), len2 ).oneMinus();
2324

2425
} else {
2526

26-
len2.greaterThan( 1.0 ).discard();
27+
alpha = select( len2.greaterThan( 1.0 ), 0, 1 );
2728

2829
}
2930

0 commit comments

Comments
 (0)