Merge pull request #561 from Santarh/textureSampler

テクスチャサンプラ適用処理を ITextureLoader が持つ
This commit is contained in:
hiroj 2020-09-28 14:19:31 +09:00 committed by GitHub
commit d4e48e053c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 6 deletions

View File

@ -163,8 +163,7 @@ namespace UniGLTF
var textureType = TextureIO.GetglTFTextureType(gltf, m_textureIndex);
var colorSpace = TextureIO.GetColorSpace(textureType);
var isLinear = colorSpace == RenderTextureReadWrite.Linear;
yield return m_textureLoader.ProcessOnMainThread(isLinear);
TextureSamplerUtil.SetSampler(Texture, gltf.GetSamplerFromTextureIndex(m_textureIndex));
yield return m_textureLoader.ProcessOnMainThread(isLinear, gltf.GetSamplerFromTextureIndex(m_textureIndex));
}
}
#endregion

View File

@ -25,8 +25,9 @@ namespace UniGLTF
/// Call from unity main thread
/// </summary>
/// <param name="isLinear"></param>
/// <param name="sampler"></param>
/// <returns></returns>
IEnumerator ProcessOnMainThread(bool isLinear);
IEnumerator ProcessOnMainThread(bool isLinear, glTFTextureSampler sampler);
}
#if UNITY_EDITOR
@ -53,7 +54,7 @@ namespace UniGLTF
{
}
public IEnumerator ProcessOnMainThread(bool isLinear)
public IEnumerator ProcessOnMainThread(bool isLinear, glTFTextureSampler sampler)
{
//
// texture from assets
@ -90,6 +91,12 @@ namespace UniGLTF
importer.SaveAndReimport();
}
if (sampler != null)
{
TextureSamplerUtil.SetSampler(Texture, sampler);
}
yield break;
}
}
@ -140,7 +147,7 @@ namespace UniGLTF
m_imageBytes = ToArray(segments);
}
public IEnumerator ProcessOnMainThread(bool isLinear)
public IEnumerator ProcessOnMainThread(bool isLinear, glTFTextureSampler sampler)
{
//
// texture from image(png etc) bytes
@ -151,6 +158,10 @@ namespace UniGLTF
{
Texture.LoadImage(m_imageBytes);
}
if (sampler != null)
{
TextureSamplerUtil.SetSampler(Texture, sampler);
}
yield break;
}
}
@ -274,7 +285,7 @@ namespace UniGLTF
}
}
public IEnumerator ProcessOnMainThread(bool isLinear)
public IEnumerator ProcessOnMainThread(bool isLinear, glTFTextureSampler sampler)
{
// tmp file
var tmp = Path.GetTempFileName();
@ -328,6 +339,10 @@ namespace UniGLTF
#error Unsupported Unity version
#endif
}
if (sampler != null)
{
TextureSamplerUtil.SetSampler(Texture, sampler);
}
}
}
}