Class UbershaderProvider
- java.lang.Object
-
- com.google.android.filament.gltfio.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
AssetLoaderto create Filament materials. Client applications do not need to call methods on it.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.android.filament.gltfio.MaterialProvider
MaterialProvider.MaterialKey
-
-
Constructor Summary
Constructors Constructor Description UbershaderProvider(com.google.android.filament.Engine engine)Constructs an ubershader loader using the suppliedEngine.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.android.filament.MaterialInstancecreateMaterialInstance(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.voiddestroy()Frees memory associated with the native material provider.voiddestroyMaterials()Destroys all cached materials.com.google.android.filament.MaterialgetMaterial(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.longgetNativeObject()booleanneedsDummyData(int attrib)Returns true if the presence of the given vertex attribute is required.
-
-
-
Method Detail
-
destroy
public void destroy()
Frees memory associated with the native material provider.- Specified by:
destroyin interfaceMaterialProvider
-
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:MaterialProviderCreates or fetches a compiled Filament material, then creates an instance from it.- Specified by:
createMaterialInstancein interfaceMaterialProvider- 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:MaterialProviderCreates or fetches a compiled Filament material corresponding to the given config.- Specified by:
getMaterialin interfaceMaterialProvider
-
getMaterials
@NonNull public com.google.android.filament.Material[] getMaterials()
Description copied from interface:MaterialProviderCreates and returns an array containing all cached materials.- Specified by:
getMaterialsin interfaceMaterialProvider
-
needsDummyData
public boolean needsDummyData(int attrib)
Description copied from interface:MaterialProviderReturns 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:
needsDummyDatain interfaceMaterialProvider
-
destroyMaterials
public void destroyMaterials()
Description copied from interface:MaterialProviderDestroys 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:
destroyMaterialsin interfaceMaterialProvider
-
getNativeObject
public long getNativeObject()
-
-