Merge branch 'master' into Santarh-patch-1

This commit is contained in:
ousttrue
2024-08-05 13:48:01 +09:00
committed by GitHub
42 changed files with 713 additions and 742 deletions

View File

@@ -10,11 +10,9 @@ namespace UniGLTF
public class MaterialFactory : IResponsibilityForDestroyObjects
{
private readonly IReadOnlyDictionary<SubAssetKey, Material> m_externalMap;
/// <summary>
/// デフォルトマテリアルの MaterialDescriptor は IMaterialDescriptorGenerator の実装によって異なるので外から渡す
/// </summary>
private readonly SubAssetKey m_defaultMaterialKey = new SubAssetKey(typeof(Material), "__UNIGLTF__DEFAULT__MATERIAL__");
private readonly MaterialDescriptor m_defaultMaterialParams;
private readonly List<MaterialLoadInfo> m_materials = new List<MaterialLoadInfo>();
/// <summary>
/// gltfPritmitive.material が無い場合のデフォルトマテリアル
@@ -23,6 +21,9 @@ namespace UniGLTF
/// </summary>
private Material m_defaultMaterial;
public IReadOnlyList<MaterialLoadInfo> Materials => m_materials;
public MaterialFactory(IReadOnlyDictionary<SubAssetKey, Material> externalMaterialMap, MaterialDescriptor defaultMaterialParams)
{
m_externalMap = externalMaterialMap;
@@ -45,18 +46,6 @@ namespace UniGLTF
}
}
List<MaterialLoadInfo> m_materials = new List<MaterialLoadInfo>();
public IReadOnlyList<MaterialLoadInfo> Materials => m_materials;
void Remove(Material material)
{
var index = m_materials.FindIndex(x => x.Asset == material);
if (index >= 0)
{
m_materials.RemoveAt(index);
}
}
public void Dispose()
{
foreach (var x in m_materials)
@@ -67,6 +56,11 @@ namespace UniGLTF
UnityObjectDestroyer.DestroyRuntimeOrEditor(x.Asset);
}
}
if (m_defaultMaterial != null)
{
UnityObjectDestroyer.DestroyRuntimeOrEditor(m_defaultMaterial);
}
}
/// <summary>
@@ -90,6 +84,12 @@ namespace UniGLTF
m_materials.Remove(x);
}
}
if (m_defaultMaterial != null)
{
take(m_defaultMaterialKey, m_defaultMaterial);
m_defaultMaterial = null;
}
}
public Material GetMaterial(int index)
@@ -101,6 +101,12 @@ namespace UniGLTF
public async Task<Material> GetDefaultMaterialAsync(IAwaitCaller awaitCaller)
{
if (m_externalMap.ContainsKey(m_defaultMaterialKey))
{
m_defaultMaterial = m_externalMap[m_defaultMaterialKey];
return m_externalMap[m_defaultMaterialKey];
}
if (m_defaultMaterial == null)
{
m_defaultMaterial = await LoadAsync(m_defaultMaterialParams, (_, _) => null, awaitCaller);
@@ -136,7 +142,8 @@ namespace UniGLTF
if (texture != null)
{
material.SetTexture(kv.Key, texture);
SetTextureOffsetAndScale(material, kv.Key, kv.Value.Offset, kv.Value.Scale);
material.SetTextureOffset(kv.Key, kv.Value.Offset);
material.SetTextureScale(kv.Key, kv.Value.Scale);
}
}
@@ -174,11 +181,5 @@ namespace UniGLTF
return material;
}
public static void SetTextureOffsetAndScale(Material material, string propertyName, Vector2 offset, Vector2 scale)
{
material.SetTextureOffset(propertyName, offset);
material.SetTextureScale(propertyName, scale);
}
}
}

View File

