mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-12 13:34:39 -05:00
Merge pull request #561 from Santarh/textureSampler
テクスチャサンプラ適用処理を ITextureLoader が持つ
This commit is contained in:
commit
d4e48e053c
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user