Skip to content

Commit 0d1e2d7

Browse files
authored
TSL: Use multi argument versions of min and max (#31196)
1 parent 8a7655d commit 0d1e2d7

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

examples/jsm/tsl/display/FXAANode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ class FXAANode extends TempNode {
123123
const se = SampleLuminanceOffset( texSize, uv, 1.0, 1.0 );
124124
const sw = SampleLuminanceOffset( texSize, uv, - 1.0, 1.0 );
125125

126-
const highest = max( max( max( max( s, e ), n ), w ), m );
127-
const lowest = min( min( min( min( s, e ), n ), w ), m );
126+
const highest = max( s, e, n, w, m );
127+
const lowest = min( s, e, n, w, m );
128128
const contrast = highest.sub( lowest );
129129

130130
return { m, n, e, s, w, ne, nw, se, sw, highest, lowest, contrast };

examples/jsm/tsl/display/SMAANode.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,11 @@ class SMAANode extends TempNode {
321321
// Calculate left and top deltas:
322322
const Cleft = this.textureNode.sample( vOffset0.xy ).rgb.toVar();
323323
let t = abs( C.sub( Cleft ) );
324-
delta.x = max( max( t.r, t.g ), t.b );
324+
delta.x = max( t.r, t.g, t.b );
325325

326326
const Ctop = this.textureNode.sample( vOffset0.zw ).rgb.toVar();
327327
t = abs( C.sub( Ctop ) );
328-
delta.y = max( max( t.r, t.g ), t.b );
328+
delta.y = max( t.r, t.g, t.b );
329329

330330
// We do the usual threshold:
331331
const edges = step( threshold, delta.xy ).toVar();
@@ -336,26 +336,26 @@ class SMAANode extends TempNode {
336336
// Calculate right and bottom deltas:
337337
const Cright = this.textureNode.sample( vOffset1.xy ).rgb.toVar();
338338
t = abs( C.sub( Cright ) );
339-
delta.z = max( max( t.r, t.g ), t.b );
339+
delta.z = max( t.r, t.g, t.b );
340340

341341
const Cbottom = this.textureNode.sample( vOffset1.zw ).rgb.toVar();
342342
t = abs( C.sub( Cbottom ) );
343-
delta.w = max( max( t.r, t.g ), t.b );
343+
delta.w = max( t.r, t.g, t.b );
344344

345345
// Calculate the maximum delta in the direct neighborhood:
346-
let maxDelta = max( max( max( delta.x, delta.y ), delta.z ), delta.w ).toVar();
346+
let maxDelta = max( delta.x, delta.y, delta.z, delta.w ).toVar();
347347

348348
// Calculate left-left and top-top deltas:
349349
const Cleftleft = this.textureNode.sample( vOffset2.xy ).rgb.toVar();
350350
t = abs( C.sub( Cleftleft ) );
351-
delta.z = max( max( t.r, t.g ), t.b );
351+
delta.z = max( t.r, t.g, t.b );
352352

353353
const Ctoptop = this.textureNode.sample( vOffset2.zw ).rgb.toVar();
354354
t = abs( C.sub( Ctoptop ) );
355-
delta.w = max( max( t.r, t.g ), t.b );
355+
delta.w = max( t.r, t.g, t.b );
356356

357357
// Calculate the final maximum delta:
358-
maxDelta = max( max( maxDelta, delta.z ), delta.w );
358+
maxDelta = max( maxDelta, delta.z, delta.w );
359359

360360
// Local contrast adaptation in action:
361361
edges.xy.mulAssign( vec2( step( float( 0.5 ).mul( maxDelta ), delta.xy ) ) );

examples/jsm/tsl/display/TRAAPassNode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ class TRAAPassNode extends PassNode {
380380
const currentWeight = float( 0.05 ).toVar();
381381
const historyWeight = currentWeight.oneMinus().toVar();
382382

383-
const compressedCurrent = currentColor.mul( float( 1 ).div( ( max( max( currentColor.r, currentColor.g ), currentColor.b ).add( 1.0 ) ) ) );
384-
const compressedHistory = clampedHistoryColor.mul( float( 1 ).div( ( max( max( clampedHistoryColor.r, clampedHistoryColor.g ), clampedHistoryColor.b ).add( 1.0 ) ) ) );
383+
const compressedCurrent = currentColor.mul( float( 1 ).div( ( max( currentColor.r, currentColor.g, currentColor.b ).add( 1.0 ) ) ) );
384+
const compressedHistory = clampedHistoryColor.mul( float( 1 ).div( ( max( clampedHistoryColor.r, clampedHistoryColor.g, clampedHistoryColor.b ).add( 1.0 ) ) ) );
385385

386386
const luminanceCurrent = luminance( compressedCurrent.rgb );
387387
const luminanceHistory = luminance( compressedHistory.rgb );

src/nodes/functions/material/getParallaxCorrectNormal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const getParallaxCorrectNormal = /*@__PURE__*/ Fn( ( [ normal, cubeSize, cubePos
2828
rbminmax.y = nDir.y.greaterThan( float( 0 ) ).select( rbmax.y, rbmin.y );
2929
rbminmax.z = nDir.z.greaterThan( float( 0 ) ).select( rbmax.z, rbmin.z );
3030

31-
const correction = min( min( rbminmax.x, rbminmax.y ), rbminmax.z ).toVar();
31+
const correction = min( rbminmax.x, rbminmax.y, rbminmax.z ).toVar();
3232
const boxIntersection = positionWorld.add( nDir.mul( correction ) ).toVar();
3333
return boxIntersection.sub( cubePos );
3434

src/nodes/materialx/lib/mx_noise.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ export const mx_worley_distance_1 = /*@__PURE__*/ Fn( ( [ p_immutable, x_immutab
10041004

10051005
If( metric.equal( int( 3 ) ), () => {
10061006

1007-
return max( max( abs( diff.x ), abs( diff.y ) ), abs( diff.z ) );
1007+
return max( abs( diff.x ), abs( diff.y ), abs( diff.z ) );
10081008

10091009
} );
10101010

0 commit comments

Comments
 (0)