v0.76
ITextureDeserializer(Texture Loader)¶
This interface allows you to customize texture loading.
UnityTextureDeserializer¶
UniVRM default implementation is UnityTextureDeserializer
.
ImageConversion.LoadImagecan be used to load png
and jpeg
.
Improve performance with ITextureDeserializer
Generating a Texture2D has multiple steps.
Extract
raw pixel
frompng
orjpeg
Create a
Texture2D
using the extractedraw pixel
Performance can be improved by putting the raw pixel fetch on a thread to make it asynchronous.
Warning
ImageConversion.LoadImage
performs raw pixel
extraction and Texture2D
creation at once, It blocks the main thread for the duration. If you load a large texture or a large amount of textures, the screen tends to freeze.
Extend supported image formats with ITextureDeserializer
glTF
can store png
and jpeg
as texture images.
If you want to use another format image with EXT_texture_webp
KHR_texture_basisu
etc. It can be handled by ITextureDeserializer
.
Replacement method¶
new UniGLTF.ImporterContext
Arguments can be specified.
public ImporterContext(
GltfData data,
IReadOnlyDictionary<SubAssetKey, UnityEngine.Object> externalObjectMap = null,
ITextureDeserializer textureDeserializer = null, // 👈
IMaterialDescriptorGenerator materialGenerator = null)
new VRM.VRMImporterContext
Arguments can be specified.
public VRMImporterContext(
VRMData data,
IReadOnlyDictionary<SubAssetKey, Object> externalObjectMap = null,
ITextureDeserializer textureDeserializer = null, // 👈
IMaterialDescriptorGenerator materialGenerator = null,
bool loadAnimation = false)
new UniVRM10.Vrm10Importer
Arguments can be specified.
public Vrm10Importer(
Vrm10Data vrm,
IReadOnlyDictionary<SubAssetKey, UnityEngine.Object> externalObjectMap = null,
ITextureDeserializer textureDeserializer = null, // 👈
IMaterialDescriptorGenerator materialGenerator = null,
bool useControlRig = false
)
Example to replace with UnityAsyncImageLoader¶
I got a usage example in ISSUE.
https://github.com/vrm-c/UniVRM/issues/1982
You can use UnityAsyncImageLoader to improve performance.