Skip to content

Commit af5a82a

Browse files
authored
BatchNode: Optimize genereated shader code. (#32203)
1 parent 46961fb commit af5a82a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/nodes/accessors/BatchNode.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ class BatchNode extends Node {
7474

7575
const getIndirectIndex = Fn( ( [ id ] ) => {
7676

77-
const size = int( textureSize( textureLoad( this.batchMesh._indirectTexture ), 0 ).x );
78-
const x = int( id ).mod( size );
79-
const y = int( id ).div( size );
77+
const size = int( textureSize( textureLoad( this.batchMesh._indirectTexture ), 0 ).x ).toConst();
78+
const x = int( id ).mod( size ).toConst();
79+
const y = int( id ).div( size ).toConst();
8080
return textureLoad( this.batchMesh._indirectTexture, ivec2( x, y ) ).x;
8181

8282
} ).setLayout( {
@@ -91,11 +91,11 @@ class BatchNode extends Node {
9191

9292
const matricesTexture = this.batchMesh._matricesTexture;
9393

94-
const size = int( textureSize( textureLoad( matricesTexture ), 0 ).x );
95-
const j = float( indirectId ).mul( 4 ).toInt().toVar();
94+
const size = int( textureSize( textureLoad( matricesTexture ), 0 ).x ).toConst();
95+
const j = float( indirectId ).mul( 4 ).toInt().toConst();
9696

97-
const x = j.mod( size );
98-
const y = j.div( size );
97+
const x = j.mod( size ).toConst();
98+
const y = j.div( size ).toConst();
9999
const batchingMatrix = mat4(
100100
textureLoad( matricesTexture, ivec2( x, y ) ),
101101
textureLoad( matricesTexture, ivec2( x.add( 1 ), y ) ),
@@ -110,10 +110,10 @@ class BatchNode extends Node {
110110

111111
const getBatchingColor = Fn( ( [ id ] ) => {
112112

113-
const size = int( textureSize( textureLoad( colorsTexture ), 0 ).x );
113+
const size = int( textureSize( textureLoad( colorsTexture ), 0 ).x ).toConst();
114114
const j = id;
115-
const x = j.mod( size );
116-
const y = j.div( size );
115+
const x = j.mod( size ).toConst();
116+
const y = j.div( size ).toConst();
117117
return textureLoad( colorsTexture, ivec2( x, y ) ).rgb;
118118

119119
} ).setLayout( {

0 commit comments

Comments
 (0)