diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureSamplerUtil.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureSamplerUtil.cs index d150122cf..f69963c49 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureSamplerUtil.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureSamplerUtil.cs @@ -26,7 +26,7 @@ namespace UniGLTF public static glFilter ExportMinFilter(Texture2D texture) { - if (texture.mipmapCount > 0) + if (texture.mipmapCount > 1) { switch (texture.filterMode) { diff --git a/Assets/VRMShaders/GLTF/IO/Editor/TextureImporterConfigurator.cs b/Assets/VRMShaders/GLTF/IO/Editor/TextureImporterConfigurator.cs index 113c7ddac..8b19c2807 100644 --- a/Assets/VRMShaders/GLTF/IO/Editor/TextureImporterConfigurator.cs +++ b/Assets/VRMShaders/GLTF/IO/Editor/TextureImporterConfigurator.cs @@ -38,6 +38,14 @@ namespace VRMShaders textureImporter.SaveAndReimport(); } + public static void ConfigureSampler(TextureImportParam param, TextureImporter textureImporter) + { + textureImporter.mipmapEnabled = param.Sampler.EnableMipMap; + textureImporter.filterMode = param.Sampler.FilterMode; + textureImporter.wrapModeU = param.Sampler.WrapModesU; + textureImporter.wrapModeV = param.Sampler.WrapModesV; + } + class ImporterGetter : IDisposable { public TextureImporter Importer; @@ -110,6 +118,8 @@ namespace VRMShaders default: throw new NotImplementedException(); } + + ConfigureSampler(textureInfo, importer); } public static void Configure(TextureImportParam textureInfo, IDictionary ExternalMap) diff --git a/Assets/VRMShaders/GLTF/IO/Runtime/TextureExtensions.cs b/Assets/VRMShaders/GLTF/IO/Runtime/TextureExtensions.cs new file mode 100644 index 000000000..723f7d435 --- /dev/null +++ b/Assets/VRMShaders/GLTF/IO/Runtime/TextureExtensions.cs @@ -0,0 +1,23 @@ +using UnityEngine; + +namespace VRMShaders +{ + public static class TextureExtensions + { + public static bool HasMipMap(this Texture texture) + { + if (texture is Texture2D t2) + { + return t2.mipmapCount > 1; + } + else if (texture is RenderTexture rt) + { + return rt.useMipMap; + } + else + { + return false; + } + } + } +} diff --git a/Assets/VRMShaders/GLTF/IO/Runtime/TextureExtensions.cs.meta b/Assets/VRMShaders/GLTF/IO/Runtime/TextureExtensions.cs.meta new file mode 100644 index 000000000..1c4adbecc --- /dev/null +++ b/Assets/VRMShaders/GLTF/IO/Runtime/TextureExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 48a12f7410d9670439e5aef512fe0a6c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: