Преглед изворни кода

TSL: Use multi argument versions of `min` and `max` (#31196)

Kristi K пре 7 месеци
родитељ
комит
0d1e2d738e

+ 2 - 2
examples/jsm/tsl/display/FXAANode.js

@@ -123,8 +123,8 @@ class FXAANode extends TempNode {
 			const se = SampleLuminanceOffset( texSize, uv, 1.0, 1.0 );
 			const sw = SampleLuminanceOffset( texSize, uv, - 1.0, 1.0 );
 
-			const highest = max( max( max( max( s, e ), n ), w ), m );
-			const lowest = min( min( min( min( s, e ), n ), w ), m );
+			const highest = max( s, e, n, w, m );
+			const lowest = min( s, e, n, w, m );
 			const contrast = highest.sub( lowest );
 
 			return { m, n, e, s, w, ne, nw, se, sw, highest, lowest, contrast };

+ 8 - 8
examples/jsm/tsl/display/SMAANode.js

@@ -321,11 +321,11 @@ class SMAANode extends TempNode {
 			// Calculate left and top deltas:
 			const Cleft = this.textureNode.sample( vOffset0.xy ).rgb.toVar();
 			let t = abs( C.sub( Cleft ) );
-			delta.x = max( max( t.r, t.g ), t.b );
+			delta.x = max( t.r, t.g, t.b );
 
 			const Ctop = this.textureNode.sample( vOffset0.zw ).rgb.toVar();
 			t = abs( C.sub( Ctop ) );
-			delta.y = max( max( t.r, t.g ), t.b );
+			delta.y = max( t.r, t.g, t.b );
 
 			// We do the usual threshold:
 			const edges = step( threshold, delta.xy ).toVar();
@@ -336,26 +336,26 @@ class SMAANode extends TempNode {
 			// Calculate right and bottom deltas:
 			const Cright = this.textureNode.sample( vOffset1.xy ).rgb.toVar();
 			t = abs( C.sub( Cright ) );
-			delta.z = max( max( t.r, t.g ), t.b );
+			delta.z = max( t.r, t.g, t.b );
 
 			const Cbottom = this.textureNode.sample( vOffset1.zw ).rgb.toVar();
 			t = abs( C.sub( Cbottom ) );
-			delta.w = max( max( t.r, t.g ), t.b );
+			delta.w = max( t.r, t.g, t.b );
 
 			// Calculate the maximum delta in the direct neighborhood:
-			let maxDelta = max( max( max( delta.x, delta.y ), delta.z ), delta.w ).toVar();
+			let maxDelta = max( delta.x, delta.y, delta.z, delta.w ).toVar();
 
 			// Calculate left-left and top-top deltas:
 			const Cleftleft = this.textureNode.sample( vOffset2.xy ).rgb.toVar();
 			t = abs( C.sub( Cleftleft ) );
-			delta.z = max( max( t.r, t.g ), t.b );
+			delta.z = max( t.r, t.g, t.b );
 
 			const Ctoptop = this.textureNode.sample( vOffset2.zw ).rgb.toVar();
 			t = abs( C.sub( Ctoptop ) );
-			delta.w = max( max( t.r, t.g ), t.b );
+			delta.w = max( t.r, t.g, t.b );
 
 			// Calculate the final maximum delta:
-			maxDelta = max( max( maxDelta, delta.z ), delta.w );
+			maxDelta = max( maxDelta, delta.z, delta.w );
 
 			// Local contrast adaptation in action:
 			edges.xy.mulAssign( vec2( step( float( 0.5 ).mul( maxDelta ), delta.xy ) ) );

+ 2 - 2
examples/jsm/tsl/display/TRAAPassNode.js

@@ -380,8 +380,8 @@ class TRAAPassNode extends PassNode {
 			const currentWeight = float( 0.05 ).toVar();
 			const historyWeight = currentWeight.oneMinus().toVar();
 
-			const compressedCurrent = currentColor.mul( float( 1 ).div( ( max( max( currentColor.r, currentColor.g ), currentColor.b ).add( 1.0 ) ) ) );
-			const compressedHistory = clampedHistoryColor.mul( float( 1 ).div( ( max( max( clampedHistoryColor.r, clampedHistoryColor.g ), clampedHistoryColor.b ).add( 1.0 ) ) ) );
+			const compressedCurrent = currentColor.mul( float( 1 ).div( ( max( currentColor.r, currentColor.g, currentColor.b ).add( 1.0 ) ) ) );
+			const compressedHistory = clampedHistoryColor.mul( float( 1 ).div( ( max( clampedHistoryColor.r, clampedHistoryColor.g, clampedHistoryColor.b ).add( 1.0 ) ) ) );
 
 			const luminanceCurrent = luminance( compressedCurrent.rgb );
 			const luminanceHistory = luminance( compressedHistory.rgb );

+ 1 - 1
src/nodes/functions/material/getParallaxCorrectNormal.js

@@ -28,7 +28,7 @@ const getParallaxCorrectNormal = /*@__PURE__*/ Fn( ( [ normal, cubeSize, cubePos
 	rbminmax.y = nDir.y.greaterThan( float( 0 ) ).select( rbmax.y, rbmin.y );
 	rbminmax.z = nDir.z.greaterThan( float( 0 ) ).select( rbmax.z, rbmin.z );
 
-	const correction = min( min( rbminmax.x, rbminmax.y ), rbminmax.z ).toVar();
+	const correction = min( rbminmax.x, rbminmax.y, rbminmax.z ).toVar();
 	const boxIntersection = positionWorld.add( nDir.mul( correction ) ).toVar();
 	return boxIntersection.sub( cubePos );
 

+ 1 - 1
src/nodes/materialx/lib/mx_noise.js

@@ -1004,7 +1004,7 @@ export const mx_worley_distance_1 = /*@__PURE__*/ Fn( ( [ p_immutable, x_immutab
 
 	If( metric.equal( int( 3 ) ), () => {
 
-		return max( max( abs( diff.x ), abs( diff.y ) ), abs( diff.z ) );
+		return max( abs( diff.x ), abs( diff.y ), abs( diff.z ) );
 
 	} );
 

粤ICP备19079148号