@@ -0,0 +1,36 @@
using System;
using UnityEngine;
namespace UniGLTF
{
/// <summary>
/// フォールバック目的で最低限なにかをエクスポートする。
///
/// メインカラーとメインテクスチャをエクスポートする。
/// </summary>
public class UrpFallbackMaterialExporter
{
public glTFMaterial ExportMaterial(Material src, ITextureExporter textureExporter)
{
var dst = new glTFMaterial
{
name = src.name,
pbrMetallicRoughness = new glTFPbrMetallicRoughness(),
};
dst.pbrMetallicRoughness.baseColorFactor = src.color.ToFloat4(ColorSpace.sRGB, ColorSpace.Linear);
var index = textureExporter.RegisterExportingAsSRgb(src.mainTexture, false);
if (index >= 0)
{
dst.pbrMetallicRoughness.baseColorTexture = new glTFMaterialBaseColorTextureInfo
{
index = index,
texCoord = 0,
};
GltfMaterialExportUtils.ExportTextureTransform(src.mainTextureOffset, src.mainTextureScale, dst.pbrMetallicRoughness.baseColorTexture);
}
return dst;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c0269be076674f5988895ecd61b8d316
timeCreated: 1722612454

View File

@@ -7,18 +7,16 @@ namespace UniGLTF
{
public class UrpLitMaterialExporter
{
public string TargetShaderName { get; }
public Shader Shader { get; set; }
/// <summary>
/// "Universal Render Pipeline/Lit" シェーダのマテリアルをエクスポートする。
///
/// targetShaderName に、プロパティに互換性がある他のシェーダを指定することもできる。
/// プロパティに互換性がある他のシェーダを指定することもできる。
/// </summary>
public UrpLitMaterialExporter(string targetShaderName = null)
public UrpLitMaterialExporter(Shader shader = null)
{
TargetShaderName = string.IsNullOrEmpty(targetShaderName)
? "Universal Render Pipeline/Lit"
: targetShaderName;
Shader = shader != null ? shader : Shader.Find("Universal Render Pipeline/Lit");
}
public bool TryExportMaterial(Material src, ITextureExporter textureExporter, out glTFMaterial dst)
@@ -26,8 +24,8 @@ namespace UniGLTF
try
{
if (src == null) throw new ArgumentNullException(nameof(src));
if (src.shader.name != TargetShaderName) throw new ArgumentException(nameof(src));
if (textureExporter == null) throw new ArgumentNullException(nameof(textureExporter));
if (src.shader != Shader || Shader == null) throw new UniGLTFShaderNotMatchedInternalException(src.shader);
dst = new glTFMaterial
{
@@ -54,14 +52,20 @@ namespace UniGLTF
return true;
}
catch (Exception)
catch (UniGLTFShaderNotMatchedInternalException)
{
dst = default;
return false;
}
catch (Exception e)
{
Debug.LogException(e);
dst = default;
return false;
}
}
public static void ExportSurfaceSettings(UrpLitContext context, glTFMaterial dst, ITextureExporter textureExporter)
public static void ExportSurfaceSettings(UrpBaseShaderContext context, glTFMaterial dst, ITextureExporter textureExporter)
{
dst.alphaMode = (context.SurfaceType, context.IsAlphaClipEnabled) switch
{
@@ -75,7 +79,7 @@ namespace UniGLTF
dst.doubleSided = context.CullMode != CullMode.Back; // NOTE: cull front not supported in glTF
}
public static void ExportBaseColor(UrpLitContext context, glTFMaterial dst, ITextureExporter textureExporter)
public static void ExportBaseColor(UrpBaseShaderContext context, glTFMaterial dst, ITextureExporter textureExporter)
{
dst.pbrMetallicRoughness.baseColorFactor = context.BaseColorSrgb.ToFloat4(ColorSpace.sRGB, ColorSpace.Linear);
if (context.BaseTexture != null)
@@ -186,7 +190,7 @@ namespace UniGLTF
}
}
private static void ExportBaseTexTransform(UrpLitContext context, glTFTextureInfo dst)
private static void ExportBaseTexTransform(UrpBaseShaderContext context, glTFTextureInfo dst)
{
GltfMaterialExportUtils.ExportTextureTransform(
context.BaseTextureOffset,

View File

@@ -0,0 +1,79 @@
using System;
using UniGLTF.UniUnlit;
using UnityEngine;
namespace UniGLTF
{
public class UrpUniUnlitMaterialExporter
{
public Shader Shader { get; set; }
/// <summary>
/// "UniGLTF/UniUnlit" シェーダのマテリアルをエクスポートする。
///
/// プロパティに互換性がある他のシェーダを指定することもできる。
/// </summary>
public UrpUniUnlitMaterialExporter(Shader shader = null)
{
Shader = shader != null ? shader : Shader.Find("UniGLTF/UniUnlit");
}
public bool TryExportMaterial(Material src, ITextureExporter textureExporter, out glTFMaterial dst)
{
try
{
if (src == null) throw new ArgumentNullException(nameof(src));
if (textureExporter == null) throw new ArgumentNullException(nameof(textureExporter));
if (src.shader != Shader || Shader == null) throw new UniGLTFShaderNotMatchedInternalException(src.shader);
dst = glTF_KHR_materials_unlit.CreateDefault();
dst.name = src.name;
var context = new UniUnlitContext(src);
dst.alphaMode = context.RenderMode switch
{
UniUnlitRenderMode.Opaque => glTFBlendMode.OPAQUE.ToString(),
UniUnlitRenderMode.Cutout => glTFBlendMode.MASK.ToString(),
UniUnlitRenderMode.Transparent => glTFBlendMode.BLEND.ToString(),
_ => throw new ArgumentOutOfRangeException(),
};
dst.alphaCutoff = context.Cutoff;
dst.doubleSided = context.CullMode != UniUnlitCullMode.Back;
dst.pbrMetallicRoughness.baseColorFactor = context.MainColorSrgb
.ToFloat4(ColorSpace.sRGB, ColorSpace.Linear);
if (context.MainTexture != null)
{
var needsAlpha = context.RenderMode != UniUnlitRenderMode.Opaque;
var index = textureExporter.RegisterExportingAsSRgb(context.MainTexture, needsAlpha);
if (index >= 0)
{
dst.pbrMetallicRoughness.baseColorTexture = new glTFMaterialBaseColorTextureInfo
{
index = index,
texCoord = 0,
};
GltfMaterialExportUtils.ExportTextureTransform(
context.MainTextureOffset,
context.MainTextureScale,
dst.pbrMetallicRoughness.baseColorTexture);
}
}
return true;
}
catch (UniGLTFShaderNotMatchedInternalException)
{
dst = default;
return false;
}
catch (Exception e)
{
Debug.LogException(e);
dst = default;
return false;
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5b17f3928c684fc1a9beda10797b0e76
timeCreated: 1722613258

View File

@@ -0,0 +1,50 @@
using System;
using UnityEngine;
namespace UniGLTF
{
public class UrpUnlitMaterialExporter
{
public Shader Shader { get; set; }
/// <summary>
/// "Universal Render Pipeline/Unlit" シェーダのマテリアルをエクスポートする。
///
/// プロパティに互換性がある他のシェーダを指定することもできる。
/// </summary>
public UrpUnlitMaterialExporter(Shader shader = null)
{
Shader = shader != null ? shader : Shader.Find("Universal Render Pipeline/Unlit");
}
public bool TryExportMaterial(Material src, ITextureExporter textureExporter, out glTFMaterial dst)
{
try
{
if (src == null) throw new ArgumentNullException(nameof(src));
if (textureExporter == null) throw new ArgumentNullException(nameof(textureExporter));
if (src.shader != Shader || Shader == null) throw new UniGLTFShaderNotMatchedInternalException(src.shader);
dst = glTF_KHR_materials_unlit.CreateDefault();
dst.name = src.name;
var context = new UrpUnlitContext(src);
UrpLitMaterialExporter.ExportSurfaceSettings(context, dst, textureExporter);
UrpLitMaterialExporter.ExportBaseColor(context, dst, textureExporter);
return true;
}
catch (UniGLTFShaderNotMatchedInternalException)
{
dst = default;
return false;
}
catch (Exception e)
{
Debug.LogException(e);
dst = default;
return false;
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a90bb1e911744bbab916950324c70e52
timeCreated: 1722614768

View File

@@ -4,15 +4,19 @@ namespace UniGLTF
{
public class UrpGltfMaterialExporter : IMaterialExporter
{
private readonly UrpLitMaterialExporter _litExporter = new();
public UrpLitMaterialExporter UrpLitExporter { get; set; } = new();
public UrpUnlitMaterialExporter UrpUnlitExporter { get; set; } = new();
public UrpUniUnlitMaterialExporter UrpUniUnlitExporter { get; set; } = new();
public UrpFallbackMaterialExporter FallbackExporter { get; set; } = new();
public glTFMaterial ExportMaterial(Material m, ITextureExporter textureExporter, GltfExportSettings settings)
{
glTFMaterial dst;
if (UrpLitExporter.TryExportMaterial(m, textureExporter, out var dst)) return dst;
if (UrpUnlitExporter.TryExportMaterial(m, textureExporter, out dst)) return dst;
if (UrpUniUnlitExporter.TryExportMaterial(m, textureExporter, out dst)) return dst;
if (_litExporter.TryExportMaterial(m, textureExporter, out dst)) return dst;
return dst;
Debug.Log($"Material `{m.name}` fallbacks.");
return FallbackExporter.ExportMaterial(m, textureExporter);
}
}
}

View File

@@ -0,0 +1,163 @@
using UnityEngine;
using UnityEngine.Rendering;
namespace UniGLTF
{
public abstract class UrpBaseShaderContext
{
private static readonly int Surface = Shader.PropertyToID("_Surface");
private static readonly int AlphaClip = Shader.PropertyToID("_AlphaClip");
private static readonly int Blend = Shader.PropertyToID("_Blend");
private static readonly int Cull = Shader.PropertyToID("_Cull");
private static readonly int BaseColorProp = Shader.PropertyToID("_BaseColor");
private static readonly int BaseMap = Shader.PropertyToID("_BaseMap");
private static readonly int CutoffProp = Shader.PropertyToID("_Cutoff");
private static readonly int ZWrite = Shader.PropertyToID("_ZWrite");
private static readonly int SrcBlend = Shader.PropertyToID("_SrcBlend");
private static readonly int DstBlend = Shader.PropertyToID("_DstBlend");
private static readonly string SurfaceTypeTransparentKeyword = "_SURFACE_TYPE_TRANSPARENT";
private static readonly string AlphaTestOnKeyword = "_ALPHATEST_ON";
private static readonly string AlphaPremultiplyOnKeyword = "_ALPHAPREMULTIPLY_ON";
private static readonly string AlphaModulateOnKeyword = "_ALPHAMODULATE_ON";
protected UrpBaseShaderContext(Material material)
{
Material = material;
}
public Material Material { get; }
/// <summary>
/// これが有効な場合、Validate() 関数が呼ばれるべき場合でも自動的に呼ばれなくなります。
///
/// 処理最適化目的で使用できます。
/// </summary>
public bool UnsafeEditMode { get; set; } = false;
public UrpLitSurfaceType SurfaceType
{
get => (UrpLitSurfaceType)Material.GetFloat(Surface);
set
{
Material.SetFloat(Surface, (float)value);
if (!UnsafeEditMode) Validate();
}
}
public UrpLitBlendMode BlendMode
{
get => (UrpLitBlendMode)Material.GetFloat(Blend);
set
{
Material.SetFloat(Blend, (float)value);
if (!UnsafeEditMode) Validate();
}
}
public bool IsAlphaClipEnabled
{
get => Material.GetFloat(AlphaClip) >= 0.5f;
set
{
Material.SetFloat(AlphaClip, value ? 1.0f : 0.0f);
if (!UnsafeEditMode) Validate();
}
}
public CullMode CullMode
{
get => (CullMode)Material.GetFloat(Cull);
set
{
Material.SetFloat(Cull, (float)value);
Material.doubleSidedGI = value != CullMode.Back;
}
}
public Color BaseColorSrgb
{
get => Material.GetColor(BaseColorProp);
set => Material.SetColor(BaseColorProp, value);
}
public Texture BaseTexture
{
get => Material.GetTexture(BaseMap);
set => Material.SetTexture(BaseMap, value);
}
public Vector2 BaseTextureOffset
{
get => Material.GetTextureOffset(BaseMap);
set => Material.SetTextureOffset(BaseMap, value);
}
public Vector2 BaseTextureScale
{
get => Material.GetTextureScale(BaseMap);
set => Material.SetTextureScale(BaseMap, value);
}
public float Cutoff
{
get => Material.GetFloat(CutoffProp);
set => Material.SetFloat(CutoffProp, value);
}
public virtual void Validate()
{
// Surface Type
var surfaceType = (UrpLitSurfaceType)Material.GetFloat(Surface);
Material.SetKeyword(SurfaceTypeTransparentKeyword, surfaceType != UrpLitSurfaceType.Opaque);
// Alpha Clip
var alphaClip = Material.GetFloat(AlphaClip) >= 0.5f;
Material.SetKeyword(AlphaTestOnKeyword, alphaClip);
// Blend Mode
var blendMode = (UrpLitBlendMode)Material.GetFloat(Blend);
Material.SetKeyword(AlphaPremultiplyOnKeyword, blendMode == UrpLitBlendMode.Premultiply);
Material.SetKeyword(AlphaModulateOnKeyword, blendMode == UrpLitBlendMode.Additive);
// ZWrite
var zWrite = surfaceType == UrpLitSurfaceType.Opaque;
Material.SetFloat(ZWrite, zWrite ? 1.0f : 0.0f);
Material.SetShaderPassEnabled("DepthOnly", zWrite);
// Render Settings
Material.SetFloat(SrcBlend, (surfaceType, blendMode) switch
{
(UrpLitSurfaceType.Opaque, _) => (float)UnityEngine.Rendering.BlendMode.One,
(UrpLitSurfaceType.Transparent, UrpLitBlendMode.Alpha) => (float)UnityEngine.Rendering.BlendMode.SrcAlpha,
(UrpLitSurfaceType.Transparent, UrpLitBlendMode.Premultiply) => (float)UnityEngine.Rendering.BlendMode.One,
(UrpLitSurfaceType.Transparent, UrpLitBlendMode.Additive) => (float)UnityEngine.Rendering.BlendMode.One,
(UrpLitSurfaceType.Transparent, UrpLitBlendMode.Multiply) => (float)UnityEngine.Rendering.BlendMode.DstColor,
_ => (float)UnityEngine.Rendering.BlendMode.One,
});
Material.SetFloat(DstBlend, (surfaceType, blendMode) switch
{
(UrpLitSurfaceType.Opaque, _) => (float)UnityEngine.Rendering.BlendMode.Zero,
(UrpLitSurfaceType.Transparent, UrpLitBlendMode.Alpha) => (float)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha,
(UrpLitSurfaceType.Transparent, UrpLitBlendMode.Premultiply) => (float)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha,
(UrpLitSurfaceType.Transparent, UrpLitBlendMode.Additive) => (float)UnityEngine.Rendering.BlendMode.One,
(UrpLitSurfaceType.Transparent, UrpLitBlendMode.Multiply) => (float)UnityEngine.Rendering.BlendMode.Zero,
_ => (float) UnityEngine.Rendering.BlendMode.Zero,
});
Material.SetOverrideTag("RenderType", (surfaceType, alphaClip) switch
{
(UrpLitSurfaceType.Opaque, false) => "Opaque",
(UrpLitSurfaceType.Opaque, true) => "TransparentCutout",
(UrpLitSurfaceType.Transparent, _) => "Transparent",
_ => "Opaque",
});
Material.renderQueue = (surfaceType, alphaClip) switch
{
(UrpLitSurfaceType.Opaque, false) => (int)RenderQueue.Geometry,
(UrpLitSurfaceType.Opaque, true) => (int)RenderQueue.AlphaTest,
(UrpLitSurfaceType.Transparent, _) => (int)RenderQueue.Transparent,
_ => Material.shader.renderQueue,
};
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a0a218f533e64925a87626ce8129f264
timeCreated: 1722615731

View File

@@ -15,22 +15,13 @@ namespace UniGLTF
/// - Environment Reflections Toggle
/// - Sorting Priority
/// </summary>
public class UrpLitContext
public class UrpLitContext : UrpBaseShaderContext
{
private readonly Material _mat;
private static readonly int WorkflowMode = Shader.PropertyToID("_WorkflowMode");
private static readonly int Surface = Shader.PropertyToID("_Surface");
private static readonly int AlphaClip = Shader.PropertyToID("_AlphaClip");
private static readonly int Blend = Shader.PropertyToID("_Blend");
private static readonly int Cull = Shader.PropertyToID("_Cull");
private static readonly int BaseColorProp = Shader.PropertyToID("_BaseColor");
private static readonly int BaseMap = Shader.PropertyToID("_BaseMap");
private static readonly int EmissionColor = Shader.PropertyToID("_EmissionColor");
private static readonly int EmissionMap = Shader.PropertyToID("_EmissionMap");
private static readonly int OcclusionMap = Shader.PropertyToID("_OcclusionMap");
private static readonly int ParallaxMap = Shader.PropertyToID("_ParallaxMap");
private static readonly int CutoffProp = Shader.PropertyToID("_Cutoff");
private static readonly int SmoothnessProp = Shader.PropertyToID("_Smoothness");
private static readonly int SmoothnessTextureChannelProp = Shader.PropertyToID("_SmoothnessTextureChannel");
private static readonly int MetallicProp = Shader.PropertyToID("_Metallic");
@@ -39,131 +30,45 @@ namespace UniGLTF
private static readonly int SpecGlossMapProp = Shader.PropertyToID("_SpecGlossMap");
private static readonly int BumpScaleProp = Shader.PropertyToID("_BumpScale");
private static readonly int BumpMapProp = Shader.PropertyToID("_BumpMap");
private static readonly int ZWrite = Shader.PropertyToID("_ZWrite");
private static readonly int SrcBlend = Shader.PropertyToID("_SrcBlend");
private static readonly int DstBlend = Shader.PropertyToID("_DstBlend");
private static readonly string SpecularSetupKeyword = "_SPECULAR_SETUP";
private static readonly string MetallicSpecGlossMapKeyword = "_METALLICSPECGLOSSMAP";
private static readonly string SurfaceTypeTransparentKeyword = "_SURFACE_TYPE_TRANSPARENT";
private static readonly string SmoothnessTextureAlbedoChannelAKeyword = "_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A";
private static readonly string NormalMapKeyword = "_NORMALMAP";
private static readonly string EmissionKeyword = "_EMISSION";
private static readonly string OcclusionMapKeyword = "_OCCLUSIONMAP";
private static readonly string ParallaxMapKeyword = "_PARALLAXMAP";
private static readonly string AlphaTestOnKeyword = "_ALPHATEST_ON";
private static readonly string AlphaPremultiplyOnKeyword = "_ALPHAPREMULTIPLY_ON";
private static readonly string AlphaModulateOnKeyword = "_ALPHAMODULATE_ON";
private static readonly int OcclusionStrengthProp = Shader.PropertyToID("_OcclusionStrength");
private static readonly int ParallaxProp = Shader.PropertyToID("_Parallax");
public UrpLitContext(Material material)
public UrpLitContext(Material material) : base(material)
{
_mat = material;
}
public Material Material => _mat;
/// <summary>
/// これが有効な場合、Validate() 関数が呼ばれるべき場合でも自動的に呼ばれなくなります。
///
/// 処理最適化目的で使用できます。
/// </summary>
public bool UnsafeEditMode { get; set; } = false;
public UrpLitWorkflowType WorkflowType
{
get => (UrpLitWorkflowType)_mat.GetFloat(WorkflowMode);
get => (UrpLitWorkflowType)Material.GetFloat(WorkflowMode);
set
{
_mat.SetFloat(WorkflowMode, (float)value);
Material.SetFloat(WorkflowMode, (float)value);
if (!UnsafeEditMode) Validate();
}
}
public UrpLitSurfaceType SurfaceType
{
get => (UrpLitSurfaceType)_mat.GetFloat(Surface);
set
{
_mat.SetFloat(Surface, (float)value);
if (!UnsafeEditMode) Validate();
}
}
public UrpLitBlendMode BlendMode
{
get => (UrpLitBlendMode)_mat.GetFloat(Blend);
set
{
_mat.SetFloat(Blend, (float)value);
if (!UnsafeEditMode) Validate();
}
}
public bool IsAlphaClipEnabled
{
get => _mat.GetFloat(AlphaClip) >= 0.5f;
set
{
_mat.SetFloat(AlphaClip, value ? 1.0f : 0.0f);
if (!UnsafeEditMode) Validate();
}
}
public CullMode CullMode
{
get => (CullMode)_mat.GetFloat(Cull);
set
{
_mat.SetFloat(Cull, (float)value);
_mat.doubleSidedGI = value != CullMode.Back;
}
}
public Color BaseColorSrgb
{
get => _mat.GetColor(BaseColorProp);
set => _mat.SetColor(BaseColorProp, value);
}
public Texture BaseTexture
{
get => _mat.GetTexture(BaseMap);
set => _mat.SetTexture(BaseMap, value);
}
public Vector2 BaseTextureOffset
{
get => _mat.GetTextureOffset(BaseMap);
set => _mat.SetTextureOffset(BaseMap, value);
}
public Vector2 BaseTextureScale
{
get => _mat.GetTextureScale(BaseMap);
set => _mat.SetTextureScale(BaseMap, value);
}
public float Cutoff
{
get => _mat.GetFloat(CutoffProp);
set => _mat.SetFloat(CutoffProp, value);
}
public float Smoothness
{
get => _mat.GetFloat(SmoothnessProp);
set => _mat.SetFloat(SmoothnessProp, value);
get => Material.GetFloat(SmoothnessProp);
set => Material.SetFloat(SmoothnessProp, value);
}
public UrpLitSmoothnessMapChannel SmoothnessTextureChannel
{
// NOTE: Float Prop 以外に条件があるので、Keyword から読み取った方が確実
get => _mat.IsKeywordEnabled(SmoothnessTextureAlbedoChannelAKeyword) ? UrpLitSmoothnessMapChannel.AlbedoAlpha : UrpLitSmoothnessMapChannel.SpecularMetallicAlpha;
get => Material.IsKeywordEnabled(SmoothnessTextureAlbedoChannelAKeyword) ? UrpLitSmoothnessMapChannel.AlbedoAlpha : UrpLitSmoothnessMapChannel.SpecularMetallicAlpha;
set
{
_mat.SetFloat(SmoothnessTextureChannelProp, (float)value);
Material.SetFloat(SmoothnessTextureChannelProp, (float)value);
if (!UnsafeEditMode) Validate();
}
}
@@ -171,179 +76,129 @@ namespace UniGLTF
public float Metallic
{
// NOTE: Metallic ワークフロー専用
get => _mat.GetFloat(MetallicProp);
set => _mat.SetFloat(MetallicProp, value);
get => Material.GetFloat(MetallicProp);
set => Material.SetFloat(MetallicProp, value);
}
public Texture MetallicGlossMap
{
// NOTE: Metallic ワークフロー専用
get => _mat.GetTexture(MetallicGlossMapProp);
set => _mat.SetTexture(MetallicGlossMapProp, value);
get => Material.GetTexture(MetallicGlossMapProp);
set => Material.SetTexture(MetallicGlossMapProp, value);
}
public Color SpecColorSrgb
{
// NOTE: Specular ワークフロー専用
get => _mat.GetColor(SpecColorProp);
set => _mat.SetColor(SpecColorProp, value);
get => Material.GetColor(SpecColorProp);
set => Material.SetColor(SpecColorProp, value);
}
public Texture SpecGlossMap
{
// NOTE: Specular ワークフロー専用
get => _mat.GetTexture(SpecGlossMapProp);
set => _mat.SetTexture(SpecGlossMapProp, value);
get => Material.GetTexture(SpecGlossMapProp);
set => Material.SetTexture(SpecGlossMapProp, value);
}
public float BumpScale
{
get => _mat.GetFloat(BumpScaleProp);
set => _mat.SetFloat(BumpScaleProp, value);
get => Material.GetFloat(BumpScaleProp);
set => Material.SetFloat(BumpScaleProp, value);
}
public Texture BumpMap
{
get => _mat.GetTexture(BumpMapProp);
get => Material.GetTexture(BumpMapProp);
set
{
_mat.SetTexture(BumpMapProp, value);
_mat.SetKeyword(NormalMapKeyword, value != null);
Material.SetTexture(BumpMapProp, value);
Material.SetKeyword(NormalMapKeyword, value != null);
}
}
public bool IsEmissionEnabled
{
get => _mat.IsKeywordEnabled(EmissionKeyword);
get => Material.IsKeywordEnabled(EmissionKeyword);
set
{
_mat.SetKeyword(EmissionKeyword, value);
Material.SetKeyword(EmissionKeyword, value);
if (value)
{
_mat.globalIlluminationFlags &= ~MaterialGlobalIlluminationFlags.EmissiveIsBlack;
Material.globalIlluminationFlags &= ~MaterialGlobalIlluminationFlags.EmissiveIsBlack;
}
else
{
_mat.globalIlluminationFlags |= MaterialGlobalIlluminationFlags.EmissiveIsBlack;
Material.globalIlluminationFlags |= MaterialGlobalIlluminationFlags.EmissiveIsBlack;
}
}
}
public Color EmissionColorLinear
{
get => _mat.GetColor(EmissionColor);
set => _mat.SetColor(EmissionColor, value);
get => Material.GetColor(EmissionColor);
set => Material.SetColor(EmissionColor, value);
}
public Texture EmissionTexture
{
get => _mat.GetTexture(EmissionMap);
set => _mat.SetTexture(EmissionMap, value);
get => Material.GetTexture(EmissionMap);
set => Material.SetTexture(EmissionMap, value);
}
public float OcclusionStrength
{
get => _mat.GetFloat(OcclusionStrengthProp);
set => _mat.SetFloat(OcclusionStrengthProp, value);
get => Material.GetFloat(OcclusionStrengthProp);
set => Material.SetFloat(OcclusionStrengthProp, value);
}
public Texture OcclusionTexture
{
get => _mat.GetTexture(OcclusionMap);
get => Material.GetTexture(OcclusionMap);
set
{
_mat.SetTexture(OcclusionMap, value);
_mat.SetKeyword(OcclusionMapKeyword, value != null);
Material.SetTexture(OcclusionMap, value);
Material.SetKeyword(OcclusionMapKeyword, value != null);
}
}
public float Parallax
{
get => _mat.GetFloat(ParallaxProp);
set => _mat.SetFloat(ParallaxProp, value);
get => Material.GetFloat(ParallaxProp);
set => Material.SetFloat(ParallaxProp, value);
}
public Texture ParallaxTexture
{
get => _mat.GetTexture(ParallaxMap);
get => Material.GetTexture(ParallaxMap);
set
{
_mat.SetTexture(ParallaxMap, value);
_mat.SetKeyword(ParallaxMapKeyword, value != null);
Material.SetTexture(ParallaxMap, value);
Material.SetKeyword(ParallaxMapKeyword, value != null);
}
}
/// <summary>
/// 複数のプロパティに関連して設定されるキーワードやプロパティなどを更新する
/// </summary>
public void Validate()
public override void Validate()
{
base.Validate();
// Workflow
var workflowType = (UrpLitWorkflowType)_mat.GetFloat(WorkflowMode);
var workflowType = (UrpLitWorkflowType)Material.GetFloat(WorkflowMode);
var isSpecularSetup = workflowType == UrpLitWorkflowType.Specular;
_mat.SetKeyword(SpecularSetupKeyword, isSpecularSetup);
Material.SetKeyword(SpecularSetupKeyword, isSpecularSetup);
// GlossMap
var glossMapName = isSpecularSetup ? SpecGlossMapProp : MetallicGlossMapProp;
var hasGlossMap = _mat.GetTexture(glossMapName) != null;
_mat.SetKeyword(MetallicSpecGlossMapKeyword, hasGlossMap);
// Surface Type
var surfaceType = (UrpLitSurfaceType)_mat.GetFloat(Surface);
_mat.SetKeyword(SurfaceTypeTransparentKeyword, surfaceType != UrpLitSurfaceType.Opaque);
var hasGlossMap = Material.GetTexture(glossMapName) != null;
Material.SetKeyword(MetallicSpecGlossMapKeyword, hasGlossMap);
// SmoothnessTextureChannel
var isOpaque = surfaceType == UrpLitSurfaceType.Opaque;
var smoothnessMapChannel = (UrpLitSmoothnessMapChannel)_mat.GetFloat(SmoothnessTextureChannelProp);
_mat.SetKeyword(SmoothnessTextureAlbedoChannelAKeyword, isOpaque && smoothnessMapChannel == UrpLitSmoothnessMapChannel.AlbedoAlpha);
// Alpha Clip
var alphaClip = _mat.GetFloat(AlphaClip) >= 0.5f;
_mat.SetKeyword(AlphaTestOnKeyword, alphaClip);
// Blend Mode
var blendMode = (UrpLitBlendMode)_mat.GetFloat(Blend);
_mat.SetKeyword(AlphaPremultiplyOnKeyword, blendMode == UrpLitBlendMode.Premultiply);
_mat.SetKeyword(AlphaModulateOnKeyword, blendMode == UrpLitBlendMode.Additive);
// ZWrite
var zWrite = surfaceType == UrpLitSurfaceType.Opaque;
_mat.SetFloat(ZWrite, zWrite ? 1.0f : 0.0f);
_mat.SetShaderPassEnabled("DepthOnly", zWrite);
// Render Settings
_mat.SetFloat(SrcBlend, (surfaceType, blendMode) switch
{
(UrpLitSurfaceType.Opaque, _) => (float)UnityEngine.Rendering.BlendMode.One,
(UrpLitSurfaceType.Transparent, UrpLitBlendMode.Alpha) => (float)UnityEngine.Rendering.BlendMode.SrcAlpha,
(UrpLitSurfaceType.Transparent, UrpLitBlendMode.Premultiply) => (float)UnityEngine.Rendering.BlendMode.One,
(UrpLitSurfaceType.Transparent, UrpLitBlendMode.Additive) => (float)UnityEngine.Rendering.BlendMode.One,
(UrpLitSurfaceType.Transparent, UrpLitBlendMode.Multiply) => (float)UnityEngine.Rendering.BlendMode.DstColor,
_ => (float)UnityEngine.Rendering.BlendMode.One,
});
_mat.SetFloat(DstBlend, (surfaceType, blendMode) switch
{
(UrpLitSurfaceType.Opaque, _) => (float)UnityEngine.Rendering.BlendMode.Zero,
(UrpLitSurfaceType.Transparent, UrpLitBlendMode.Alpha) => (float)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha,
(UrpLitSurfaceType.Transparent, UrpLitBlendMode.Premultiply) => (float)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha,
(UrpLitSurfaceType.Transparent, UrpLitBlendMode.Additive) => (float)UnityEngine.Rendering.BlendMode.One,
(UrpLitSurfaceType.Transparent, UrpLitBlendMode.Multiply) => (float)UnityEngine.Rendering.BlendMode.Zero,
_ => (float) UnityEngine.Rendering.BlendMode.Zero,
});
_mat.SetOverrideTag("RenderType", (surfaceType, alphaClip) switch
{
(UrpLitSurfaceType.Opaque, false) => "Opaque",
(UrpLitSurfaceType.Opaque, true) => "TransparentCutout",
(UrpLitSurfaceType.Transparent, _) => "Transparent",
_ => "Opaque",
});
_mat.renderQueue = (surfaceType, alphaClip) switch
{
(UrpLitSurfaceType.Opaque, false) => (int)RenderQueue.Geometry,
(UrpLitSurfaceType.Opaque, true) => (int)RenderQueue.AlphaTest,
(UrpLitSurfaceType.Transparent, _) => (int)RenderQueue.Transparent,
_ => _mat.shader.renderQueue,
};
var isOpaque = SurfaceType == UrpLitSurfaceType.Opaque;
var smoothnessMapChannel = (UrpLitSmoothnessMapChannel)Material.GetFloat(SmoothnessTextureChannelProp);
Material.SetKeyword(SmoothnessTextureAlbedoChannelAKeyword, isOpaque && smoothnessMapChannel == UrpLitSmoothnessMapChannel.AlbedoAlpha);
}
}
}

View File

@@ -0,0 +1,12 @@
using UnityEngine;
namespace UniGLTF
{
public class UrpUnlitContext : UrpBaseShaderContext
{
public UrpUnlitContext(Material material) : base(material)
{
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3fe15309261045ba937d6a8dafb6a93d
timeCreated: 1722616677

View File

@@ -0,0 +1,9 @@
using UnityEngine;
namespace UniGLTF
{
internal class UniGLTFShaderNotMatchedInternalException : UniGLTFException
{
public UniGLTFShaderNotMatchedInternalException(Shader shader) : base(shader != null ? shader.name : "") { }
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7857ff1b8d15440f9886f293a747ebb1
timeCreated: 1722617046

View File

@@ -4,8 +4,8 @@ namespace UniGLTF
public static partial class PackageVersion
{
public const int MAJOR = 0;
public const int MINOR = 124;
public const int PATCH = 2;
public const string VERSION = "0.124.2";
public const int MINOR = 125;
public const int PATCH = 0;
public const string VERSION = "0.125.0";
}
}

View File

@@ -4,8 +4,8 @@ namespace UniGLTF
public static partial class UniGLTFVersion
{
public const int MAJOR = 2;
public const int MINOR = 60;
public const int PATCH = 2;
public const string VERSION = "2.60.2";
public const int MINOR = 61;
public const int PATCH = 0;
public const string VERSION = "2.61.0";
}
}

View File

@@ -31,7 +31,7 @@ namespace UniGLTF.GltfViewer
LoadPathAsync(path);
}
async void LoadPathAsync(VRMShaders.PathObject path)
async void LoadPathAsync(PathObject path)
{
if (_instance)
{

View File

@@ -2,10 +2,10 @@ namespace UniGLTF.GltfViewer
{
public static class OpenFileDialog
{
public static VRMShaders.PathObject Show(string title, params string[] extensions)
public static PathObject Show(string title, params string[] extensions)
{
#if UNITY_STANDALONE_WIN
return VRMShaders.PathObject.FromFullPath(FileDialogForWindows.FileDialog(title, extensions));
return PathObject.FromFullPath(FileDialogForWindows.FileDialog(title, extensions));
#else
UnityEngine.Debug.LogWarning("Non-Windows runtime file dialogs are not yet implemented.");
return default;

View File

@@ -119,7 +119,11 @@ namespace UniHumanoid
builder.AddLeg(0.1f, 0.3f, 0.4f, 0.1f, 0.1f);
var description = AvatarDescription.Create(builder.Skeleton);
var animator = GetComponentOrThrow<Animator>();
var animator = GetComponent<Animator>();
if (animator == null)
{
throw new System.ArgumentException("no animator");
}
animator.avatar = description.CreateAvatar(root);
// create SkinnedMesh for bone visualize
@@ -132,7 +136,8 @@ namespace UniHumanoid
renderer.sharedMaterial = m_material;
//root.gameObject.AddComponent<BoneMapping>();
if (TryGetComponent<HumanPoseTransfer>(out var transfer))
var transfer = GetComponent<HumanPoseTransfer>();
if (transfer != null)
{
transfer.Avatar = animator.avatar;
transfer.Setup();

View File

@@ -0,0 +1,80 @@
using UnityEngine;
namespace UniGLTF.UniUnlit
{
public class UniUnlitContext
{
public Material Material { get; }
public bool UnsafeEditMode { get; set; } = false;
public UniUnlitContext(Material material)
{
Material = material;
}
public UniUnlitRenderMode RenderMode
{
get => UniUnlitUtil.GetRenderMode(Material);
set
{
UniUnlitUtil.SetRenderMode(Material, value);
if (!UnsafeEditMode) UniUnlitUtil.ValidateProperties(Material, isRenderModeChangedByUser: true);
}
}
public UniUnlitCullMode CullMode
{
get => UniUnlitUtil.GetCullMode(Material);
set
{
UniUnlitUtil.SetCullMode(Material, value);
if (!UnsafeEditMode) UniUnlitUtil.ValidateProperties(Material);
}
}
public UniUnlitVertexColorBlendOp VColBlendMode
{
get => UniUnlitUtil.GetVColBlendMode(Material);
set
{
UniUnlitUtil.SetVColBlendMode(Material, value);
if (!UnsafeEditMode) UniUnlitUtil.ValidateProperties(Material);
}
}
public Color MainColorSrgb
{
get => Material.GetColor(UniUnlitUtil.PropNameColor);
set => Material.SetColor(UniUnlitUtil.PropNameColor, value);
}
public Texture MainTexture
{
get => Material.GetTexture(UniUnlitUtil.PropNameMainTex);
set => Material.SetTexture(UniUnlitUtil.PropNameMainTex, value);
}
public Vector2 MainTextureOffset
{
get => Material.GetTextureOffset(UniUnlitUtil.PropNameMainTex);
set => Material.SetTextureOffset(UniUnlitUtil.PropNameMainTex, value);
}
public Vector2 MainTextureScale
{
get => Material.GetTextureScale(UniUnlitUtil.PropNameMainTex);
set => Material.SetTextureScale(UniUnlitUtil.PropNameMainTex, value);
}
public float Cutoff
{
get => Material.GetFloat(UniUnlitUtil.PropNameCutoff);
set => Material.SetFloat(UniUnlitUtil.PropNameCutoff, value);
}
public void Validate()
{
UniUnlitUtil.ValidateProperties(Material, isRenderModeChangedByUser: true);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 57963fbf465047bf83ed829f8a0022d3
timeCreated: 1722613449

View File

@@ -1,6 +1,6 @@
{
"name": "com.vrmc.gltf",
"version": "0.124.2",
"version": "0.125.0",
"displayName": "UniGLTF",
"description": "GLTF importer and exporter",
"unity": "2021.3",

View File

@@ -3,7 +3,6 @@ using System.IO;
using UniGLTF;
using UnityEngine;
namespace VRM.FirstPersonSample
{
public class VRMRuntimeLoader : MonoBehaviour
@@ -114,7 +113,7 @@ namespace VRM.FirstPersonSample
var loaded = default(RuntimeGltfInstance);
if (m_loadAsync)
{
loaded = await context.LoadAsync(new VRMShaders.RuntimeOnlyAwaitCaller());
loaded = await context.LoadAsync(new RuntimeOnlyAwaitCaller());
}
else
{

View File

@@ -1,7 +1,6 @@
using System.IO;
using UniGLTF;
using UnityEngine;
using VRMShaders;
namespace VRM.RuntimeExporterSample
{

View File

@@ -7,8 +7,6 @@ using UniGLTF;
using UniHumanoid;
using UnityEngine;
using UnityEngine.UI;
using VRMShaders;
namespace VRM.SimpleViewer
{

View File

@@ -1,6 +1,6 @@
{
"name": "com.vrmc.univrm",
"version": "0.124.2",
"version": "0.125.0",
"displayName": "VRM",
"description": "VRM importer",
"unity": "2021.3",
@@ -14,7 +14,7 @@
"name": "VRM Consortium"
},
"dependencies": {
"com.vrmc.gltf": "0.124.2",
"com.vrmc.gltf": "0.125.0",
"com.unity.ugui": "1.0.0"
},
"samples": [

View File

@@ -171,7 +171,7 @@ namespace UniVRM10
public float custom_98;
public float custom_99;
public void Initialize(IEnumerable<ExpressionKey> keys)
public void Initialize(IEnumerable<ExpressionKey> keys, Material material)
{
var humanoid = gameObject.AddComponent<Humanoid>();
if (humanoid.AssignBonesFromAnimator())
@@ -183,7 +183,6 @@ namespace UniVRM10
// create SkinnedMesh for bone visualize
var animator = this.GetComponentOrThrow<Animator>();
BoxMan = SkeletonMeshUtility.CreateRenderer(animator);
var material = new Material(Shader.Find("Standard"));
BoxMan.sharedMaterial = material;
var mesh = BoxMan.sharedMesh;
mesh.name = "box-man";

View File

@@ -244,6 +244,9 @@ namespace UniVRM10
}
Data.GLTF.scenes[0].nodes = Data.GLTF.scenes[0].nodes.Take(1).ToArray();
// 可視化メッシュ用マテリアル。base.LoadAsync を呼ぶ前に生成する。
var defaultMaterial = await MaterialFactory.GetDefaultMaterialAsync(awaitCaller);
// Humanoid Animation が Gltf アニメーションとしてロードされる
var instance = await base.LoadAsync(awaitCaller, measureTime);
@@ -285,7 +288,7 @@ namespace UniVRM10
// VRMA-animation solver
var animationInstance = instance.gameObject.AddComponent<Vrm10AnimationInstance>();
animationInstance.Initialize(expressions.Select(x => x.Key));
animationInstance.Initialize(expressions.Select(x => x.Key), defaultMaterial);
return instance;
}

View File

@@ -1,8 +1,7 @@
using UniGLTF;
using UnityEngine;
using UniVRM10;
using UniVRM10.VRM10Viewer;
using VRMShaders;
#if UNITY_EDITOR
using UnityEditor;
#endif
@@ -47,7 +46,7 @@ public class SimpleVrma : MonoBehaviour
showMeshes: false,
awaitCaller: new ImmediateCaller());
var instance = Vrm.GetComponentOrThrow<RuntimeGltfInstance>();
var instance = Vrm.GetComponent<RuntimeGltfInstance>();
instance.ShowMeshes();
}
@@ -58,11 +57,11 @@ public class SimpleVrma : MonoBehaviour
using var loader = new VrmAnimationImporter(data);
var instance = await loader.LoadAsync(new ImmediateCaller());
Vrma = instance.GetComponentOrThrow<Vrm10AnimationInstance>();
Vrma = instance.GetComponent<Vrm10AnimationInstance>();
Vrm.Runtime.VrmAnimation = Vrma;
Debug.Log(Vrma);
var animation = Vrma.GetComponentOrThrow<Animation>();
var animation = Vrma.GetComponent<Animation>();
animation.Play();
}
}

View File

@@ -46,7 +46,7 @@ namespace UniVRM10.URPSample
return;
}
var instance = _loadedVrm.GetComponentOrThrow<RuntimeGltfInstance>();
var instance = _loadedVrm.GetComponent<RuntimeGltfInstance>();
instance.ShowMeshes();
instance.EnableUpdateWhenOffscreen();

View File

@@ -33,7 +33,8 @@ namespace UniVRM10.FirstPersonSample
m_target.Source = m_source;
m_target.SourceType = UniHumanoid.HumanPoseTransfer.HumanPoseTransferSourceType.HumanPoseTransfer;
if (m_target.TryGetComponent<Animator>(out var animator))
var animator = m_target.GetComponent<Animator>();
if (animator != null)
{
if (m_faceCamera != null)
{
@@ -68,7 +69,7 @@ namespace UniVRM10.FirstPersonSample
return;
}
var instance = await LoadAsync(path, new VRMShaders.RuntimeOnlyAwaitCaller());
var instance = await LoadAsync(path, new RuntimeOnlyAwaitCaller());
var root = instance.gameObject;
root.transform.SetParent(transform, false);
@@ -83,14 +84,14 @@ namespace UniVRM10.FirstPersonSample
SetupTarget(m_target);
}
async Task<Vrm10Instance> LoadAsync(string path, VRMShaders.IAwaitCaller awaitCaller)
async Task<Vrm10Instance> LoadAsync(string path, IAwaitCaller awaitCaller)
{
var instance = await Vrm10.LoadPathAsync(path, awaitCaller: awaitCaller, showMeshes: false);
// VR用 FirstPerson 設定
await instance.Vrm.FirstPerson.SetupAsync(instance.gameObject, awaitCaller);
instance.GetComponentOrThrow<RuntimeGltfInstance>().ShowMeshes();
instance.GetComponent<RuntimeGltfInstance>().ShowMeshes();
return instance;
}
@@ -126,7 +127,7 @@ namespace UniVRM10.FirstPersonSample
{
GameObject.Destroy(m_source.gameObject);
}
m_source = context.Root.GetComponentOrThrow<UniHumanoid.HumanPoseTransfer>();
m_source = context.Root.GetComponent<UniHumanoid.HumanPoseTransfer>();
SetupTarget(m_target);
}

View File

@@ -1,7 +1,6 @@
using System.IO;
using UniGLTF;
using UnityEngine;
using VRMShaders;
namespace UniVRM10.RuntimeExporterSample
{
@@ -47,7 +46,7 @@ namespace UniVRM10.RuntimeExporterSample
}
var vrm10 = await Vrm10.LoadPathAsync(path);
var loaded = vrm10.GetComponentOrThrow<UniGLTF.RuntimeGltfInstance>();
var loaded = vrm10.GetComponent<UniGLTF.RuntimeGltfInstance>();
loaded.ShowMeshes();
loaded.EnableUpdateWhenOffscreen();
@@ -143,10 +142,7 @@ namespace UniVRM10.RuntimeExporterSample
model.ConvertCoordinate(VrmLib.Coordinates.Vrm1, ignoreVrm: false);
// export vrm-1.0
var exporter = new UniVRM10.Vrm10Exporter(new RuntimeTextureSerializer(), new GltfExportSettings
{
});
var exporter = new Vrm10Exporter(new GltfExportSettings());
exporter.Export(root, model, converter, new VrmLib.ExportArgs
{
}, meta);

View File

@@ -28,7 +28,10 @@ namespace UniVRM10.VRM10Viewer
// create SkinnedMesh for bone visualize
var animator = m_context.Root.GetComponent<Animator>();
m_boxMan = SkeletonMeshUtility.CreateRenderer(animator);
var material = new Material(Shader.Find("Standard"));
var tmpPrimitive = GameObject.CreatePrimitive(PrimitiveType.Quad);
var defaultMaterial = tmpPrimitive.GetComponent<Renderer>().sharedMaterial;
var material = new Material(defaultMaterial);
GameObject.Destroy(tmpPrimitive);
BoxMan.sharedMaterial = material;
var mesh = BoxMan.sharedMesh;
mesh.name = "box-man";

View File

@@ -1,5 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

View File

@@ -867,82 +867,6 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &251940583
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 251940584}
- component: {fileID: 251940586}
- component: {fileID: 251940585}
m_Layer: 5
m_Name: Checkmark
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &251940584
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 251940583}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 452923209}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 20, y: 20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &251940585
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 251940583}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10901, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &251940586
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 251940583}
m_CullTransparentMesh: 0
--- !u!1 &284921870
GameObject:
m_ObjectHideFlags: 0
@@ -1113,11 +1037,9 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 322182885}
- component: {fileID: 322182888}
- component: {fileID: 322182887}
- component: {fileID: 322182886}
m_Layer: 0
m_Name: Plane
m_Name: Floor
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@@ -1138,70 +1060,19 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &322182886
MeshRenderer:
--- !u!114 &322182886
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 322182884}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!64 &322182887
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 322182884}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 4
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &322182888
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 322182884}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1e6b73d090be404cad1a0e9839366ce2, type: 3}
m_Name:
m_EditorClassIdentifier:
_primitiveType: 4
--- !u!1 &339774396
GameObject:
m_ObjectHideFlags: 0
@@ -1250,7 +1121,6 @@ RectTransform:
- {fileID: 634488421}
- {fileID: 1767738854}
- {fileID: 103723704}
- {fileID: 1438613464}
- {fileID: 602093298}
m_Father: {fileID: 124675794}
m_RootOrder: 0
@@ -1480,83 +1350,6 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 20, y: 20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &452923208
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 452923209}
- component: {fileID: 452923211}
- component: {fileID: 452923210}
m_Layer: 5
m_Name: Background
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &452923209
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 452923208}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 251940584}
m_Father: {fileID: 1438613464}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 10, y: -10}
m_SizeDelta: {x: 20, y: 20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &452923210
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 452923208}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &452923211
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 452923208}
m_CullTransparentMesh: 0
--- !u!1 &488934504
GameObject:
m_ObjectHideFlags: 0
@@ -1905,7 +1698,7 @@ RectTransform:
- {fileID: 154330168}
- {fileID: 1954133885}
m_Father: {fileID: 339774397}
m_RootOrder: 18
m_RootOrder: 17
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -2533,10 +2326,8 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 802105004}
- component: {fileID: 802105003}
- component: {fileID: 802105002}
- component: {fileID: 802105001}
- component: {fileID: 802105005}
- component: {fileID: 802105006}
m_Layer: 5
m_Name: LookAtTarget
m_TagString: Untagged
@@ -2544,69 +2335,6 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!23 &802105001
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 802105000}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!135 &802105002
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 802105000}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
--- !u!33 &802105003
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 802105000}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &802105004
Transform:
m_ObjectHideFlags: 0
@@ -2638,6 +2366,19 @@ MonoBehaviour:
m_angularVelocity: 40
m_y: 1.5
m_height: 3
--- !u!114 &802105006
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 802105000}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1e6b73d090be404cad1a0e9839366ce2, type: 3}
m_Name:
m_EditorClassIdentifier:
_primitiveType: 0
--- !u!1 &806723448
GameObject:
m_ObjectHideFlags: 0
@@ -5617,93 +5358,6 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1434602808}
m_CullTransparentMesh: 0
--- !u!1 &1438613463
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1438613464}
- component: {fileID: 1438613465}
m_Layer: 5
m_Name: UseUrpMaterial
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1438613464
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1438613463}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 452923209}
- {fileID: 2090837017}
m_Father: {fileID: 339774397}
m_RootOrder: 17
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 162, y: 20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1438613465
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1438613463}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9085046f02f69544eb97fd06b6048fe2, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Highlighted
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 452923210}
toggleTransition: 1
graphic: {fileID: 251940585}
m_Group: {fileID: 0}
onValueChanged:
m_PersistentCalls:
m_Calls: []
m_IsOn: 0
--- !u!1 &1476033060
GameObject:
m_ObjectHideFlags: 0
@@ -6033,6 +5687,7 @@ GameObject:
- component: {fileID: 1629460661}
- component: {fileID: 1629460658}
- component: {fileID: 1629460657}
- component: {fileID: 1629460663}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
@@ -6121,6 +5776,39 @@ Transform:
m_Father: {fileID: 241398689}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1629460663
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1629460656}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_RenderShadows: 1
m_RequiresDepthTextureOption: 2
m_RequiresOpaqueTextureOption: 2
m_CameraType: 0
m_Cameras: []
m_RendererIndex: -1
m_VolumeLayerMask:
serializedVersion: 2
m_Bits: 1
m_VolumeTrigger: {fileID: 0}
m_VolumeFrameworkUpdateModeOption: 2
m_RenderPostProcessing: 0
m_Antialiasing: 0
m_AntialiasingQuality: 2
m_StopNaN: 0
m_Dithering: 0
m_ClearDepth: 1
m_AllowXRRendering: 1
m_RequiresDepthTexture: 0
m_RequiresColorTexture: 0
m_Version: 2
--- !u!1 &1633219307
GameObject:
m_ObjectHideFlags: 0
@@ -6828,7 +6516,6 @@ MonoBehaviour:
m_enableLipSync: {fileID: 935566650}
m_enableAutoBlink: {fileID: 634488422}
m_enableAutoExpression: {fileID: 1767738855}
m_useUrpMaterial: {fileID: 1438613465}
m_useAsync: {fileID: 602093299}
m_target: {fileID: 802105000}
m_motion: {fileID: 4900000, guid: 08df5151e71aed748b13547492fb8b9a, type: 3}
@@ -7771,86 +7458,6 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2055567528}
m_CullTransparentMesh: 1
--- !u!1 &2090837016
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2090837017}
- component: {fileID: 2090837019}
- component: {fileID: 2090837018}
m_Layer: 5
m_Name: Label
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2090837017
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2090837016}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1438613464}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 9, y: -0.5}
m_SizeDelta: {x: -28, y: -3}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2090837018
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2090837016}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Use URP Material
--- !u!222 &2090837019
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2090837016}
m_CullTransparentMesh: 0
--- !u!1 &2105159131
GameObject:
m_ObjectHideFlags: 0
@@ -7942,6 +7549,7 @@ GameObject:
m_Component:
- component: {fileID: 2141451818}
- component: {fileID: 2141451817}
- component: {fileID: 2141451819}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
@@ -8026,3 +7634,23 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 50, y: -210, z: 0}
--- !u!114 &2141451819
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2141451816}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Version: 1
m_UsePipelineSettings: 1
m_AdditionalLightsShadowResolutionTier: 2
m_LightLayerMask: 1
m_CustomShadowLayers: 0
m_ShadowLayerMask: 1
m_LightCookieSize: {x: 1, y: 1}
m_LightCookieOffset: {x: 0, y: 0}

