Package 

Class UbershaderProvider

  • All Implemented Interfaces:
    com.google.android.filament.gltfio.MaterialProvider

    
    public class UbershaderProvider
     implements MaterialProvider
                        

    Loads pre-generated ubershader materials that fulfill glTF requirements.

    This class is used by AssetLoader to create Filament materials. Client applications do not need to call methods on it.

    • Constructor Summary

      Constructors 
      Constructor Description
      UbershaderProvider(Engine engine) Constructs an ubershader loader using the supplied Engine.
    • Method Summary

      Modifier and Type Method Description
      void destroy() Frees memory associated with the native material provider.
      MaterialInstance createMaterialInstance(MaterialProvider.MaterialKey config, @NonNull() @Size(min = 8) Array<int> uvmap, @Nullable() String label, @Nullable() String extras) Creates or fetches a compiled Filament material, then creates an instance from it.
      Material getMaterial(MaterialProvider.MaterialKey config, @NonNull() @Size(min = 8) Array<int> uvmap, @Nullable() String label) Creates or fetches a compiled Filament material corresponding to the given config.
      Array<Material> getMaterials() Creates and returns an array containing all cached materials.
      boolean needsDummyData(int attrib) Returns true if the presence of the given vertex attribute is required.Some types of providers (e.g.
      void destroyMaterials() Destroys all cached materials.This is not called automatically when MaterialProvider is destroyed, which allowsclients to take ownership of the cache if desired.
      long getNativeObject()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UbershaderProvider

        UbershaderProvider(Engine engine)
        Constructs an ubershader loader using the supplied Engine.
        Parameters:
        engine - the engine used to create materials
    • Method Detail

      • destroy

         void destroy()

        Frees memory associated with the native material provider.

      • createMaterialInstance

        @Nullable() MaterialInstance createMaterialInstance(MaterialProvider.MaterialKey config, @NonNull() @Size(min = 8) Array<int> uvmap, @Nullable() String label, @Nullable() String extras)

        Creates or fetches a compiled Filament material, then creates an instance from it.

        Parameters:
        config - Specifies requirements; might be mutated due to resource constraints.
        uvmap - Output argument that gets populated with a small table that maps from a glTF uvindex to a Filament uv index (0 = UNUSED, 1 = UV0, 2 = UV1).
        label - Optional tag that is not a part of the cache key.
        extras - Optional extras as stringified JSON (not a part of the cache key).
      • needsDummyData

         boolean needsDummyData(int attrib)

        Returns true if the presence of the given vertex attribute is required.Some types of providers (e.g. ubershader) require dummy attribute valuesif the glTF model does not provide them.NOTE: The given attribute is the VertexAttribute enum casted to an integer.This is done to streamline the JNI work between Java and Native layers.

      • destroyMaterials

         void destroyMaterials()

        Destroys all cached materials.This is not called automatically when MaterialProvider is destroyed, which allowsclients to take ownership of the cache if desired.