@@ -261,6 +261,20 @@ public enum CompilerPriorityQueue {
261261 LOW
262262 }
263263
264+ /**
265+ * Defines whether a material instance should use UBO batching or not.
266+ */
267+ public enum UboBatchingMode {
268+ /**
269+ * For default, it follows the engine settings.
270+ * If UBO batching is enabled on the engine and the material domain is SURFACE, it
271+ * turns on the UBO batching. Otherwise, it turns off the UBO batching.
272+ */
273+ DEFAULT ,
274+ /** Disable the Ubo Batching for this material */
275+ DISABLED
276+ }
277+
264278 public static class UserVariantFilterBit {
265279 /** Directional lighting */
266280 public static int DIRECTIONAL_LIGHTING = 0x01 ;
@@ -372,6 +386,7 @@ public enum ShadowSamplingQuality {
372386 private int mSize ;
373387 private int mShBandCount = 0 ;
374388 private ShadowSamplingQuality mShadowSamplingQuality = ShadowSamplingQuality .LOW ;
389+ private UboBatchingMode mUboBatchingMode = UboBatchingMode .DEFAULT ;
375390
376391
377392 /**
@@ -416,6 +431,17 @@ public Builder shadowSamplingQuality(ShadowSamplingQuality quality) {
416431 return this ;
417432 }
418433
434+ /**
435+ * Set the batching mode of the instances created from this material.
436+ * @param uboBatchingMode
437+ * @return Reference to this Builder for chaining calls.
438+ */
439+ @ NonNull
440+ public Builder uboBatching (UboBatchingMode mode ) {
441+ mUboBatchingMode = mode ;
442+ return this ;
443+ }
444+
419445 /**
420446 * Creates and returns the Material object.
421447 *
@@ -428,7 +454,7 @@ public Builder shadowSamplingQuality(ShadowSamplingQuality quality) {
428454 @ NonNull
429455 public Material build (@ NonNull Engine engine ) {
430456 long nativeMaterial = nBuilderBuild (engine .getNativeObject (),
431- mBuffer , mSize , mShBandCount , mShadowSamplingQuality .ordinal ());
457+ mBuffer , mSize , mShBandCount , mShadowSamplingQuality .ordinal (), mUboBatchingMode . ordinal () );
432458 if (nativeMaterial == 0 ) throw new IllegalStateException ("Couldn't create Material" );
433459 return new Material (nativeMaterial );
434460 }
@@ -1094,7 +1120,7 @@ void clearNativeObject() {
10941120 mNativeObject = 0 ;
10951121 }
10961122
1097- private static native long nBuilderBuild (long nativeEngine , @ NonNull Buffer buffer , int size , int shBandCount , int shadowQuality );
1123+ private static native long nBuilderBuild (long nativeEngine , @ NonNull Buffer buffer , int size , int shBandCount , int shadowQuality , int uboBatchingMode );
10981124 private static native long nCreateInstance (long nativeMaterial );
10991125 private static native long nCreateInstanceWithName (long nativeMaterial , @ NonNull String name );
11001126 private static native long nGetDefaultInstance (long nativeMaterial );
0 commit comments