View File

@@ -5,7 +5,6 @@ using System.Threading;
using UniGLTF;
using UnityEngine;
using UnityEngine.UI;
using VRMShaders;
namespace UniVRM10.VRM10Viewer
{
@@ -42,9 +41,6 @@ namespace UniVRM10.VRM10Viewer
[SerializeField]
Toggle m_enableAutoExpression = default;
[SerializeField]
Toggle m_useUrpMaterial = default;
[SerializeField]
Toggle m_useAsync = default;
@@ -270,7 +266,6 @@ namespace UniVRM10.VRM10Viewer
m_enableLipSync = toggles.First(x => x.name == "EnableLipSync");
m_enableAutoBlink = toggles.First(x => x.name == "EnableAutoBlink");
m_enableAutoExpression = toggles.First(x => x.name == "EnableAutoExpression");
m_useUrpMaterial = toggles.First(x => x.name == "UseUrpMaterial");
m_useAsync = toggles.First(x => x.name == "UseAsync");
#if UNITY_2022_3_OR_NEWER
@@ -545,8 +540,7 @@ namespace UniVRM10.VRM10Viewer
var vrm10Instance = await Vrm10.LoadPathAsync(path,
canLoadVrm0X: true,
showMeshes: false,
awaitCaller: m_useAsync.enabled ? (IAwaitCaller)new RuntimeOnlyAwaitCaller() : (IAwaitCaller)new ImmediateCaller(),
materialGenerator: GetVrmMaterialDescriptorGenerator(m_useUrpMaterial.isOn),
awaitCaller: m_useAsync.enabled ? new RuntimeOnlyAwaitCaller() : new ImmediateCaller(),
vrmMetaInformationCallback: m_texts.UpdateMeta,
ct: cancellationToken);
if (cancellationToken.IsCancellationRequested)

View File

@@ -0,0 +1,27 @@
using UnityEngine;
namespace UniVRM10.VRM10Viewer
{
/// <summary>
/// Built-in RP と URP の差異を楽に吸収してプリミティブを表示するためのクラス
/// </summary>
public class VRM10VisualPrimitive : MonoBehaviour
{
[SerializeField] private PrimitiveType _primitiveType;
public PrimitiveType PrimitiveType
{
get => _primitiveType;
set => _primitiveType = value;
}
private void Start()
{
var visual = GameObject.CreatePrimitive(_primitiveType);
visual.transform.SetParent(transform);
visual.transform.localPosition = Vector3.zero;
visual.transform.localRotation = Quaternion.identity;
visual.transform.localScale = Vector3.one;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1e6b73d090be404cad1a0e9839366ce2
timeCreated: 1721736320

View File

@@ -1,6 +1,6 @@
{
"name": "com.vrmc.vrm",
"version": "0.124.2",
"version": "0.125.0",
"displayName": "VRM-1.0",
"description": "VRM-1.0 importer",
"unity": "2021.3",
@@ -14,7 +14,7 @@
"name": "VRM Consortium"
},
"dependencies": {
"com.vrmc.gltf": "0.124.2"
"com.vrmc.gltf": "0.125.0"
},
"samples": [
{

View File

@@ -3,30 +3,34 @@
--- !u!310 &1
UnityConnectSettings:
m_ObjectHideFlags: 0
serializedVersion: 1
m_Enabled: 0
m_TestMode: 0
m_TestEventUrl:
m_TestConfigUrl:
m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events
m_EventUrl: https://cdp.cloud.unity3d.com/v1/events
m_ConfigUrl: https://config.uca.cloud.unity3d.com
m_DashboardUrl: https://dashboard.unity3d.com
m_TestInitMode: 0
CrashReportingSettings:
m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes
m_EventUrl: https://perf-events.cloud.unity3d.com
m_Enabled: 0
m_LogBufferSize: 10
m_CaptureEditorExceptions: 1
UnityPurchasingSettings:
m_Enabled: 0
m_TestMode: 0
UnityAnalyticsSettings:
m_Enabled: 0
m_InitializeOnStartup: 1
m_TestMode: 0
m_TestEventUrl:
m_TestConfigUrl:
m_InitializeOnStartup: 1
m_PackageRequiringCoreStatsPresent: 0
UnityAdsSettings:
m_Enabled: 0
m_InitializeOnStartup: 1
m_TestMode: 0
m_EnabledPlatforms: 4294967295
m_IosGameId:
m_AndroidGameId:
m_GameIds: {}
m_GameId:
PerformanceReportingSettings:
m_Enabled: 0