diff --git a/Assets/VRM10/Tests/MaterialImportTests.cs b/Assets/VRM10/Tests/MaterialImportTests.cs index 503b30a33..cbe82ce0b 100644 --- a/Assets/VRM10/Tests/MaterialImportTests.cs +++ b/Assets/VRM10/Tests/MaterialImportTests.cs @@ -26,7 +26,7 @@ namespace UniVRM10 var matDesc = new Vrm10MaterialDescriptorGenerator().Get(data, 0); Assert.AreEqual("Alicia_body", matDesc.Name); - Assert.AreEqual("Hidden/VRM10/vrmc_materials_mtoon", matDesc.ShaderName); + Assert.AreEqual("VRM10/MToon10", matDesc.ShaderName); Assert.AreEqual("Alicia_body", matDesc.TextureSlots["_MainTex"].UnityObjectName); Assert.AreEqual("Alicia_body", matDesc.TextureSlots["_ShadeTex"].UnityObjectName); diff --git a/Assets/VRMShaders/VRM10/MToon10/Editor/MToon10EditorEditMode.cs b/Assets/VRMShaders/VRM10/MToon10/Editor/MToon10EditorEditMode.cs new file mode 100644 index 000000000..07855be10 --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Editor/MToon10EditorEditMode.cs @@ -0,0 +1,8 @@ +namespace VRMShaders.VRM10.MToon10.Editor +{ + public enum MToon10EditorEditMode + { + Basic = 0, + Advanced = 1, + } +} \ No newline at end of file diff --git a/Assets/VRMShaders/VRM10/MToon10/Editor/MToon10EditorEditMode.cs.meta b/Assets/VRMShaders/VRM10/MToon10/Editor/MToon10EditorEditMode.cs.meta new file mode 100644 index 000000000..924035f7a --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Editor/MToon10EditorEditMode.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 22a9170004064d029bc205fc5b5a1acc +timeCreated: 1626335293 \ No newline at end of file diff --git a/Assets/VRMShaders/VRM10/MToon10/Editor/MToonInspector.cs b/Assets/VRMShaders/VRM10/MToon10/Editor/MToonInspector.cs index 7bf96ec6e..438e4bb34 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Editor/MToonInspector.cs +++ b/Assets/VRMShaders/VRM10/MToon10/Editor/MToonInspector.cs @@ -19,12 +19,21 @@ namespace VRMShaders.VRM10.MToon10.Editor EditorGUI.BeginChangeCheck(); + EditorGUILayout.HelpBox("This shader is for VRM 1.0.", MessageType.Info); + + using (new LabelScope("Editor Settings")) + { + PopupEnum("Edit Mode", props[MToon10Prop.EditorEditMode], materialEditor); + } + var editMode = (MToon10EditorEditMode) (int) props[MToon10Prop.EditorEditMode].floatValue; + var isAdvancedEditMode = editMode == MToon10EditorEditMode.Advanced; + using (new LabelScope("Rendering")) { PopupEnum("Alpha Mode", props[MToon10Prop.AlphaMode], materialEditor); var alphaMode = (MToon10AlphaMode) (int) props[MToon10Prop.AlphaMode].floatValue; - if (alphaMode == MToon10AlphaMode.Transparent) + if (isAdvancedEditMode && alphaMode == MToon10AlphaMode.Transparent) { PopupEnum( "Transparent With ZWrite Mode", @@ -40,7 +49,10 @@ namespace VRMShaders.VRM10.MToon10.Editor PopupEnum("Double Sided", props[MToon10Prop.DoubleSided], materialEditor); - materialEditor.ShaderProperty(props[MToon10Prop.RenderQueueOffsetNumber], "RenderQueue Offset"); + if (isAdvancedEditMode) + { + materialEditor.ShaderProperty(props[MToon10Prop.RenderQueueOffsetNumber], "RenderQueue Offset"); + } } using (new LabelScope("Lighting")) @@ -55,23 +67,73 @@ namespace VRMShaders.VRM10.MToon10.Editor props[MToon10Prop.ShadeColorTexture], props[MToon10Prop.ShadeColorFactor] ); - materialEditor.TexturePropertySingleLine( - new GUIContent("Normal Map", "Normal Map (RGB)"), - props[MToon10Prop.NormalTexture], - props[MToon10Prop.NormalTextureScale] - ); - materialEditor.ShaderProperty(props[MToon10Prop.ShadingShiftFactor], "Shading Shift"); - materialEditor.ShaderProperty(props[MToon10Prop.ShadingToonyFactor], "Shading Toony"); - materialEditor.TexturePropertySingleLine( - new GUIContent("Additive Shading Shift", "Shading Shift (R)"), - props[MToon10Prop.ShadingShiftTexture], - props[MToon10Prop.ShadingShiftTextureScale] - ); + if (isAdvancedEditMode) + { + materialEditor.TexturePropertySingleLine( + new GUIContent("Normal Map", "Normal Map (RGB)"), + props[MToon10Prop.NormalTexture], + props[MToon10Prop.NormalTextureScale] + ); + } + EditorGUILayout.Space(); + + if (isAdvancedEditMode) + { + materialEditor.ShaderProperty(props[MToon10Prop.ShadingToonyFactor], "Shading Toony"); + materialEditor.ShaderProperty(props[MToon10Prop.ShadingShiftFactor], "Shading Shift"); + materialEditor.TexturePropertySingleLine( + new GUIContent("Additive Shading Shift", "Shading Shift (R)"), + props[MToon10Prop.ShadingShiftTexture], + props[MToon10Prop.ShadingShiftTextureScale] + ); + } + else + { + EditorGUILayout.BeginHorizontal(); + GUILayout.Label("Presets"); + if (GUILayout.Button("Default")) + { + props[MToon10Prop.ShadingToonyFactor].floatValue = 0.95f; + props[MToon10Prop.ShadingShiftFactor].floatValue = -0.05f; + props[MToon10Prop.ShadingShiftTexture].textureValue = null; + } + if (GUILayout.Button("Lambert")) + { + props[MToon10Prop.ShadingToonyFactor].floatValue = 0.5f; + props[MToon10Prop.ShadingShiftFactor].floatValue = -0.5f; + props[MToon10Prop.ShadingShiftTexture].textureValue = null; + } + if (GUILayout.Button("Cartoon")) + { + props[MToon10Prop.ShadingToonyFactor].floatValue = 1.0f; + props[MToon10Prop.ShadingShiftFactor].floatValue = 0.0f; + props[MToon10Prop.ShadingShiftTexture].textureValue = null; + } + EditorGUILayout.EndHorizontal(); + + GUILayout.BeginVertical(GUI.skin.box); + materialEditor.ShaderProperty(props[MToon10Prop.ShadingToonyFactor], "Shading Toony"); + materialEditor.ShaderProperty(props[MToon10Prop.ShadingShiftFactor], "Shading Shift"); + GUILayout.EndVertical(); + } + + if (props[MToon10Prop.ShadingShiftTexture].textureValue == null) + { + var toony = props[MToon10Prop.ShadingToonyFactor].floatValue; + var shift = props[MToon10Prop.ShadingShiftFactor].floatValue; + if (toony - shift < 1.0f - 0.001f) + { + EditorGUILayout.HelpBox("The lit area includes non-lit area.", MessageType.Warning); + } + } } - using (new LabelScope("Global Illumination")) + if (isAdvancedEditMode) { - materialEditor.ShaderProperty(props[MToon10Prop.GiEqualizationFactor], "GI Equalization"); + using (new LabelScope("Global Illumination")) + { + materialEditor.ShaderProperty(props[MToon10Prop.GiEqualizationFactor], "GI Equalization"); + } } using (new LabelScope("Emission")) @@ -89,16 +151,19 @@ namespace VRMShaders.VRM10.MToon10.Editor new GUIContent("Rim Color", "Rim Color (RGB)"), props[MToon10Prop.RimMultiplyTexture] ); - materialEditor.ShaderProperty( - props[MToon10Prop.RimLightingMixFactor], - new GUIContent("Rim LightingMix") - ); - EditorGUILayout.Space(); + if (isAdvancedEditMode) + { + materialEditor.ShaderProperty( + props[MToon10Prop.RimLightingMixFactor], + new GUIContent("Rim LightingMix") + ); + EditorGUILayout.Space(); - materialEditor.TexturePropertySingleLine( - new GUIContent("Matcap Rim", "Matcap Rim (RGB)"), - props[MToon10Prop.MatcapTexture] - ); + materialEditor.TexturePropertySingleLine( + new GUIContent("Matcap Rim", "Matcap Rim (RGB)"), + props[MToon10Prop.MatcapTexture] + ); + } EditorGUILayout.Space(); materialEditor.ShaderProperty( @@ -118,39 +183,50 @@ namespace VRMShaders.VRM10.MToon10.Editor using (new LabelScope("Outline")) { PopupEnum("Outline Mode", props[MToon10Prop.OutlineWidthMode], materialEditor); - materialEditor.TexturePropertySingleLine( - new GUIContent("Outline Width", "Outline Width (G) [meter]"), - props[MToon10Prop.OutlineWidthMultiplyTexture], - props[MToon10Prop.OutlineWidthFactor] - ); - materialEditor.ShaderProperty( - props[MToon10Prop.OutlineColorFactor], - new GUIContent("Outline Color") - ); - materialEditor.ShaderProperty( - props[MToon10Prop.OutlineLightingMixFactor], - new GUIContent("Outline LightingMix") - ); + var hasOutline = (MToon10OutlineMode) (int) props[MToon10Prop.OutlineWidthMode].floatValue != MToon10OutlineMode.None; + + if (hasOutline) + { + materialEditor.TexturePropertySingleLine( + new GUIContent("Outline Width", "Outline Width (G) [meter]"), + props[MToon10Prop.OutlineWidthMultiplyTexture], + props[MToon10Prop.OutlineWidthFactor] + ); + materialEditor.ShaderProperty( + props[MToon10Prop.OutlineColorFactor], + new GUIContent("Outline Color") + ); + if (isAdvancedEditMode) + { + materialEditor.ShaderProperty( + props[MToon10Prop.OutlineLightingMixFactor], + new GUIContent("Outline LightingMix") + ); + } + } } - using (new LabelScope("UV Animation")) + if (isAdvancedEditMode) { - materialEditor.TexturePropertySingleLine( - new GUIContent("Mask", "Mask (B)"), - props[MToon10Prop.UvAnimationMaskTexture] - ); - materialEditor.ShaderProperty( - props[MToon10Prop.UvAnimationScrollXSpeedFactor], - new GUIContent("Translate X") - ); - materialEditor.ShaderProperty( - props[MToon10Prop.UvAnimationScrollYSpeedFactor], - new GUIContent("Translate Y") - ); - materialEditor.ShaderProperty( - props[MToon10Prop.UvAnimationRotationSpeedFactor], - new GUIContent("Rotation") - ); + using (new LabelScope("UV Animation")) + { + materialEditor.TexturePropertySingleLine( + new GUIContent("Mask", "Mask (B)"), + props[MToon10Prop.UvAnimationMaskTexture] + ); + materialEditor.ShaderProperty( + props[MToon10Prop.UvAnimationScrollXSpeedFactor], + new GUIContent("Translate X") + ); + materialEditor.ShaderProperty( + props[MToon10Prop.UvAnimationScrollYSpeedFactor], + new GUIContent("Translate Y") + ); + materialEditor.ShaderProperty( + props[MToon10Prop.UvAnimationRotationSpeedFactor], + new GUIContent("Rotation") + ); + } } if (EditorGUI.EndChangeCheck()) @@ -158,12 +234,11 @@ namespace VRMShaders.VRM10.MToon10.Editor Validate(materials); } - using (new LabelScope("Debug")) + if (isAdvancedEditMode && materials.Length == 1) { - if (materials.Length == 1) + var mat = materials[0]; + using (new LabelScope("Debug")) { - var mat = materials[0]; - EditorGUILayout.LabelField("RenderQueue", mat.renderQueue.ToString()); EditorGUILayout.LabelField("Cull", ((CullMode) props[MToon10Prop.UnityCullMode].floatValue).ToString()); EditorGUILayout.LabelField("SrcBlend", ((BlendMode) props[MToon10Prop.UnitySrcBlend].floatValue).ToString()); @@ -193,7 +268,7 @@ namespace VRMShaders.VRM10.MToon10.Editor var changed = EditorGUI.EndChangeCheck(); if (changed) { - editor.RegisterPropertyChangeUndo("EnumPopUp"); + editor.RegisterPropertyChangeUndo($"Change {name}"); property.floatValue = ret; } diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon.shader b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon.shader index 9b9e53978..f4c59d7d0 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon.shader +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon.shader @@ -1,4 +1,4 @@ -Shader "Hidden/VRM10/vrmc_materials_mtoon" +Shader "VRM10/MToon10" { Properties { @@ -16,10 +16,10 @@ Shader "Hidden/VRM10/vrmc_materials_mtoon" _ShadeTex ("mtoon.shadeMultiplyTexture", 2D) = "white" {} [Normal] _BumpMap ("normalTexture", 2D) = "bump" {} // Unity specified name _BumpScale ("normalTexture.scale", Float) = 1.0 // Unity specified name - _ShadingShiftFactor ("mtoon.shadingShiftFactor", Range(-1, 1)) = 0 + _ShadingShiftFactor ("mtoon.shadingShiftFactor", Range(-1, 1)) = -0.05 _ShadingShiftTex ("mtoon.shadingShiftTexture", 2D) = "black" {} // channel R _ShadingShiftTexScale ("mtoon.shadingShiftTexture.scale", Float) = 1 - _ShadingToonyFactor ("mtoon.shadingToonyFactor", Range(0, 1)) = 0.9 + _ShadingToonyFactor ("mtoon.shadingToonyFactor", Range(0, 1)) = 0.95 // GI _GiEqualization ("mtoon.giEqualizationFactor", Range(0, 1)) = 0.9 @@ -58,6 +58,9 @@ Shader "Hidden/VRM10/vrmc_materials_mtoon" // etc _M_DebugMode ("_DebugMode", Float) = 0.0 + + // for Editor + _M_EditMode ("_EditMode", Float) = 0.0 } // Shader Model 3.0 diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_define.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_define.hlsl index cb983736f..cec236313 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_define.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_define.hlsl @@ -18,6 +18,13 @@ #define MTOON_IS_FRONT_VFACE(VAL, FRONT, BACK) ((VAL > 0.0) ? (FRONT) : (BACK)) #endif +// Compile-time constant +// EXPERIMENTAL +inline bool MToon_IsPbrCorrectOn() +{ + return false; +} + // Compile-time constant inline bool MToon_IsForwardBasePass() { diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl index f7a74039e..b7dc73cac 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl @@ -24,15 +24,16 @@ Varyings MToonVertex(const Attributes v) // v is UnityCG macro specified name. const VertexPositionInfo position = MToon_GetOutlineVertex(v.vertex.xyz, normalize(v.normalOS), output.uv); output.pos = position.positionCS; output.positionWS = position.positionWS; + output.normalWS = UnityObjectToWorldNormal(-v.normalOS); } else { const VertexPositionInfo position = MToon_GetVertex(v.vertex.xyz); output.pos = position.positionCS; output.positionWS = position.positionWS; + output.normalWS = UnityObjectToWorldNormal(v.normalOS); } - output.normalWS = UnityObjectToWorldNormal(v.normalOS); output.viewDirWS = MToon_GetWorldSpaceNormalizedViewDir(output.positionWS); #if defined(_NORMALMAP) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl index bee7da2dd..494ceb559 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl @@ -38,10 +38,16 @@ inline half GetMToonLighting_Shade(const UnityLighting lighting, const MToonInpu const half shadeShift = GetMToonLighting_Reflectance_ShadingShift(input); const half shadeToony = _ShadingToonyFactor; + if (MToon_IsPbrCorrectOn()) + { + const half shadeInput = dotNL; + return mtoon_linearstep(-1.0 + shadeToony, +1.0 - shadeToony, shadeInput + shadeShift); + } + if (MToon_IsForwardBasePass()) { - const half shadeInput = lerp(-1, 1, mtoon_linearstep(-1, 1, dotNL) * lighting.directLightAttenuation); - return mtoon_linearstep(-1.0 + shadeToony, +1.0 - shadeToony, shadeInput + shadeShift); + const half shadeInput = lerp(-1, 1, mtoon_linearstep(-1, 1, dotNL)); + return mtoon_linearstep(-1.0 + shadeToony, +1.0 - shadeToony, shadeInput + shadeShift) * lighting.directLightAttenuation; } else { @@ -52,6 +58,11 @@ inline half GetMToonLighting_Shade(const UnityLighting lighting, const MToonInpu inline half GetMToonLighting_Shadow(const UnityLighting lighting, const half dotNL) { + if (MToon_IsPbrCorrectOn()) + { + return lighting.directLightAttenuation * step(0, dotNL); + } + if (MToon_IsForwardBasePass()) { return 1; diff --git a/Assets/VRMShaders/VRM10/MToon10/Runtime/MToon10Migrator.cs b/Assets/VRMShaders/VRM10/MToon10/Runtime/MToon10Migrator.cs index 317b40c48..cd49fa111 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Runtime/MToon10Migrator.cs +++ b/Assets/VRMShaders/VRM10/MToon10/Runtime/MToon10Migrator.cs @@ -25,8 +25,8 @@ namespace VRMShaders.VRM10.MToon10.Runtime { var (rangeMin, rangeMax) = GetShadingRange0X(shadingToony0X, shadingShift0X); - // new shadingShift is the center of range. - return Mathf.Clamp((rangeMax - rangeMin) * 0.5f, -1, +1); + // new shadingShift is the center of range inverted. + return Mathf.Clamp((rangeMax + rangeMin) * 0.5f * -1f, -1, +1); } /// diff --git a/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Meta.cs b/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Meta.cs index 331a7e7af..8141abb90 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Meta.cs +++ b/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Meta.cs @@ -2,6 +2,6 @@ { public static class MToon10Meta { - public static readonly string UnityShaderName = "Hidden/VRM10/vrmc_materials_mtoon"; + public static readonly string UnityShaderName = "VRM10/MToon10"; } } \ No newline at end of file diff --git a/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Prop.cs b/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Prop.cs index c7047cecf..6a0b6e386 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Prop.cs +++ b/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Prop.cs @@ -55,5 +55,8 @@ UnityDstBlend, UnityZWrite, UnityAlphaToMask, + + // for Editor + EditorEditMode, } } \ No newline at end of file diff --git a/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Properties.cs b/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Properties.cs index 29aa35d7b..fb209cfcc 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Properties.cs +++ b/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Properties.cs @@ -51,6 +51,8 @@ namespace VRMShaders.VRM10.MToon10.Runtime [MToon10Prop.UnityDstBlend] = "_M_DstBlend", [MToon10Prop.UnityZWrite] = "_M_ZWrite", [MToon10Prop.UnityAlphaToMask] = "_M_AlphaToMask", + + [MToon10Prop.EditorEditMode] = "_M_EditMode", }; public static IReadOnlyDictionary UnityShaderLabNames => _unityShaderLabNames; diff --git a/Assets/VRMShaders/VRM10/MToon10/Tests.meta b/Assets/VRMShaders/VRM10/MToon10/Tests.meta new file mode 100644 index 000000000..00f95abe0 --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Tests.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f5d3d10dc09b0524abb5c55599bb14e8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRMShaders/VRM10/MToon10/Tests/MigrationTests.cs b/Assets/VRMShaders/VRM10/MToon10/Tests/MigrationTests.cs new file mode 100644 index 000000000..7be8d4939 --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Tests/MigrationTests.cs @@ -0,0 +1,48 @@ +using NUnit.Framework; +using VRMShaders.VRM10.MToon10.Runtime; + +namespace VRMShaders.VRM10.MToon10.Tests +{ + public sealed class MigrationTests + { + [Test] + public void MigrateToonyAndShift() + { + var delta = 0.001f; + + // 0.x default + Assert.AreEqual(0.95f,MToon10Migrator.MigrateToShadingToony(0.9f, 0f), delta); + Assert.AreEqual(-0.05f,MToon10Migrator.MigrateToShadingShift(0.9f, 0f), delta); + + // lambert + Assert.AreEqual(0.5f, MToon10Migrator.MigrateToShadingToony(0, 0), delta); + Assert.AreEqual(-0.5f, MToon10Migrator.MigrateToShadingShift(0, 0), delta); + + // half lambert + Assert.AreEqual(0.0f, MToon10Migrator.MigrateToShadingToony(0, -1), delta); + Assert.AreEqual(0.0f, MToon10Migrator.MigrateToShadingShift(0, -1), delta); + + // random + Assert.AreEqual(0.79f, MToon10Migrator.MigrateToShadingToony(0.7f, -0.4f), delta); + Assert.AreEqual(0.19f, MToon10Migrator.MigrateToShadingShift(0.7f, -0.4f), delta); + } + + [Test] + public void MigrateGiIntensity() + { + var delta = 0.001f; + + // normal + Assert.AreEqual(0f, MToon10Migrator.MigrateToGiEqualization(1f)); + + // equalized + Assert.AreEqual(1f, MToon10Migrator.MigrateToGiEqualization(0f)); + + // intermediate + Assert.AreEqual(0.25f, MToon10Migrator.MigrateToGiEqualization(0.75f)); + Assert.AreEqual(0.333f, MToon10Migrator.MigrateToGiEqualization(0.667f)); + Assert.AreEqual(0.125f, MToon10Migrator.MigrateToGiEqualization(0.875f)); + Assert.AreEqual(0.75f, MToon10Migrator.MigrateToGiEqualization(0.25f)); + } + } +} \ No newline at end of file diff --git a/Assets/VRMShaders/VRM10/MToon10/Tests/MigrationTests.cs.meta b/Assets/VRMShaders/VRM10/MToon10/Tests/MigrationTests.cs.meta new file mode 100644 index 000000000..ce9e95fba --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Tests/MigrationTests.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6530bdc57fd7d354db37f84b93222964 +timeCreated: 1626335293 \ No newline at end of file diff --git a/Assets/VRMShaders/VRM10/MToon10/Tests/VRMShaders.VRM10.MToon10.Tests.asmdef b/Assets/VRMShaders/VRM10/MToon10/Tests/VRMShaders.VRM10.MToon10.Tests.asmdef new file mode 100644 index 000000000..369b3e938 --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Tests/VRMShaders.VRM10.MToon10.Tests.asmdef @@ -0,0 +1,18 @@ +{ + "name": "VRMShaders.VRM10.MToon10.Tests", + "references": [ + "VRMShaders.VRM10.MToon10.Runtime" + ], + "optionalUnityReferences": [ + "TestAssemblies" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": false, + "defineConstraints": [] +} \ No newline at end of file diff --git a/Assets/VRMShaders/VRM10/MToon10/Tests/VRMShaders.VRM10.MToon10.Tests.asmdef.meta b/Assets/VRMShaders/VRM10/MToon10/Tests/VRMShaders.VRM10.MToon10.Tests.asmdef.meta new file mode 100644 index 000000000..69489d908 --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Tests/VRMShaders.VRM10.MToon10.Tests.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a8e4a462662564e48931da8e2a390e60 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: