mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-08 02:34:39 -05:00
Convert VRM1.0 Material Import classes from static to instance class.
This commit is contained in:
parent
7e47a4f155
commit
90e7c2f588
|
|
@ -10,11 +10,12 @@ namespace UniVRM10
|
|||
public BuiltInGltfPbrMaterialImporter PbrMaterialImporter { get; } = new();
|
||||
public BuiltInGltfDefaultMaterialImporter DefaultMaterialImporter { get; } = new();
|
||||
public BuiltInGltfUnlitMaterialImporter UnlitMaterialImporter { get; } = new();
|
||||
public BuiltInVrm10MToonMaterialImporter MToonMaterialImporter { get; } = new();
|
||||
|
||||
public MaterialDescriptor Get(GltfData data, int i)
|
||||
{
|
||||
// mtoon
|
||||
if (BuiltInVrm10MToonMaterialImporter.TryCreateParam(data, i, out MaterialDescriptor matDesc)) return matDesc;
|
||||
if (MToonMaterialImporter.TryCreateParam(data, i, out MaterialDescriptor matDesc)) return matDesc;
|
||||
// unlit
|
||||
if (UnlitMaterialImporter.TryCreateParam(data, i, out matDesc)) return matDesc;
|
||||
// pbr
|
||||
|
|
|
|||
|
|
@ -11,14 +11,26 @@ using OutlineWidthMode = UniGLTF.Extensions.VRMC_materials_mtoon.OutlineWidthMod
|
|||
namespace UniVRM10
|
||||
{
|
||||
/// <summary>
|
||||
/// Convert MToon parameters from glTF specification to Unity implementation.
|
||||
/// A class that generates MaterialDescriptor for "VRM10/MToon10" shader based on vrm-1.0 Material specification.
|
||||
///
|
||||
/// https://github.com/vrm-c/vrm-specification/blob/master/specification/VRMC_materials_mtoon-1.0/README.md
|
||||
/// </summary>
|
||||
public static class BuiltInVrm10MToonMaterialImporter
|
||||
public class BuiltInVrm10MToonMaterialImporter
|
||||
{
|
||||
/// <summary>
|
||||
/// Can be replaced with custom shaders that are compatible with "VRM10/MToon10" properties and keywords.
|
||||
/// </summary>
|
||||
public Shader Shader { get; set; }
|
||||
|
||||
public BuiltInVrm10MToonMaterialImporter(Shader shader = null)
|
||||
{
|
||||
Shader = shader != null ? shader : Shader.Find("VRM10/MToon10");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// VMRC_materials_mtoon の場合にマテリアル生成情報を作成する
|
||||
/// </summary>
|
||||
public static bool TryCreateParam(GltfData data, int i, out MaterialDescriptor matDesc)
|
||||
public bool TryCreateParam(GltfData data, int i, out MaterialDescriptor matDesc)
|
||||
{
|
||||
var m = data.GLTF.materials[i];
|
||||
if (!UniGLTF.Extensions.VRMC_materials_mtoon.GltfDeserializer.TryGet(m.extensions,
|
||||
|
|
|
|||
|
|
@ -7,14 +7,26 @@ using VRM10.MToon10;
|
|||
namespace UniVRM10
|
||||
{
|
||||
/// <summary>
|
||||
/// Convert MToon parameters from glTF specification to Unity implementation.(for URP)
|
||||
/// A class that generates MaterialDescriptor for "VRM10/Universal Render Pipeline/MToon10" shader based on vrm-1.0 Material specification.
|
||||
///
|
||||
/// https://github.com/vrm-c/vrm-specification/blob/master/specification/VRMC_materials_mtoon-1.0/README.md
|
||||
/// </summary>
|
||||
public static class UrpVrm10MToonMaterialImporter
|
||||
public class UrpVrm10MToonMaterialImporter
|
||||
{
|
||||
/// <summary>
|
||||
/// Can be replaced with custom shaders that are compatible with "VRM10/Universal Render Pipeline/MToon10" properties and keywords.
|
||||
/// </summary>
|
||||
public Shader Shader { get; set; }
|
||||
|
||||
public UrpVrm10MToonMaterialImporter(Shader shader = null)
|
||||
{
|
||||
Shader = shader != null ? shader : Shader.Find("VRM10/Universal Render Pipeline/MToon10");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// VMRC_materials_mtoon の場合にマテリアル生成情報を作成する
|
||||
/// </summary>
|
||||
public static bool TryCreateParam(GltfData data, int i, out MaterialDescriptor matDesc)
|
||||
public bool TryCreateParam(GltfData data, int i, out MaterialDescriptor matDesc)
|
||||
{
|
||||
var m = data.GLTF.materials[i];
|
||||
if (!UniGLTF.Extensions.VRMC_materials_mtoon.GltfDeserializer.TryGet(m.extensions, out var mtoon))
|
||||
|
|
|
|||
|
|
@ -10,11 +10,12 @@ namespace UniVRM10
|
|||
public UrpGltfPbrMaterialImporter PbrMaterialImporter { get; } = new();
|
||||
public UrpGltfDefaultMaterialImporter DefaultMaterialImporter { get; } = new();
|
||||
public BuiltInGltfUnlitMaterialImporter UnlitMaterialImporter { get; } = new();
|
||||
public UrpVrm10MToonMaterialImporter MToonMaterialImporter { get; } = new();
|
||||
|
||||
public MaterialDescriptor Get(GltfData data, int i)
|
||||
{
|
||||
// mtoon
|
||||
if (UrpVrm10MToonMaterialImporter.TryCreateParam(data, i, out var matDesc)) return matDesc;
|
||||
if (MToonMaterialImporter.TryCreateParam(data, i, out var matDesc)) return matDesc;
|
||||
// unlit
|
||||
if (UnlitMaterialImporter.TryCreateParam(data, i, out matDesc)) return matDesc;
|
||||
// pbr
|
||||
|
|
|
|||
|
|
@ -7,9 +7,11 @@ namespace UniVRM10.VRM10Viewer
|
|||
/// </summary>
|
||||
public class UrpMToonMaterialImporter : IMaterialImporter
|
||||
{
|
||||
public UrpVrm10MToonMaterialImporter MToonMaterialImporter { get; } = new();
|
||||
|
||||
public bool TryCreateParam(GltfData data, int i, out MaterialDescriptor matDesc)
|
||||
{
|
||||
if (UrpVrm10MToonMaterialImporter.TryCreateParam(data, i, out matDesc))
|
||||
if (MToonMaterialImporter.TryCreateParam(data, i, out matDesc))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user