Class UbershaderProvider

  • All Implemented Interfaces:
    MaterialProvider

    public class UbershaderProvider
    extends java.lang.Object
    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​(com.google.android.filament.Engine engine)
      Constructs an ubershader loader using the supplied Engine.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.google.android.filament.MaterialInstance createMaterialInstance​(MaterialProvider.MaterialKey config, int[] uvmap, java.lang.String label, java.lang.String extras)
      Creates or fetches a compiled Filament material, then creates an instance from it.
      void destroy()
      Frees memory associated with the native material provider.
      void destroyMaterials()
      Destroys all cached materials.
      com.google.android.filament.Material getMaterial​(MaterialProvider.MaterialKey config, int[] uvmap, java.lang.String label)
      Creates or fetches a compiled Filament material corresponding to the given config.
      com.google.android.filament.Material[] getMaterials()
      Creates and returns an array containing all cached materials.
      long getNativeObject()  
      boolean needsDummyData​(int attrib)
      Returns true if the presence of the given vertex attribute is required.
      • Methods inherited from class java.lang.Object

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

      • UbershaderProvider

        public UbershaderProvider​(com.google.android.filament.Engine engine)
        Constructs an ubershader loader using the supplied Engine.
        Parameters:
        engine - the engine used to create materials
    • Method Detail

      • destroy

        public void destroy()
        Frees memory associated with the native material provider.
        Specified by:
        destroy in interface MaterialProvider
      • createMaterialInstance

        @Nullable
        public com.google.android.filament.MaterialInstance createMaterialInstance​(MaterialProvider.MaterialKey config,
                                                                                   @NonNull @Size(min=8L)
                                                                                   int[] uvmap,
                                                                                   @Nullable
                                                                                   java.lang.String label,
                                                                                   @Nullable
                                                                                   java.lang.String extras)
        Description copied from interface: MaterialProvider
        Creates or fetches a compiled Filament material, then creates an instance from it.
        Specified by:
        createMaterialInstance in interface MaterialProvider
        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 uv index 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).
      • getMaterial

        @Nullable
        public com.google.android.filament.Material getMaterial​(MaterialProvider.MaterialKey config,
                                                                @NonNull @Size(min=8L)
                                                                int[] uvmap,
                                                                @Nullable
                                                                java.lang.String label)
        Description copied from interface: MaterialProvider
        Creates or fetches a compiled Filament material corresponding to the given config.
        Specified by:
        getMaterial in interface MaterialProvider
      • getMaterials

        @NonNull
        public com.google.android.filament.Material[] getMaterials()
        Description copied from interface: MaterialProvider
        Creates and returns an array containing all cached materials.
        Specified by:
        getMaterials in interface MaterialProvider
      • needsDummyData

        public boolean needsDummyData​(int attrib)
        Description copied from interface: MaterialProvider
        Returns true if the presence of the given vertex attribute is required. Some types of providers (e.g. ubershader) require dummy attribute values if 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.
        Specified by:
        needsDummyData in interface MaterialProvider
      • destroyMaterials

        public void destroyMaterials()
        Description copied from interface: MaterialProvider
        Destroys all cached materials. This is not called automatically when MaterialProvider is destroyed, which allows clients to take ownership of the cache if desired.
        Specified by:
        destroyMaterials in interface MaterialProvider
      • getNativeObject

        public long getNativeObject()