mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-28 22:04:56 -05:00
Merge pull request #1085 from ousttrue/feature10/VRMC_hdr_emissiveMultiplier
VRMC_materials_hdr_emissiveMultiplier 実装
This commit is contained in:
@@ -27,9 +27,17 @@ namespace UniGLTF
|
||||
return new SerializedPropertyEditor(serializedObject, prop);
|
||||
}
|
||||
|
||||
public void OnInspectorGUI()
|
||||
public void OnInspectorGUI(bool updateApply = true)
|
||||
{
|
||||
if (updateApply)
|
||||
{
|
||||
m_serializedObject.Update();
|
||||
}
|
||||
RecursiveProperty(m_rootProperty);
|
||||
if (updateApply)
|
||||
{
|
||||
m_serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void RecursiveProperty(SerializedProperty root)
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 094682fd8f99ab7488b000e12d6a45b3
|
||||
guid: c73bab19bcf7dca42be82c82a38a4011
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,27 +0,0 @@
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
public class GltfExportSettings : ScriptableObject
|
||||
{
|
||||
public GameObject Root { get; set; }
|
||||
|
||||
public Axes InverseAxis;
|
||||
|
||||
[Header("MorphTarget(BlendShape)")]
|
||||
public bool Sparse;
|
||||
|
||||
public bool DropNormal;
|
||||
|
||||
public bool DivideVertexBuffer;
|
||||
|
||||
public MeshExportSettings MeshExportSettings => new MeshExportSettings
|
||||
{
|
||||
UseSparseAccessorForMorphTarget = Sparse,
|
||||
ExportOnlyBlendShapePosition = DropNormal,
|
||||
DivideVertexBuffer = DivideVertexBuffer,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -28,18 +28,19 @@ namespace UniGLTF
|
||||
}
|
||||
Tabs _tab;
|
||||
|
||||
[SerializeField]
|
||||
public GltfExportSettings Settings = new GltfExportSettings();
|
||||
|
||||
GltfExportSettings m_settings;
|
||||
Editor m_settingsInspector;
|
||||
SerializedPropertyEditor m_editor;
|
||||
|
||||
MeshExportValidator m_meshes;
|
||||
Editor m_meshesInspector;
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
m_settings = ScriptableObject.CreateInstance<GltfExportSettings>();
|
||||
m_settings.InverseAxis = UniGLTFPreference.GltfIOAxis;
|
||||
m_settingsInspector = Editor.CreateEditor(m_settings);
|
||||
Settings.InverseAxis = UniGLTFPreference.GltfIOAxis;
|
||||
var so = new SerializedObject(this);
|
||||
m_editor = new SerializedPropertyEditor(so, so.FindProperty(nameof(Settings)));
|
||||
|
||||
m_meshes = ScriptableObject.CreateInstance<MeshExportValidator>();
|
||||
m_meshesInspector = Editor.CreateEditor(m_meshes);
|
||||
@@ -47,15 +48,9 @@ namespace UniGLTF
|
||||
|
||||
protected override void Clear()
|
||||
{
|
||||
// m_settingsInspector
|
||||
UnityEditor.Editor.DestroyImmediate(m_settingsInspector);
|
||||
m_settingsInspector = null;
|
||||
// m_meshesInspector
|
||||
UnityEditor.Editor.DestroyImmediate(m_meshesInspector);
|
||||
m_meshesInspector = null;
|
||||
// m_settings
|
||||
ScriptableObject.DestroyImmediate(m_settings);
|
||||
m_settings = null;
|
||||
}
|
||||
|
||||
protected override IEnumerable<Validator> ValidatorFactory()
|
||||
@@ -73,7 +68,7 @@ namespace UniGLTF
|
||||
|
||||
protected override void OnLayout()
|
||||
{
|
||||
m_meshes.SetRoot(State.ExportRoot, m_settings.MeshExportSettings, new DefualtBlendShapeExportFilter());
|
||||
m_meshes.SetRoot(State.ExportRoot, Settings, new DefualtBlendShapeExportFilter());
|
||||
}
|
||||
|
||||
protected override bool DoGUI(bool isValid)
|
||||
@@ -92,8 +87,7 @@ namespace UniGLTF
|
||||
break;
|
||||
|
||||
case Tabs.ExportSettings:
|
||||
m_settings.Root = State.ExportRoot;
|
||||
m_settingsInspector.OnInspectorGUI();
|
||||
m_editor.OnInspectorGUI();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -116,16 +110,10 @@ namespace UniGLTF
|
||||
}
|
||||
|
||||
var gltf = new glTF();
|
||||
using (var exporter = new gltfExporter(gltf, m_settings.InverseAxis))
|
||||
using (var exporter = new gltfExporter(gltf, Settings))
|
||||
{
|
||||
exporter.Prepare(State.ExportRoot);
|
||||
var settings = new MeshExportSettings
|
||||
{
|
||||
ExportOnlyBlendShapePosition = m_settings.DropNormal,
|
||||
UseSparseAccessorForMorphTarget = m_settings.Sparse,
|
||||
DivideVertexBuffer = m_settings.DivideVertexBuffer,
|
||||
};
|
||||
exporter.Export(settings, new EditorTextureSerializer());
|
||||
exporter.Export(Settings, new EditorTextureSerializer());
|
||||
}
|
||||
|
||||
if (isGlb)
|
||||
|
||||
@@ -31,8 +31,12 @@ namespace UniGLTF
|
||||
|
||||
public int ExpectedExportByteSize => Meshes.Where(x => x.IsRendererActive).Sum(x => x.ExportByteSize);
|
||||
|
||||
public void SetRoot(GameObject ExportRoot, MeshExportSettings settings, IBlendShapeExportFilter blendShapeFilter)
|
||||
public void SetRoot(GameObject ExportRoot, GltfExportSettings settings, IBlendShapeExportFilter blendShapeFilter)
|
||||
{
|
||||
if(ExportRoot==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MeshExportInfo.GetInfo(ExportRoot.transform.Traverse().Skip(1), Meshes, settings);
|
||||
foreach(var info in Meshes)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebda22df7de116b4dbc84385b56a69b8
|
||||
guid: 882d5cdaa29c5cf40bc5892189d0adba
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,60 @@
|
||||
// This file is generated from JsonSchema. Don't modify this source code.
|
||||
using UniJSON;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniGLTF.Extensions.VRMC_materials_hdr_emissiveMultiplier {
|
||||
|
||||
public static class GltfDeserializer
|
||||
{
|
||||
public static readonly Utf8String ExtensionNameUtf8 = Utf8String.From(VRMC_materials_hdr_emissiveMultiplier.ExtensionName);
|
||||
|
||||
public static bool TryGet(UniGLTF.glTFExtension src, out VRMC_materials_hdr_emissiveMultiplier extension)
|
||||
{
|
||||
if(src is UniGLTF.glTFExtensionImport extensions)
|
||||
{
|
||||
foreach(var kv in extensions.ObjectItems())
|
||||
{
|
||||
if(kv.Key.GetUtf8String() == ExtensionNameUtf8)
|
||||
{
|
||||
extension = Deserialize(kv.Value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static VRMC_materials_hdr_emissiveMultiplier Deserialize(JsonNode parsed)
|
||||
{
|
||||
var value = new VRMC_materials_hdr_emissiveMultiplier();
|
||||
|
||||
foreach(var kv in parsed.ObjectItems())
|
||||
{
|
||||
var key = kv.Key.GetString();
|
||||
|
||||
if(key=="extensions"){
|
||||
value.Extensions = new glTFExtensionImport(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="extras"){
|
||||
value.Extras = new glTFExtensionImport(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="emissiveMultiplier"){
|
||||
value.EmissiveMultiplier = kv.Value.GetSingle();
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
} // GltfDeserializer
|
||||
} // UniGLTF
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82aac657de39cf948ab7bf1be5a0f3ad
|
||||
guid: 751f36caf65fbcd4a91ae0d5419fdbd8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,22 @@
|
||||
// This file is generated from JsonSchema. Don't modify this source code.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace UniGLTF.Extensions.VRMC_materials_hdr_emissiveMultiplier
|
||||
{
|
||||
|
||||
public class VRMC_materials_hdr_emissiveMultiplier
|
||||
{
|
||||
public const string ExtensionName = "VRMC_materials_hdr_emissiveMultiplier";
|
||||
|
||||
// Dictionary object with extension-specific objects.
|
||||
public object Extensions;
|
||||
|
||||
// Application-specific data.
|
||||
public object Extras;
|
||||
|
||||
// A multiplier for emissiveFactor
|
||||
public float? EmissiveMultiplier;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 222764601817e1f459cb9ce3119ab0be
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
// This file is generated from JsonSchema. Don't modify this source code.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UniJSON;
|
||||
|
||||
namespace UniGLTF.Extensions.VRMC_materials_hdr_emissiveMultiplier {
|
||||
|
||||
static public class GltfSerializer
|
||||
{
|
||||
|
||||
public static void SerializeTo(ref UniGLTF.glTFExtension dst, VRMC_materials_hdr_emissiveMultiplier extension)
|
||||
{
|
||||
if (dst is glTFExtensionImport)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
if (!(dst is glTFExtensionExport extensions))
|
||||
{
|
||||
extensions = new glTFExtensionExport();
|
||||
dst = extensions;
|
||||
}
|
||||
|
||||
var f = new JsonFormatter();
|
||||
Serialize(f, extension);
|
||||
extensions.Add(VRMC_materials_hdr_emissiveMultiplier.ExtensionName, f.GetStoreBytes());
|
||||
}
|
||||
|
||||
|
||||
public static void Serialize(JsonFormatter f, VRMC_materials_hdr_emissiveMultiplier value)
|
||||
{
|
||||
f.BeginMap();
|
||||
|
||||
|
||||
if(value.Extensions!=null){
|
||||
f.Key("extensions");
|
||||
(value.Extensions as glTFExtension).Serialize(f);
|
||||
}
|
||||
|
||||
if(value.Extras!=null){
|
||||
f.Key("extras");
|
||||
(value.Extras as glTFExtension).Serialize(f);
|
||||
}
|
||||
|
||||
if(value.EmissiveMultiplier.HasValue){
|
||||
f.Key("emissiveMultiplier");
|
||||
f.Value(value.EmissiveMultiplier.GetValueOrDefault());
|
||||
}
|
||||
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
} // class
|
||||
} // namespace
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fc13fdbe30a3fa4381d8cb4aa8346c6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
44
Assets/UniGLTF/Runtime/UniGLTF/IO/GltfExportSettings.cs
Normal file
44
Assets/UniGLTF/Runtime/UniGLTF/IO/GltfExportSettings.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
|
||||
using System;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
[Serializable]
|
||||
public class GltfExportSettings
|
||||
{
|
||||
public Axes InverseAxis = Axes.Z;
|
||||
|
||||
/// <summary>
|
||||
/// https://github.com/vrm-c/UniVRM/issues/800
|
||||
///
|
||||
/// VertexBuffer を共有バッファ方式にする
|
||||
/// UniVRM-0.71.0 までの挙動
|
||||
/// </summary>
|
||||
public bool DivideVertexBuffer;
|
||||
|
||||
/// <summary>
|
||||
/// MorphTarget に Sparse Accessor を使う
|
||||
/// </summary>
|
||||
public bool UseSparseAccessorForMorphTarget;
|
||||
|
||||
/// <summary>
|
||||
/// MorphTarget を Position だけにする(normal とか捨てる)
|
||||
/// </summary>
|
||||
public bool ExportOnlyBlendShapePosition;
|
||||
|
||||
/// <summary>
|
||||
/// tangent を出力する
|
||||
/// </summary>
|
||||
public bool ExportTangents
|
||||
#if GLTF_EXPORT_TANGENTS
|
||||
= true,
|
||||
#endif
|
||||
;
|
||||
|
||||
/// <summary>
|
||||
/// VRMC_materials_hdr_emissiveMultiplier
|
||||
/// </summary>
|
||||
public bool UseEmissiveMultiplier;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e6d0977c916e05438394a6ea65b6a1c
|
||||
guid: ffb6f28f0bcf447468389128f208019c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -121,9 +121,13 @@ namespace UniGLTF
|
||||
|
||||
if (src.emissiveFactor != null && src.emissiveFactor.Length == 3)
|
||||
{
|
||||
matDesc.Colors.Add("_EmissionColor",
|
||||
src.emissiveFactor.ToColor3(ColorSpace.Linear, ColorSpace.Linear)
|
||||
);
|
||||
var emissiveFactor = src.emissiveFactor.ToColor3(ColorSpace.Linear, ColorSpace.Linear);
|
||||
if (UniGLTF.Extensions.VRMC_materials_hdr_emissiveMultiplier.GltfDeserializer.TryGet(src.extensions,
|
||||
out UniGLTF.Extensions.VRMC_materials_hdr_emissiveMultiplier.VRMC_materials_hdr_emissiveMultiplier ex))
|
||||
{
|
||||
emissiveFactor *= ex.EmissiveMultiplier.Value;
|
||||
}
|
||||
matDesc.Colors.Add("_EmissionColor", emissiveFactor);
|
||||
}
|
||||
|
||||
if (src.emissiveTexture != null && src.emissiveTexture.index != -1)
|
||||
|
||||
@@ -9,6 +9,6 @@ namespace UniGLTF
|
||||
/// </summary>
|
||||
public interface IMaterialExporter
|
||||
{
|
||||
glTFMaterial ExportMaterial(Material m, ITextureExporter textureExporter);
|
||||
glTFMaterial ExportMaterial(Material m, ITextureExporter textureExporter, GltfExportSettings settings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@ namespace UniGLTF
|
||||
|
||||
public class MaterialExporter : IMaterialExporter
|
||||
{
|
||||
public virtual glTFMaterial ExportMaterial(Material m, ITextureExporter textureExporter)
|
||||
public virtual glTFMaterial ExportMaterial(Material m, ITextureExporter textureExporter, GltfExportSettings settings)
|
||||
{
|
||||
var material = CreateMaterial(m);
|
||||
|
||||
// common params
|
||||
material.name = m.name;
|
||||
Export_Color(m, textureExporter, material);
|
||||
Export_Emission(m, textureExporter, material);
|
||||
Export_Emission(m, textureExporter, material, settings.UseEmissiveMultiplier);
|
||||
Export_Normal(m, textureExporter, material);
|
||||
Export_OcclusionMetallicRoughness(m, textureExporter, material);
|
||||
|
||||
@@ -148,17 +148,28 @@ namespace UniGLTF
|
||||
}
|
||||
}
|
||||
|
||||
static void Export_Emission(Material m, ITextureExporter textureExporter, glTFMaterial material)
|
||||
static void Export_Emission(Material m, ITextureExporter textureExporter, glTFMaterial material, bool useEmissiveMultiplier)
|
||||
{
|
||||
if (m.IsKeywordEnabled("_EMISSION") == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m.HasProperty("_EmissionColor"))
|
||||
{
|
||||
var color = m.GetColor("_EmissionColor");
|
||||
if (color.maxColorComponent > 1)
|
||||
{
|
||||
color /= color.maxColorComponent;
|
||||
var maxColorComponent = color.maxColorComponent;
|
||||
color /= maxColorComponent;
|
||||
if (useEmissiveMultiplier)
|
||||
{
|
||||
UniGLTF.Extensions.VRMC_materials_hdr_emissiveMultiplier.GltfSerializer.SerializeTo(ref material.extensions,
|
||||
new Extensions.VRMC_materials_hdr_emissiveMultiplier.VRMC_materials_hdr_emissiveMultiplier
|
||||
{
|
||||
EmissiveMultiplier = maxColorComponent,
|
||||
});
|
||||
}
|
||||
}
|
||||
material.emissiveFactor = color.ToFloat3(ColorSpace.Linear, ColorSpace.Linear);
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace UniGLTF
|
||||
public string Summary;
|
||||
#endregion
|
||||
|
||||
MeshExportInfo(Renderer renderer, MeshExportSettings settings)
|
||||
MeshExportInfo(Renderer renderer, GltfExportSettings settings)
|
||||
{
|
||||
if (renderer == null)
|
||||
{
|
||||
@@ -264,7 +264,7 @@ namespace UniGLTF
|
||||
public static MeshExportInfo Create(GameObject go)
|
||||
{
|
||||
var list = new List<MeshExportInfo>();
|
||||
GetInfo(go.transform.Traverse(), list, MeshExportSettings.Default);
|
||||
GetInfo(go.transform.Traverse(), list, new GltfExportSettings());
|
||||
return list[0];
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ namespace UniGLTF
|
||||
/// <param name="list"></param>
|
||||
/// <param name="settings"></param>
|
||||
/// <param name="blendShapeFilter"> blendShape の export を filtering する </param>
|
||||
public static void GetInfo(IEnumerable<Transform> nodes, List<MeshExportInfo> list, MeshExportSettings settings)
|
||||
public static void GetInfo(IEnumerable<Transform> nodes, List<MeshExportInfo> list, GltfExportSettings settings)
|
||||
{
|
||||
list.Clear();
|
||||
foreach (var node in nodes)
|
||||
@@ -311,7 +311,7 @@ namespace UniGLTF
|
||||
public void CalcMeshSize(
|
||||
GameObject root,
|
||||
Renderer renderer,
|
||||
MeshExportSettings settings,
|
||||
GltfExportSettings settings,
|
||||
IBlendShapeExportFilter blendShapeFilter
|
||||
)
|
||||
{
|
||||
@@ -321,7 +321,7 @@ namespace UniGLTF
|
||||
|
||||
public void CalcMeshSize(
|
||||
string relativePath,
|
||||
MeshExportSettings settings,
|
||||
GltfExportSettings settings,
|
||||
IBlendShapeExportFilter blendShapeFilter
|
||||
)
|
||||
{
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
[Serializable]
|
||||
public struct MeshExportSettings
|
||||
{
|
||||
//
|
||||
// https://github.com/vrm-c/UniVRM/issues/800
|
||||
//
|
||||
// VertexBuffer を共有バッファ方式にする
|
||||
// UniVRM-0.71.0 までの挙動
|
||||
//
|
||||
public bool DivideVertexBuffer;
|
||||
|
||||
// MorphTarget に Sparse Accessor を使う
|
||||
public bool UseSparseAccessorForMorphTarget;
|
||||
|
||||
// MorphTarget を Position だけにする(normal とか捨てる)
|
||||
public bool ExportOnlyBlendShapePosition;
|
||||
|
||||
// tangent を出力する
|
||||
public bool ExportTangents;
|
||||
|
||||
public static MeshExportSettings Default => new MeshExportSettings
|
||||
{
|
||||
UseSparseAccessorForMorphTarget = false,
|
||||
ExportOnlyBlendShapePosition = false,
|
||||
DivideVertexBuffer = false,
|
||||
#if GLTF_EXPORT_TANGENTS
|
||||
ExportTangents = true,
|
||||
#endif
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ namespace UniGLTF
|
||||
/// <returns></returns>
|
||||
public static (glTFMesh, Dictionary<int, int>) Export(glTF gltf, int gltfBuffer,
|
||||
MeshExportInfo unityMesh, List<Material> unityMaterials,
|
||||
IAxisInverter axisInverter, MeshExportSettings settings)
|
||||
IAxisInverter axisInverter, GltfExportSettings settings)
|
||||
{
|
||||
var mesh = unityMesh.Mesh;
|
||||
var gltfMesh = new glTFMesh(mesh.name);
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace UniGLTF
|
||||
/// <returns></returns>
|
||||
public static (glTFMesh, Dictionary<int, int> blendShapeIndexMap) Export(glTF gltf, int bufferIndex,
|
||||
MeshExportInfo unityMesh, List<Material> unityMaterials,
|
||||
IAxisInverter axisInverter, MeshExportSettings settings)
|
||||
IAxisInverter axisInverter, GltfExportSettings settings)
|
||||
{
|
||||
var mesh = unityMesh.Mesh;
|
||||
var materials = unityMesh.Materials;
|
||||
|
||||
@@ -64,9 +64,10 @@ namespace UniGLTF
|
||||
}
|
||||
|
||||
TextureExporter m_textureExporter;
|
||||
IAxisInverter m_axisInverter;
|
||||
|
||||
public gltfExporter(glTF gltf, Axes invertAxis = Axes.Z)
|
||||
GltfExportSettings m_settings;
|
||||
|
||||
public gltfExporter(glTF gltf, GltfExportSettings settings)
|
||||
{
|
||||
glTF = gltf;
|
||||
|
||||
@@ -78,7 +79,12 @@ namespace UniGLTF
|
||||
version = "2.0",
|
||||
};
|
||||
|
||||
m_axisInverter = invertAxis.Create();
|
||||
m_settings = settings;
|
||||
if (m_settings == null)
|
||||
{
|
||||
// default
|
||||
m_settings = new GltfExportSettings();
|
||||
}
|
||||
}
|
||||
|
||||
GameObject m_tmpParent = null;
|
||||
@@ -87,7 +93,7 @@ namespace UniGLTF
|
||||
{
|
||||
// コピーを作って左手系を右手系に変換する
|
||||
Copy = GameObject.Instantiate(go);
|
||||
Copy.transform.ReverseRecursive(m_axisInverter);
|
||||
Copy.transform.ReverseRecursive(m_settings.InverseAxis.Create());
|
||||
|
||||
// Export の root は gltf の scene になるので、
|
||||
// エクスポート対象が単一の GameObject の場合に、
|
||||
@@ -216,7 +222,7 @@ namespace UniGLTF
|
||||
// do nothing
|
||||
}
|
||||
|
||||
public virtual void Export(MeshExportSettings meshExportSettings, ITextureSerializer textureSerializer)
|
||||
public virtual void Export(GltfExportSettings meshExportSettings, ITextureSerializer textureSerializer)
|
||||
{
|
||||
var bytesBuffer = new ArrayByteBuffer(new byte[50 * 1024 * 1024]);
|
||||
var bufferIndex = glTF.AddBuffer(bytesBuffer);
|
||||
@@ -234,7 +240,7 @@ namespace UniGLTF
|
||||
m_textureExporter = new TextureExporter(textureSerializer);
|
||||
|
||||
var materialExporter = CreateMaterialExporter();
|
||||
glTF.materials = Materials.Select(x => materialExporter.ExportMaterial(x, TextureExporter)).ToList();
|
||||
glTF.materials = Materials.Select(x => materialExporter.ExportMaterial(x, TextureExporter, m_settings)).ToList();
|
||||
#endregion
|
||||
|
||||
#region Meshes
|
||||
@@ -242,8 +248,8 @@ namespace UniGLTF
|
||||
foreach (var unityMesh in uniqueUnityMeshes)
|
||||
{
|
||||
var (gltfMesh, blendShapeIndexMap) = meshExportSettings.DivideVertexBuffer
|
||||
? MeshExporter_DividedVertexBuffer.Export(glTF, bufferIndex, unityMesh, Materials, m_axisInverter, meshExportSettings)
|
||||
: MeshExporter_SharedVertexBuffer.Export(glTF, bufferIndex, unityMesh, Materials, m_axisInverter, meshExportSettings)
|
||||
? MeshExporter_DividedVertexBuffer.Export(glTF, bufferIndex, unityMesh, Materials, m_settings.InverseAxis.Create(), meshExportSettings)
|
||||
: MeshExporter_SharedVertexBuffer.Export(glTF, bufferIndex, unityMesh, Materials, m_settings.InverseAxis.Create(), meshExportSettings)
|
||||
;
|
||||
glTF.meshes.Add(gltfMesh);
|
||||
Meshes.Add(unityMesh.Mesh);
|
||||
@@ -281,7 +287,7 @@ namespace UniGLTF
|
||||
{
|
||||
if (uniqueBones != null && renderer is SkinnedMeshRenderer smr)
|
||||
{
|
||||
var matrices = x.GetBindPoses().Select(m_axisInverter.InvertMat4).ToArray();
|
||||
var matrices = x.GetBindPoses().Select(m_settings.InverseAxis.Create().InvertMat4).ToArray();
|
||||
var accessor = glTF.ExtendBufferAndGetAccessorIndex(bufferIndex, matrices, glBufferTarget.NONE);
|
||||
var skin = new glTFSkin
|
||||
{
|
||||
|
||||
@@ -19,9 +19,9 @@ namespace UniGLTF
|
||||
private static readonly Texture2D NormalMapGrayTex = AssetDatabase.LoadAssetAtPath<Texture2D>($"{AssetPath}/{NormalMapGrayImageName}.png");
|
||||
private static readonly Color32 JustGray = new Color32(127, 127, 127, 255);
|
||||
private static readonly Color32 SrgbGrayInSrgb = JustGray;
|
||||
private static readonly Color32 SrgbGrayInLinear = ((Color) SrgbGrayInSrgb).linear;
|
||||
private static readonly Color32 SrgbGrayInLinear = ((Color)SrgbGrayInSrgb).linear;
|
||||
private static readonly Color32 LinearGrayInLinear = JustGray;
|
||||
private static readonly Color32 LinearGrayInSrgb = ((Color) LinearGrayInLinear).gamma;
|
||||
private static readonly Color32 LinearGrayInSrgb = ((Color)LinearGrayInLinear).gamma;
|
||||
private static readonly Color32 NormalizedLinearGrayInLinear = new Color32(127, 127, 255, 255);
|
||||
|
||||
[Test]
|
||||
@@ -123,10 +123,13 @@ namespace UniGLTF
|
||||
|
||||
// Export glTF
|
||||
var gltf = new glTF();
|
||||
using (var exporter = new gltfExporter(gltf, Axes.X))
|
||||
using (var exporter = new gltfExporter(gltf, new GltfExportSettings
|
||||
{
|
||||
InverseAxis = Axes.X
|
||||
}))
|
||||
{
|
||||
exporter.Prepare(root);
|
||||
var settings = new MeshExportSettings
|
||||
var settings = new GltfExportSettings
|
||||
{
|
||||
ExportOnlyBlendShapePosition = false,
|
||||
UseSparseAccessorForMorphTarget = false,
|
||||
|
||||
@@ -58,10 +58,10 @@ namespace UniGLTF
|
||||
static Byte[] Export(GameObject root)
|
||||
{
|
||||
var gltf = new glTF();
|
||||
using (var exporter = new gltfExporter(gltf))
|
||||
using (var exporter = new gltfExporter(gltf, new GltfExportSettings()))
|
||||
{
|
||||
exporter.Prepare(root);
|
||||
exporter.Export(MeshExportSettings.Default, new EditorTextureSerializer());
|
||||
exporter.Export(new GltfExportSettings(), new EditorTextureSerializer());
|
||||
return gltf.ToGlbBytes();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace UniGLTF
|
||||
srcMaterial.mainTextureScale = scale;
|
||||
|
||||
var materialExporter = new MaterialExporter();
|
||||
var gltfMaterial = materialExporter.ExportMaterial(srcMaterial, textureExporter);
|
||||
var gltfMaterial = materialExporter.ExportMaterial(srcMaterial, textureExporter, new GltfExportSettings());
|
||||
gltfMaterial.pbrMetallicRoughness.baseColorTexture.extensions = gltfMaterial.pbrMetallicRoughness.baseColorTexture.extensions.Deserialize();
|
||||
|
||||
Assert.IsTrue(glTF_KHR_texture_transform.TryGet(gltfMaterial.pbrMetallicRoughness.baseColorTexture, out glTF_KHR_texture_transform t));
|
||||
@@ -243,7 +243,7 @@ namespace UniGLTF
|
||||
material.EnableKeyword("_EMISSION");
|
||||
var materialExporter = new MaterialExporter();
|
||||
var textureExporter = new TextureExporter(new EditorTextureSerializer());
|
||||
var gltfMaterial = materialExporter.ExportMaterial(material, textureExporter);
|
||||
var gltfMaterial = materialExporter.ExportMaterial(material, textureExporter, new GltfExportSettings());
|
||||
|
||||
Assert.AreEqual(gltfMaterial.emissiveFactor, new float[] { 0, 0.5f, 1 });
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace UniGLTF
|
||||
|
||||
try
|
||||
{
|
||||
validator.SetRoot(root, MeshExportSettings.Default, new DefualtBlendShapeExportFilter());
|
||||
validator.SetRoot(root, new GltfExportSettings(), new DefualtBlendShapeExportFilter());
|
||||
var vs = validator.Validate(root);
|
||||
Assert.False(vs.All(x => x.CanExport));
|
||||
}
|
||||
@@ -46,7 +46,7 @@ namespace UniGLTF
|
||||
|
||||
try
|
||||
{
|
||||
validator.SetRoot(root, MeshExportSettings.Default, new DefualtBlendShapeExportFilter());
|
||||
validator.SetRoot(root, new GltfExportSettings(), new DefualtBlendShapeExportFilter());
|
||||
var vs = validator.Validate(root);
|
||||
Assert.False(vs.All(x => x.CanExport));
|
||||
}
|
||||
@@ -66,7 +66,7 @@ namespace UniGLTF
|
||||
|
||||
try
|
||||
{
|
||||
validator.SetRoot(root, MeshExportSettings.Default, new DefualtBlendShapeExportFilter());
|
||||
validator.SetRoot(root, new GltfExportSettings(), new DefualtBlendShapeExportFilter());
|
||||
var vs = validator.Validate(root);
|
||||
Assert.False(vs.All(x => x.CanExport));
|
||||
}
|
||||
@@ -90,7 +90,7 @@ namespace UniGLTF
|
||||
// remove MeshFilter
|
||||
Component.DestroyImmediate(child.GetComponent<MeshFilter>());
|
||||
|
||||
validator.SetRoot(root, MeshExportSettings.Default, new DefualtBlendShapeExportFilter());
|
||||
validator.SetRoot(root, new GltfExportSettings(), new DefualtBlendShapeExportFilter());
|
||||
var vs = validator.Validate(root);
|
||||
Assert.True(vs.All(x => x.CanExport));
|
||||
}
|
||||
@@ -114,7 +114,7 @@ namespace UniGLTF
|
||||
// set null
|
||||
child.GetComponent<MeshFilter>().sharedMesh = null;
|
||||
|
||||
validator.SetRoot(root, MeshExportSettings.Default, new DefualtBlendShapeExportFilter());
|
||||
validator.SetRoot(root, new GltfExportSettings(), new DefualtBlendShapeExportFilter());
|
||||
var vs = validator.Validate(root);
|
||||
Assert.True(vs.All(x => x.CanExport));
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace UniGLTF
|
||||
};
|
||||
|
||||
var (go, mesh) = CreateMesh(Materials.ToArray());
|
||||
var meshExportSettings = new MeshExportSettings
|
||||
var meshExportSettings = new GltfExportSettings
|
||||
{
|
||||
DivideVertexBuffer = false
|
||||
};
|
||||
@@ -176,7 +176,7 @@ namespace UniGLTF
|
||||
};
|
||||
|
||||
var (go, mesh) = CreateMesh(Materials.ToArray());
|
||||
var meshExportSettings = new MeshExportSettings
|
||||
var meshExportSettings = new GltfExportSettings
|
||||
{
|
||||
DivideVertexBuffer = true
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace UniGLTF
|
||||
material.mainTexture = tex0;
|
||||
|
||||
var materialExporter = new MaterialExporter();
|
||||
materialExporter.ExportMaterial(material, textureExporter);
|
||||
materialExporter.ExportMaterial(material, textureExporter, new GltfExportSettings());
|
||||
|
||||
var exported = textureExporter.Export();
|
||||
|
||||
|
||||
@@ -103,10 +103,10 @@ namespace UniGLTF
|
||||
var gltf = new glTF();
|
||||
|
||||
string json = null;
|
||||
using (var exporter = new gltfExporter(gltf))
|
||||
using (var exporter = new gltfExporter(gltf, new GltfExportSettings()))
|
||||
{
|
||||
exporter.Prepare(go);
|
||||
exporter.Export(MeshExportSettings.Default, new EditorTextureSerializer());
|
||||
exporter.Export(new GltfExportSettings(), new EditorTextureSerializer());
|
||||
|
||||
// remove empty buffer
|
||||
gltf.buffers.Clear();
|
||||
@@ -294,10 +294,10 @@ namespace UniGLTF
|
||||
public void GlTFToJsonTest()
|
||||
{
|
||||
var gltf = new glTF();
|
||||
using (var exporter = new gltfExporter(gltf))
|
||||
using (var exporter = new gltfExporter(gltf, new GltfExportSettings()))
|
||||
{
|
||||
exporter.Prepare(CreateSimpleScene());
|
||||
exporter.Export(MeshExportSettings.Default, new EditorTextureSerializer());
|
||||
exporter.Export(new GltfExportSettings(), new EditorTextureSerializer());
|
||||
}
|
||||
|
||||
var expected = gltf.ToJson().ParseAsJson();
|
||||
@@ -530,10 +530,10 @@ namespace UniGLTF
|
||||
// export
|
||||
var gltf = new glTF();
|
||||
var json = default(string);
|
||||
using (var exporter = new gltfExporter(gltf))
|
||||
using (var exporter = new gltfExporter(gltf, new GltfExportSettings()))
|
||||
{
|
||||
exporter.Prepare(go);
|
||||
exporter.Export(UniGLTF.MeshExportSettings.Default, new EditorTextureSerializer());
|
||||
exporter.Export(new UniGLTF.GltfExportSettings(), new EditorTextureSerializer());
|
||||
|
||||
json = gltf.ToJson();
|
||||
}
|
||||
@@ -612,10 +612,10 @@ namespace UniGLTF
|
||||
// export
|
||||
var gltf = new glTF();
|
||||
string json;
|
||||
using (var exporter = new gltfExporter(gltf))
|
||||
using (var exporter = new gltfExporter(gltf, new GltfExportSettings()))
|
||||
{
|
||||
exporter.Prepare(go);
|
||||
exporter.Export(UniGLTF.MeshExportSettings.Default, new EditorTextureSerializer());
|
||||
exporter.Export(new UniGLTF.GltfExportSettings(), new EditorTextureSerializer());
|
||||
|
||||
json = gltf.ToJson();
|
||||
}
|
||||
@@ -669,17 +669,17 @@ namespace UniGLTF
|
||||
}
|
||||
|
||||
// validate
|
||||
validator.SetRoot(root, MeshExportSettings.Default, new DefualtBlendShapeExportFilter());
|
||||
validator.SetRoot(root, new GltfExportSettings(), new DefualtBlendShapeExportFilter());
|
||||
var vs = validator.Validate(root);
|
||||
Assert.True(vs.All(x => x.CanExport));
|
||||
|
||||
// export
|
||||
var gltf = new glTF();
|
||||
string json;
|
||||
using (var exporter = new gltfExporter(gltf))
|
||||
using (var exporter = new gltfExporter(gltf, new GltfExportSettings()))
|
||||
{
|
||||
exporter.Prepare(root);
|
||||
exporter.Export(UniGLTF.MeshExportSettings.Default, new EditorTextureSerializer());
|
||||
exporter.Export(new UniGLTF.GltfExportSettings(), new EditorTextureSerializer());
|
||||
|
||||
json = gltf.ToJson();
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace VRM.Samples
|
||||
*/
|
||||
importedJson.RemoveValue(Utf8String.From("/bufferViews/*/byteStride"));
|
||||
|
||||
var vrm = VRMExporter.Export(UniGLTF.MeshExportSettings.Default, loaded.gameObject, new EditorTextureSerializer());
|
||||
var vrm = VRMExporter.Export(new GltfExportSettings(), loaded.gameObject, new EditorTextureSerializer());
|
||||
|
||||
// TODO: Check contents in JSON
|
||||
/*var exportJson = */
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace VRM.Samples
|
||||
var material = Resources.Load<Material>(resourceName);
|
||||
var exporter = new VRMMaterialExporter();
|
||||
var textureExporter = new TextureExporter(new EditorTextureSerializer());
|
||||
var exported = exporter.ExportMaterial(material, textureExporter);
|
||||
var exported = exporter.ExportMaterial(material, textureExporter, new GltfExportSettings());
|
||||
|
||||
// parse glTFExtensionExport to glTFExtensionImport
|
||||
exported.extensions = exported.extensions.Deserialize();
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace VRM.Samples
|
||||
return;
|
||||
}
|
||||
|
||||
var vrm = VRMExporter.Export(UniGLTF.MeshExportSettings.Default, m_model, new RuntimeTextureSerializer());
|
||||
var vrm = VRMExporter.Export(new UniGLTF.GltfExportSettings(), m_model, new RuntimeTextureSerializer());
|
||||
var bytes = vrm.ToGlbBytes();
|
||||
File.WriteAllBytes(path, bytes);
|
||||
Debug.LogFormat("export to {0}", path);
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace VRM
|
||||
[Tooltip("Divide vertex buffer. For more gltf compatibility")]
|
||||
public bool DivideVertexBuffer = false;
|
||||
|
||||
public MeshExportSettings MeshExportSettings => new MeshExportSettings
|
||||
public GltfExportSettings MeshExportSettings => new GltfExportSettings
|
||||
{
|
||||
UseSparseAccessorForMorphTarget = UseSparseAccessor,
|
||||
ExportOnlyBlendShapePosition = OnlyBlendshapePosition,
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace VRM
|
||||
return new VRMMaterialExporter();
|
||||
}
|
||||
|
||||
public static glTF Export(MeshExportSettings configuration, GameObject go, ITextureSerializer textureSerializer)
|
||||
public static glTF Export(GltfExportSettings configuration, GameObject go, ITextureSerializer textureSerializer)
|
||||
{
|
||||
var gltf = new glTF();
|
||||
using (var exporter = new VRMExporter(gltf))
|
||||
@@ -28,7 +28,7 @@ namespace VRM
|
||||
|
||||
public readonly VRM.glTF_VRM_extensions VRM = new glTF_VRM_extensions();
|
||||
|
||||
public VRMExporter(glTF gltf) : base(gltf, Axes.Z)
|
||||
public VRMExporter(glTF gltf) : base(gltf, new GltfExportSettings())
|
||||
{
|
||||
gltf.extensionsUsed.Add(glTF_VRM_extensions.ExtensionName);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace VRM
|
||||
try
|
||||
{
|
||||
// export
|
||||
var vrm = VRMExporter.Export(UniGLTF.MeshExportSettings.Default, go, new EditorTextureSerializer());
|
||||
var vrm = VRMExporter.Export(new UniGLTF.GltfExportSettings(), go, new EditorTextureSerializer());
|
||||
|
||||
// re import
|
||||
if (vrm != null)
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace VRM
|
||||
var path = AliciaPath;
|
||||
var loaded = Load(File.ReadAllBytes(path), path);
|
||||
|
||||
var exported = VRMExporter.Export(new UniGLTF.MeshExportSettings
|
||||
var exported = VRMExporter.Export(new UniGLTF.GltfExportSettings
|
||||
{
|
||||
DivideVertexBuffer = true, // test this
|
||||
ExportOnlyBlendShapePosition = true,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0e684fa1214e6f419f662ce3db4f991
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -38,7 +38,7 @@ RenderSettings:
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0.4465791, g: 0.4964133, b: 0.57481784, a: 1}
|
||||
m_IndirectSpecularColor: {r: 0.18028381, g: 0.22571406, b: 0.30692294, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
@@ -3750,6 +3750,97 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1322834809}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!1 &1407428956
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1407428958}
|
||||
- component: {fileID: 1407428957}
|
||||
- component: {fileID: 1407428959}
|
||||
m_Layer: 0
|
||||
m_Name: PostProcess
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!20 &1407428957
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1407428956}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_GateFitMode: 2
|
||||
m_FocalLength: 50
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 1000
|
||||
field of view: 60
|
||||
orthographic: 0
|
||||
orthographic size: 5
|
||||
m_Depth: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 1
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 1
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!4 &1407428958
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1407428956}
|
||||
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_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 6
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1407428959
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1407428956}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8b9a305e18de0c04dbd257a21cd47087, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
sharedProfile: {fileID: 11400000, guid: b0e684fa1214e6f419f662ce3db4f991, type: 2}
|
||||
isGlobal: 1
|
||||
blendDistance: 0
|
||||
weight: 1
|
||||
priority: 0
|
||||
--- !u!1 &1476033060
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -3991,10 +4082,10 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 1629460662}
|
||||
- component: {fileID: 1629460661}
|
||||
- component: {fileID: 1629460660}
|
||||
- component: {fileID: 1629460659}
|
||||
- component: {fileID: 1629460658}
|
||||
- component: {fileID: 1629460657}
|
||||
- component: {fileID: 1629460660}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
@@ -4033,14 +4124,66 @@ Behaviour:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1629460656}
|
||||
m_Enabled: 1
|
||||
--- !u!92 &1629460660
|
||||
Behaviour:
|
||||
--- !u!114 &1629460660
|
||||
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: 948f4100a11a5c24981795d21301da5c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
volumeTrigger: {fileID: 1629460662}
|
||||
volumeLayer:
|
||||
serializedVersion: 2
|
||||
m_Bits: 1
|
||||
stopNaNPropagation: 1
|
||||
finalBlitToCameraTarget: 0
|
||||
antialiasingMode: 0
|
||||
temporalAntialiasing:
|
||||
jitterSpread: 0.75
|
||||
sharpness: 0.25
|
||||
stationaryBlending: 0.95
|
||||
motionBlending: 0.85
|
||||
subpixelMorphologicalAntialiasing:
|
||||
quality: 2
|
||||
fastApproximateAntialiasing:
|
||||
fastMode: 0
|
||||
keepAlpha: 0
|
||||
fog:
|
||||
enabled: 1
|
||||
excludeSkybox: 1
|
||||
debugLayer:
|
||||
lightMeter:
|
||||
width: 512
|
||||
height: 256
|
||||
showCurves: 1
|
||||
histogram:
|
||||
width: 512
|
||||
height: 256
|
||||
channel: 3
|
||||
waveform:
|
||||
exposure: 0.12
|
||||
height: 256
|
||||
vectorscope:
|
||||
size: 256
|
||||
exposure: 0.12
|
||||
overlaySettings:
|
||||
linearDepth: 0
|
||||
motionColorIntensity: 4
|
||||
motionGridSize: 64
|
||||
colorBlindnessType: 0
|
||||
colorBlindnessStrength: 1
|
||||
m_Resources: {fileID: 11400000, guid: d82512f9c8e5d4a4d938b575d47f88d4, type: 2}
|
||||
m_ShowToolkit: 0
|
||||
m_ShowCustomSorter: 0
|
||||
breakBeforeColorGrading: 0
|
||||
m_BeforeTransparentBundles: []
|
||||
m_BeforeStackBundles: []
|
||||
m_AfterStackBundles: []
|
||||
--- !u!20 &1629460661
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -4079,7 +4222,7 @@ Camera:
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 1
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_ForceIntoRT: 1
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
|
||||
@@ -47,7 +47,6 @@ namespace UniVRM10
|
||||
}
|
||||
EditorGUILayout.Separator();
|
||||
|
||||
serializedObject.Update();
|
||||
switch (_tab)
|
||||
{
|
||||
case Tabs.Meta:
|
||||
@@ -66,7 +65,6 @@ namespace UniVRM10
|
||||
m_firstPerson.OnInspectorGUI();
|
||||
break;
|
||||
}
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,10 +41,10 @@ namespace UniVRM10
|
||||
"vrm-specification/specification/VRMC_vrm-1.0_draft/schema/VRMC_vrm.schema.json",
|
||||
"Assets/VRM10/Runtime/Format/Vrm", // format
|
||||
"Assets/VRM10/Runtime/Format/Vrm", // serializer
|
||||
// VRMC_node_constraint
|
||||
"vrm-specification/specification/VRMC_node_constraint-1.0_draft/schema/VRMC_node_constraint.schema.json",
|
||||
"Assets/VRM10/Runtime/Format/Constraints", // format
|
||||
"Assets/VRM10/Runtime/Format/Constraints", // serializer
|
||||
// VRMC_hdr_emissiveMultiplier
|
||||
"vrm-specification/specification/VRMC_materials_hdr_emissiveMultiplier-1.0_draft/schema/VRMC_materials_hdr_emissiveMultiplier.json",
|
||||
"Assets/VRMShaders/VRM10/Format/Runtime/EmissiveMultiplier", // format
|
||||
"Assets/VRM10/Runtime/Format/EmissiveMultiplier", // serializer
|
||||
// VRMC_materials_mtoon
|
||||
"vrm-specification/specification/VRMC_materials_mtoon-1.0_draft/schema/VRMC_materials_mtoon.schema.json",
|
||||
"Assets/VRMShaders/VRM10/Format/Runtime/MaterialsMToon", // format
|
||||
@@ -53,6 +53,10 @@ namespace UniVRM10
|
||||
"vrm-specification/specification/VRMC_springBone-1.0_draft/schema/VRMC_springBone.schema.json",
|
||||
"Assets/VRM10/Runtime/Format/SpringBone", // format
|
||||
"Assets/VRM10/Runtime/Format/SpringBone", // serializer
|
||||
// VRMC_node_constraint
|
||||
"vrm-specification/specification/VRMC_node_constraint-1.0_draft/schema/VRMC_node_constraint.schema.json",
|
||||
"Assets/VRM10/Runtime/Format/Constraints", // format
|
||||
"Assets/VRM10/Runtime/Format/Constraints", // serializer
|
||||
};
|
||||
|
||||
for (int i = 0; i < args.Length; i += 3)
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace UniVRM10
|
||||
[Tooltip("Remove blendShapeClip that preset is Unknown")]
|
||||
public bool ReduceBlendshapeClip = false;
|
||||
|
||||
public MeshExportSettings MeshExportSettings => new MeshExportSettings
|
||||
public GltfExportSettings MeshExportSettings => new GltfExportSettings
|
||||
{
|
||||
UseSparseAccessorForMorphTarget = true,
|
||||
ExportOnlyBlendShapePosition = true,
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace UniVRM10
|
||||
}
|
||||
}
|
||||
VRM10Object m_tmpObject;
|
||||
(VRM10MetaEditor, SerializedObject) m_metaEditor;
|
||||
VRM10MetaEditor m_metaEditor;
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
@@ -235,7 +235,7 @@ namespace UniVRM10
|
||||
switch (_tab)
|
||||
{
|
||||
case Tabs.Meta:
|
||||
if (m_metaEditor.Item1 == null)
|
||||
if (m_metaEditor == null)
|
||||
{
|
||||
SerializedObject so;
|
||||
if (m_meta != null)
|
||||
@@ -246,11 +246,9 @@ namespace UniVRM10
|
||||
{
|
||||
so = new SerializedObject(m_tmpObject);
|
||||
}
|
||||
m_metaEditor = (VRM10MetaEditor.Create(so), so);
|
||||
m_metaEditor = VRM10MetaEditor.Create(so);
|
||||
}
|
||||
m_metaEditor.Item2.Update();
|
||||
m_metaEditor.Item1.OnInspectorGUI();
|
||||
m_metaEditor.Item2.ApplyModifiedProperties();
|
||||
m_metaEditor.OnInspectorGUI();
|
||||
break;
|
||||
|
||||
case Tabs.Mesh:
|
||||
@@ -297,7 +295,7 @@ namespace UniVRM10
|
||||
model.ConvertCoordinate(VrmLib.Coordinates.Vrm1, ignoreVrm: false);
|
||||
|
||||
// export vrm-1.0
|
||||
var exporter = new UniVRM10.Vrm10Exporter(new EditorTextureSerializer());
|
||||
var exporter = new UniVRM10.Vrm10Exporter(new EditorTextureSerializer(), new GltfExportSettings());
|
||||
var option = new VrmLib.ExportArgs();
|
||||
exporter.Export(root, model, converter, option, Vrm ? Vrm.Meta : m_tmpObject.Meta);
|
||||
|
||||
|
||||
@@ -2487,8 +2487,8 @@ public static TextureTransformBind __expressions_ITEM_Deserialize_TextureTransfo
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="scaling"){
|
||||
value.Scaling = __expressions_ITEM__textureTransformBinds_ITEM_Deserialize_Scaling(kv.Value);
|
||||
if(key=="scale"){
|
||||
value.Scale = __expressions_ITEM__textureTransformBinds_ITEM_Deserialize_Scale(kv.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2501,7 +2501,7 @@ public static TextureTransformBind __expressions_ITEM_Deserialize_TextureTransfo
|
||||
return value;
|
||||
}
|
||||
|
||||
public static float[] __expressions_ITEM__textureTransformBinds_ITEM_Deserialize_Scaling(JsonNode parsed)
|
||||
public static float[] __expressions_ITEM__textureTransformBinds_ITEM_Deserialize_Scale(JsonNode parsed)
|
||||
{
|
||||
var value = new float[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
||||
@@ -457,7 +457,7 @@ namespace UniGLTF.Extensions.VRMC_vrm
|
||||
public int? Material;
|
||||
|
||||
// uv scaling for TEXCOORD_0
|
||||
public float[] Scaling;
|
||||
public float[] Scale;
|
||||
|
||||
// uv offset for TEXCOORD_0
|
||||
public float[] Offset;
|
||||
|
||||
@@ -2223,9 +2223,9 @@ public static void __expressions_ITEM_Serialize_TextureTransformBinds_ITEM(JsonF
|
||||
f.Value(value.Material.GetValueOrDefault());
|
||||
}
|
||||
|
||||
if(value.Scaling!=null&&value.Scaling.Count()>=2){
|
||||
f.Key("scaling");
|
||||
__expressions_ITEM__textureTransformBinds_ITEM_Serialize_Scaling(f, value.Scaling);
|
||||
if(value.Scale!=null&&value.Scale.Count()>=2){
|
||||
f.Key("scale");
|
||||
__expressions_ITEM__textureTransformBinds_ITEM_Serialize_Scale(f, value.Scale);
|
||||
}
|
||||
|
||||
if(value.Offset!=null&&value.Offset.Count()>=2){
|
||||
@@ -2236,7 +2236,7 @@ public static void __expressions_ITEM_Serialize_TextureTransformBinds_ITEM(JsonF
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void __expressions_ITEM__textureTransformBinds_ITEM_Serialize_Scaling(JsonFormatter f, float[] value)
|
||||
public static void __expressions_ITEM__textureTransformBinds_ITEM_Serialize_Scale(JsonFormatter f, float[] value)
|
||||
{
|
||||
f.BeginList();
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace UniVRM10
|
||||
binding = new UniVRM10.MaterialUVBinding
|
||||
{
|
||||
MaterialName = material.name, // 名前で持つべき
|
||||
Scaling = new Vector2(bind.Scaling[0], bind.Scaling[1]),
|
||||
Scaling = new Vector2(bind.Scale[0], bind.Scale[1]),
|
||||
Offset = new Vector2(bind.Offset[0], bind.Offset[1]),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -18,8 +18,12 @@ namespace UniVRM10
|
||||
ITextureSerializer m_textureSerializer;
|
||||
TextureExporter m_textureExporter;
|
||||
|
||||
public Vrm10Exporter(ITextureSerializer textureSerializer)
|
||||
GltfExportSettings m_settings;
|
||||
|
||||
public Vrm10Exporter(ITextureSerializer textureSerializer, GltfExportSettings settings)
|
||||
{
|
||||
m_settings = settings;
|
||||
|
||||
if (textureSerializer == null)
|
||||
{
|
||||
throw new ArgumentException(nameof(textureSerializer));
|
||||
@@ -172,7 +176,7 @@ namespace UniVRM10
|
||||
var materialExporter = new Vrm10MaterialExporter();
|
||||
foreach (Material material in model.Materials)
|
||||
{
|
||||
var glTFMaterial = materialExporter.ExportMaterial(material, m_textureExporter);
|
||||
var glTFMaterial = materialExporter.ExportMaterial(material, m_textureExporter, m_settings);
|
||||
Storage.Gltf.materials.Add(glTFMaterial);
|
||||
}
|
||||
|
||||
@@ -550,7 +554,7 @@ namespace UniVRM10
|
||||
{
|
||||
Material = getIndex(binding.MaterialName),
|
||||
Offset = new float[] { binding.Offset.x, binding.Offset.y },
|
||||
Scaling = new float[] { binding.Scaling.x, binding.Scaling.y },
|
||||
Scale = new float[] { binding.Scaling.x, binding.Scaling.y },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -794,7 +798,7 @@ namespace UniVRM10
|
||||
VrmLib.ModelExtensionsForCoordinates.ConvertCoordinate(model, VrmLib.Coordinates.Vrm1);
|
||||
|
||||
// Model と go から VRM-1.0 にExport
|
||||
var exporter10 = new Vrm10Exporter(textureSerializer ?? new RuntimeTextureSerializer());
|
||||
var exporter10 = new Vrm10Exporter(textureSerializer ?? new RuntimeTextureSerializer(), new GltfExportSettings());
|
||||
var option = new VrmLib.ExportArgs
|
||||
{
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace UniVRM10
|
||||
{
|
||||
public class Vrm10MaterialExporter : MaterialExporter
|
||||
{
|
||||
public override glTFMaterial ExportMaterial(Material m, ITextureExporter textureExporter)
|
||||
public override glTFMaterial ExportMaterial(Material m, ITextureExporter textureExporter, GltfExportSettings settings)
|
||||
{
|
||||
if (Vrm10MToonMaterialExporter.TryExportMaterialAsMToon(m, textureExporter, out var dst))
|
||||
{
|
||||
@@ -14,7 +14,7 @@ namespace UniVRM10
|
||||
}
|
||||
else
|
||||
{
|
||||
return base.ExportMaterial(m, textureExporter);
|
||||
return base.ExportMaterial(m, textureExporter, settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace UniVRM10
|
||||
expression.TextureTransformBinds.Add(new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind
|
||||
{
|
||||
Material = materialIndex,
|
||||
Scaling = new float[] { targetValue[0], targetValue[1] },
|
||||
Scale = new float[] { targetValue[0], targetValue[1] },
|
||||
Offset = new float[] { targetValue[2], targetValue[3] }
|
||||
});
|
||||
}
|
||||
@@ -126,7 +126,7 @@ namespace UniVRM10
|
||||
expression.TextureTransformBinds.Add(new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind
|
||||
{
|
||||
Material = materialIndex,
|
||||
Scaling = new float[] { targetValue[0], 1 },
|
||||
Scale = new float[] { targetValue[0], 1 },
|
||||
Offset = new float[] { targetValue[2], 0 }
|
||||
});
|
||||
}
|
||||
@@ -135,7 +135,7 @@ namespace UniVRM10
|
||||
expression.TextureTransformBinds.Add(new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind
|
||||
{
|
||||
Material = materialIndex,
|
||||
Scaling = new float[] { 1, targetValue[1] },
|
||||
Scale = new float[] { 1, targetValue[1] },
|
||||
Offset = new float[] { 0, targetValue[3] }
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"com.unity.analytics": "3.2.3",
|
||||
"com.unity.collab-proxy": "1.2.15",
|
||||
"com.unity.package-manager-ui": "2.0.13",
|
||||
"com.unity.postprocessing": "3.0.3",
|
||||
"com.unity.purchasing": "2.0.3",
|
||||
"com.unity.textmeshpro": "1.4.1",
|
||||
"com.unity.modules.ai": "1.0.0",
|
||||
|
||||
Submodule vrm-specification updated: a755e9ab6b...ad2ff4ef12
Reference in New Issue
Block a user