From bf4fca66c06110eaf6eeca0880281d01afdfcff5 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 17 Mar 2021 19:38:36 +0900 Subject: [PATCH] occlusion only --- .../IO/TextureIO/OcclusionMetallicRoughnessConverter.cs | 6 +++++- .../UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureFactory.cs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/OcclusionMetallicRoughnessConverter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/OcclusionMetallicRoughnessConverter.cs index 72ad2d1af..514ed6067 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/OcclusionMetallicRoughnessConverter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/OcclusionMetallicRoughnessConverter.cs @@ -69,7 +69,11 @@ namespace UniGLTF } else if (occlusionTexture != null) { - throw new NotImplementedException("occlusion only"); + var copyTexture = TextureConverter.CopyTexture(occlusionTexture, glTFTextureTypes.OcclusionMetallicRoughness, null); + copyTexture.SetPixels32(copyTexture.GetPixels32().Select(x => ImportPixel(default, metallicFactor, roughnessFactor, x)).ToArray()); + copyTexture.Apply(); + copyTexture.name = occlusionTexture.name; + return copyTexture; } else { diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureFactory.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureFactory.cs index 70872c48c..24f999f5b 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureFactory.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureFactory.cs @@ -178,7 +178,11 @@ namespace UniGLTF case GetTextureParam.TextureTypes.StandardMap: { - var baseTexture = await GetOrCreateBaseTexture(awaitCaller, gltf, param.Index0.Value, false); + TextureLoadInfo baseTexture = default; + if (param.Index0.HasValue) + { + baseTexture = await GetOrCreateBaseTexture(awaitCaller, gltf, param.Index0.Value, false); + } TextureLoadInfo occlusionBaseTexture = default; if (param.Index1.HasValue) {