diff --git a/Assets/VRM10_Samples/VRM10Viewer/Assets/TinyMToon.shadergraph b/Assets/VRM10_Samples/VRM10Viewer/Assets/TinyMToon.shadergraph new file mode 100644 index 000000000..29a8bad40 --- /dev/null +++ b/Assets/VRM10_Samples/VRM10Viewer/Assets/TinyMToon.shadergraph @@ -0,0 +1,975 @@ +{ + "m_SGVersion": 3, + "m_Type": "UnityEditor.ShaderGraph.GraphData", + "m_ObjectId": "5e8062d7742046c5a0cbef2f61ceca95", + "m_Properties": [ + { + "m_Id": "4e79611254fb4f7ebaa9dc55ea52a427" + } + ], + "m_Keywords": [], + "m_Dropdowns": [], + "m_CategoryData": [ + { + "m_Id": "867e133e4da04154ac66a450c056f228" + } + ], + "m_Nodes": [ + { + "m_Id": "8e6b987b3d2e4b438d4618bd99e12be6" + }, + { + "m_Id": "7e3c0b97666e47ffa0460010d1a64071" + }, + { + "m_Id": "4ad89151ecf0451d9f92f4db3f59ca3d" + }, + { + "m_Id": "e27b69744886424eb5f477011f04efd2" + }, + { + "m_Id": "978fb2b4d6a64b13baf4df534019c0ef" + }, + { + "m_Id": "12d6f083f5bf4fe396e430f312c91445" + }, + { + "m_Id": "945c5856342a4d05a37a15c8fd76dd91" + }, + { + "m_Id": "ef80aee428f942ea9ba07ca5ff70d8b7" + }, + { + "m_Id": "c043e21ac8d54fe3af1f367b6682ea76" + }, + { + "m_Id": "6f5745e22b43420db4198550f74935a6" + }, + { + "m_Id": "001956a26193431db776814a0429e033" + } + ], + "m_GroupDatas": [], + "m_StickyNoteDatas": [], + "m_Edges": [ + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "001956a26193431db776814a0429e033" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "6f5745e22b43420db4198550f74935a6" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "6f5745e22b43420db4198550f74935a6" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "e27b69744886424eb5f477011f04efd2" + }, + "m_SlotId": 0 + } + } + ], + "m_VertexContext": { + "m_Position": { + "x": 0.0, + "y": 0.0 + }, + "m_Blocks": [ + { + "m_Id": "8e6b987b3d2e4b438d4618bd99e12be6" + }, + { + "m_Id": "7e3c0b97666e47ffa0460010d1a64071" + }, + { + "m_Id": "4ad89151ecf0451d9f92f4db3f59ca3d" + } + ] + }, + "m_FragmentContext": { + "m_Position": { + "x": 0.0, + "y": 200.0 + }, + "m_Blocks": [ + { + "m_Id": "e27b69744886424eb5f477011f04efd2" + }, + { + "m_Id": "978fb2b4d6a64b13baf4df534019c0ef" + }, + { + "m_Id": "12d6f083f5bf4fe396e430f312c91445" + }, + { + "m_Id": "945c5856342a4d05a37a15c8fd76dd91" + }, + { + "m_Id": "ef80aee428f942ea9ba07ca5ff70d8b7" + }, + { + "m_Id": "c043e21ac8d54fe3af1f367b6682ea76" + } + ] + }, + "m_PreviewData": { + "serializedMesh": { + "m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}", + "m_Guid": "" + }, + "preventRotation": false + }, + "m_Path": "Shader Graphs", + "m_GraphPrecision": 1, + "m_PreviewMode": 2, + "m_OutputNode": { + "m_Id": "" + }, + "m_SubDatas": [], + "m_ActiveTargets": [ + { + "m_Id": "cd04b2ec603c4ce98f51d924e2a512c2" + } + ] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.PropertyNode", + "m_ObjectId": "001956a26193431db776814a0429e033", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Property", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -434.6666564941406, + "y": 140.0, + "width": 140.0, + "height": 35.99998474121094 + } + }, + "m_Slots": [ + { + "m_Id": "896378e2743d4645bbfd8533cf1826e5" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_DismissedVersion": 0, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Property": { + "m_Id": "4e79611254fb4f7ebaa9dc55ea52a427" + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot", + "m_ObjectId": "019aac67658b4391a0fbbde2235300db", + "m_Id": 0, + "m_DisplayName": "Emission", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Emission", + "m_StageCapability": 2, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_ColorMode": 1, + "m_DefaultColor": { + "r": 0.0, + "g": 0.0, + "b": 0.0, + "a": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.NormalMaterialSlot", + "m_ObjectId": "01c54a54e6cb42a290e72e354571cec5", + "m_Id": 0, + "m_DisplayName": "Normal", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Normal", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "119a395b33c7443980ebe76a78156c14", + "m_Id": 4, + "m_DisplayName": "R", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "R", + "m_StageCapability": 2, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "12d6f083f5bf4fe396e430f312c91445", + "m_Group": { + "m_Id": "" + }, + "m_Name": "SurfaceDescription.Metallic", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "bed0fcfe71ee4b1e85fb3d9d7ee1e4c1" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_DismissedVersion": 0, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "SurfaceDescription.Metallic" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot", + "m_ObjectId": "3b076e005942425f99ce3907ec24fe79", + "m_Id": 0, + "m_DisplayName": "Base Color", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "BaseColor", + "m_StageCapability": 2, + "m_Value": { + "x": 0.5, + "y": 0.5, + "z": 0.5 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_ColorMode": 0, + "m_DefaultColor": { + "r": 0.5, + "g": 0.5, + "b": 0.5, + "a": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "4ad89151ecf0451d9f92f4db3f59ca3d", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Tangent", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "b977eab87a834a02956948283a300909" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_DismissedVersion": 0, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Tangent" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Internal.Texture2DShaderProperty", + "m_ObjectId": "4e79611254fb4f7ebaa9dc55ea52a427", + "m_Guid": { + "m_GuidSerialized": "8ba0f7ac-16b0-4874-83a9-5f7ed0c10efa" + }, + "m_Name": "BaseMap", + "m_DefaultRefNameVersion": 1, + "m_RefNameGeneratedByDisplayName": "BaseMap", + "m_DefaultReferenceName": "_BaseMap", + "m_OverrideReferenceName": "", + "m_GeneratePropertyBlock": true, + "m_UseCustomSlotLabel": false, + "m_CustomSlotLabel": "", + "m_DismissedVersion": 0, + "m_Precision": 0, + "overrideHLSLDeclaration": false, + "hlslDeclarationOverride": 0, + "m_Hidden": false, + "m_Value": { + "m_SerializedTexture": "", + "m_Guid": "" + }, + "isMainTexture": true, + "useTilingAndOffset": true, + "m_Modifiable": true, + "m_DefaultType": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "5e4571167e004d41962bea79b2d6ec12", + "m_Id": 7, + "m_DisplayName": "A", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 2, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.NormalMaterialSlot", + "m_ObjectId": "6ea9aa166ed74644b3a8a23458367734", + "m_Id": 0, + "m_DisplayName": "Normal (Tangent Space)", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "NormalTS", + "m_StageCapability": 2, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 3 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.SampleTexture2DNode", + "m_ObjectId": "6f5745e22b43420db4198550f74935a6", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Sample Texture 2D", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -319.1457214355469, + "y": 221.52105712890626, + "width": 209.3333282470703, + "height": 438.66668701171877 + } + }, + "m_Slots": [ + { + "m_Id": "976fc3a4005841bc9f2506ad8a880ad2" + }, + { + "m_Id": "119a395b33c7443980ebe76a78156c14" + }, + { + "m_Id": "9b9bcc2fdef244b09b85c0d444a1464e" + }, + { + "m_Id": "702ae318a63f41199008fba14c3e0d46" + }, + { + "m_Id": "5e4571167e004d41962bea79b2d6ec12" + }, + { + "m_Id": "d6894d8dff434dd59a557d72bf9f60fb" + }, + { + "m_Id": "e7932487a75244b7b646db0d63a82e8e" + }, + { + "m_Id": "f92de9080fa848f6831d9ff9301e7ca9" + } + ], + "synonyms": [ + "tex2d" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_DismissedVersion": 0, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_TextureType": 0, + "m_NormalMapSpace": 0, + "m_EnableGlobalMipBias": true, + "m_MipSamplingMode": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "702ae318a63f41199008fba14c3e0d46", + "m_Id": 6, + "m_DisplayName": "B", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "B", + "m_StageCapability": 2, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "7e3c0b97666e47ffa0460010d1a64071", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Normal", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "01c54a54e6cb42a290e72e354571cec5" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_DismissedVersion": 0, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Normal" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.CategoryData", + "m_ObjectId": "867e133e4da04154ac66a450c056f228", + "m_Name": "", + "m_ChildObjectList": [ + { + "m_Id": "4e79611254fb4f7ebaa9dc55ea52a427" + } + ] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Texture2DMaterialSlot", + "m_ObjectId": "896378e2743d4645bbfd8533cf1826e5", + "m_Id": 0, + "m_DisplayName": "BaseMap", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_BareResource": false +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "8e6b987b3d2e4b438d4618bd99e12be6", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Position", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "f3a2f016faaf422f9c936817f13cb82d" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_DismissedVersion": 0, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Position" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "945c5856342a4d05a37a15c8fd76dd91", + "m_Group": { + "m_Id": "" + }, + "m_Name": "SurfaceDescription.Smoothness", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "da4800c1d386405fb154caff690abd85" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_DismissedVersion": 0, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "SurfaceDescription.Smoothness" +} + +{ + "m_SGVersion": 2, + "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalLitSubTarget", + "m_ObjectId": "97355bb871ae412c90915a1c95a39813", + "m_WorkflowMode": 1, + "m_NormalDropOffSpace": 0, + "m_ClearCoat": false, + "m_BlendModePreserveSpecular": true +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot", + "m_ObjectId": "976fc3a4005841bc9f2506ad8a880ad2", + "m_Id": 0, + "m_DisplayName": "RGBA", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "RGBA", + "m_StageCapability": 2, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "978fb2b4d6a64b13baf4df534019c0ef", + "m_Group": { + "m_Id": "" + }, + "m_Name": "SurfaceDescription.NormalTS", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "6ea9aa166ed74644b3a8a23458367734" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_DismissedVersion": 0, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "SurfaceDescription.NormalTS" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "9b9bcc2fdef244b09b85c0d444a1464e", + "m_Id": 5, + "m_DisplayName": "G", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "G", + "m_StageCapability": 2, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.TangentMaterialSlot", + "m_ObjectId": "b977eab87a834a02956948283a300909", + "m_Id": 0, + "m_DisplayName": "Tangent", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Tangent", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "bed0fcfe71ee4b1e85fb3d9d7ee1e4c1", + "m_Id": 0, + "m_DisplayName": "Metallic", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Metallic", + "m_StageCapability": 2, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "c043e21ac8d54fe3af1f367b6682ea76", + "m_Group": { + "m_Id": "" + }, + "m_Name": "SurfaceDescription.Occlusion", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "e0d5d67a35d246f4be028fa5a4c778bf" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_DismissedVersion": 0, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "SurfaceDescription.Occlusion" +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget", + "m_ObjectId": "cd04b2ec603c4ce98f51d924e2a512c2", + "m_Datas": [], + "m_ActiveSubTarget": { + "m_Id": "97355bb871ae412c90915a1c95a39813" + }, + "m_AllowMaterialOverride": false, + "m_SurfaceType": 0, + "m_ZTestMode": 4, + "m_ZWriteControl": 0, + "m_AlphaMode": 0, + "m_RenderFace": 2, + "m_AlphaClip": false, + "m_CastShadows": true, + "m_ReceiveShadows": true, + "m_SupportsLODCrossFade": false, + "m_CustomEditorGUI": "", + "m_SupportVFX": false +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Texture2DInputMaterialSlot", + "m_ObjectId": "d6894d8dff434dd59a557d72bf9f60fb", + "m_Id": 1, + "m_DisplayName": "Texture", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Texture", + "m_StageCapability": 3, + "m_BareResource": false, + "m_Texture": { + "m_SerializedTexture": "", + "m_Guid": "" + }, + "m_DefaultType": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "da4800c1d386405fb154caff690abd85", + "m_Id": 0, + "m_DisplayName": "Smoothness", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Smoothness", + "m_StageCapability": 2, + "m_Value": 0.5, + "m_DefaultValue": 0.5, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "e0d5d67a35d246f4be028fa5a4c778bf", + "m_Id": 0, + "m_DisplayName": "Ambient Occlusion", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Occlusion", + "m_StageCapability": 2, + "m_Value": 1.0, + "m_DefaultValue": 1.0, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "e27b69744886424eb5f477011f04efd2", + "m_Group": { + "m_Id": "" + }, + "m_Name": "SurfaceDescription.BaseColor", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "3b076e005942425f99ce3907ec24fe79" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_DismissedVersion": 0, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "SurfaceDescription.BaseColor" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.UVMaterialSlot", + "m_ObjectId": "e7932487a75244b7b646db0d63a82e8e", + "m_Id": 2, + "m_DisplayName": "UV", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "UV", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0 + }, + "m_Labels": [], + "m_Channel": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "ef80aee428f942ea9ba07ca5ff70d8b7", + "m_Group": { + "m_Id": "" + }, + "m_Name": "SurfaceDescription.Emission", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "019aac67658b4391a0fbbde2235300db" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_DismissedVersion": 0, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "SurfaceDescription.Emission" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.PositionMaterialSlot", + "m_ObjectId": "f3a2f016faaf422f9c936817f13cb82d", + "m_Id": 0, + "m_DisplayName": "Position", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Position", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.SamplerStateMaterialSlot", + "m_ObjectId": "f92de9080fa848f6831d9ff9301e7ca9", + "m_Id": 3, + "m_DisplayName": "Sampler", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Sampler", + "m_StageCapability": 3, + "m_BareResource": false +} + diff --git a/Assets/VRM10_Samples/VRM10Viewer/Assets/TinyMToon.shadergraph.meta b/Assets/VRM10_Samples/VRM10Viewer/Assets/TinyMToon.shadergraph.meta new file mode 100644 index 000000000..04c5857b3 --- /dev/null +++ b/Assets/VRM10_Samples/VRM10Viewer/Assets/TinyMToon.shadergraph.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: fd08e80eb7e04e849b8a6d534e48efea +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3} diff --git a/Assets/VRM10_Samples/VRM10Viewer/IMaterialImporter.cs b/Assets/VRM10_Samples/VRM10Viewer/IMaterialImporter.cs new file mode 100644 index 000000000..7906b2a3c --- /dev/null +++ b/Assets/VRM10_Samples/VRM10Viewer/IMaterialImporter.cs @@ -0,0 +1,9 @@ +using UniGLTF; + +namespace UniVRM10.VRM10Viewer +{ + public interface IMaterialImporter + { + bool TryCreateParam(GltfData data, int i, out MaterialDescriptor matDesc); + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/VRM10Viewer/IMaterialImporter.cs.meta b/Assets/VRM10_Samples/VRM10Viewer/IMaterialImporter.cs.meta new file mode 100644 index 000000000..72183176b --- /dev/null +++ b/Assets/VRM10_Samples/VRM10Viewer/IMaterialImporter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a73adafc0b11d6e459306666f5b0ceb8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10_Samples/VRM10Viewer/OrderedMaterialDescriptorGenerator.cs b/Assets/VRM10_Samples/VRM10Viewer/OrderedMaterialDescriptorGenerator.cs new file mode 100644 index 000000000..e8d644d30 --- /dev/null +++ b/Assets/VRM10_Samples/VRM10Viewer/OrderedMaterialDescriptorGenerator.cs @@ -0,0 +1,41 @@ +using UniGLTF; + +namespace UniVRM10.VRM10Viewer +{ + public sealed class OrderedMaterialDescriptorGenerator : IMaterialDescriptorGenerator + { + private IMaterialImporter[] _importers; + + public UrpGltfDefaultMaterialImporter DefaultMaterialImporter { get; } = new(); + + /// + /// 順に TryCreateParam を実行して最初に成功したら終わる。 + /// 全て失敗したら UrpGltfDefaultMaterialImporter を実行する。 + /// 通常 vrm-1.0, unlit, pbr の順に試行する。 + /// + /// + public OrderedMaterialDescriptorGenerator(params IMaterialImporter[] importers) + { + _importers = importers; + } + + public MaterialDescriptor Get(GltfData data, int i) + { + foreach (var importer in _importers) + { + if (importer.TryCreateParam(data, i, out var param)) + { + return param; + } + } + // NOTE: Fallback to default material + if (Symbols.VRM_DEVELOP) + { + UniGLTFLogger.Warning($"material: {i} out of range. fallback"); + } + return GetGltfDefault(GltfMaterialImportUtils.ImportMaterialName(i, null)); + } + + public MaterialDescriptor GetGltfDefault(string materialName = null) => DefaultMaterialImporter.CreateParam(materialName); + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialDescriptorGenerator.cs.meta b/Assets/VRM10_Samples/VRM10Viewer/OrderedMaterialDescriptorGenerator.cs.meta similarity index 100% rename from Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialDescriptorGenerator.cs.meta rename to Assets/VRM10_Samples/VRM10Viewer/OrderedMaterialDescriptorGenerator.cs.meta diff --git a/Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialContext.cs b/Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialContext.cs new file mode 100644 index 000000000..4df95163d --- /dev/null +++ b/Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialContext.cs @@ -0,0 +1,154 @@ +using UnityEngine; + +namespace UniVRM10.VRM10Viewer +{ + public class TinyMToonMaterialContext + { + // + // When using shadergraph, you need to expose the following properties. + // + + /// + /// Color = White + /// + private static readonly int BaseColorProp = Shader.PropertyToID("_BaseColor"); + /// + /// Texture2D = white + /// When using shadergraph, require "Set as Main Texture" + /// + private static readonly int BaseMapProp = Shader.PropertyToID("_BaseMap"); + /// + /// float = 1.0 + /// + private static readonly int OcclusionStrengthProp = Shader.PropertyToID("_OcclusionStrength"); + /// + /// Texture2D.Red = 1.0. + /// + private static readonly int OcclusionMapProp = Shader.PropertyToID("_OcclusionMap"); + private static readonly int RoughnessProp = Shader.PropertyToID("_Roughness"); + private static readonly int MetallicProp = Shader.PropertyToID("_Metallic"); + /// + /// Texture2D.Green = 1.0. The roughness + /// Texture2D.Blue = 1.0. The metalness + /// + private static readonly int MetallicRoughnessMapProp = Shader.PropertyToID("_MetallicRoughnessMap"); + /// + /// float = 1.0 + /// + private static readonly int BumpScaleProp = Shader.PropertyToID("_BumpScale"); + /// + /// Texture2D = [0, 0, 1.0] + /// + private static readonly int BumpMapProp = Shader.PropertyToID("_BumpMap"); + /// + /// Color = black + /// + private static readonly int EmissionColorProp = Shader.PropertyToID("_EmissionColor"); + /// + /// Texture2D = black + /// + private static readonly int EmissionMapProp = Shader.PropertyToID("_EmissionMap"); + /// + /// boolean keyword + /// + private static readonly int CutoffEnabledProp = Shader.PropertyToID("_CutoffEnabled"); + /// + /// float = 0.5 + /// + private static readonly int CutoffProp = Shader.PropertyToID("_Cutoff"); + + public readonly Material Material; + public TinyMToonMaterialContext(Material material) + { + Material = material; + } + + public Color BaseColorSrgb + { + get => Material.GetColor(BaseColorProp); + set => Material.SetColor(BaseColorProp, value); + } + public Texture BaseTexture + { + get => Material.GetTexture(BaseMapProp); + set => Material.SetTexture(BaseMapProp, value); + } + public Vector2 BaseTextureOffset + { + get => Material.GetTextureOffset(BaseMapProp); + set => Material.SetTextureOffset(BaseMapProp, value); + } + public Vector2 BaseTextureScale + { + get => Material.GetTextureScale(BaseMapProp); + set => Material.SetTextureScale(BaseMapProp, value); + } + + public float OcclusionStrength + { + get => Material.GetFloat(OcclusionStrengthProp); + set => Material.SetFloat(OcclusionStrengthProp, value); + } + public Texture OcclusionTexture + { + get => Material.GetTexture(OcclusionMapProp); + set + { + Material.SetTexture(OcclusionMapProp, value); + } + } + + public float Roughness + { + get => Material.GetFloat(RoughnessProp); + set => Material.SetFloat(RoughnessProp, value); + } + public float Metallic + { + get => Material.GetFloat(MetallicProp); + set => Material.SetFloat(MetallicProp, value); + } + public Texture MetallicRoughnessMap + { + get => Material.GetTexture(MetallicRoughnessMapProp); + set => Material.SetTexture(MetallicRoughnessMapProp, value); + } + + public float BumpScale + { + get => Material.GetFloat(BumpScaleProp); + set => Material.SetFloat(BumpScaleProp, value); + } + public Texture BumpMap + { + get => Material.GetTexture(BumpMapProp); + set + { + Material.SetTexture(BumpMapProp, value); + } + } + + public Color EmissionColorLinear + { + get => Material.GetColor(EmissionColorProp); + set => Material.SetColor(EmissionColorProp, value); + } + public Texture EmissionTexture + { + get => Material.GetTexture(EmissionMapProp); + set => Material.SetTexture(EmissionMapProp, value); + } + + public bool CutoffEnabled + { + get => Material.GetInt(CutoffEnabledProp) != 0; + set => Material.SetInt(CutoffEnabledProp, value ? 1 : 0); + } + + public float Cutoff + { + get => Material.GetFloat(CutoffProp); + set => Material.SetFloat(CutoffProp, value); + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialContext.cs.meta b/Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialContext.cs.meta new file mode 100644 index 000000000..1f1447c44 --- /dev/null +++ b/Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialContext.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 74278bbebb772d043ad87b46a42e9cc3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialImporter.cs b/Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialImporter.cs new file mode 100644 index 000000000..9da754da7 --- /dev/null +++ b/Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialImporter.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using UniGLTF; +using UnityEngine; + +namespace UniVRM10.VRM10Viewer +{ + public class TinyMToonrMaterialImporter : IMaterialImporter + { + private Material m_opaque; + public TinyMToonrMaterialImporter(Material material) + { + m_opaque = material; + } + + bool IMaterialImporter.TryCreateParam(GltfData data, int i, out MaterialDescriptor matDesc) + { + if (i < 0 || i >= data.GLTF.materials.Count) + { + matDesc = default; + return false; + } + + var src = data.GLTF.materials[i]; + if (!UniGLTF.Extensions.VRMC_materials_mtoon.GltfDeserializer.TryGet(src.extensions, out var mtoon)) + { + // Fallback to glTF, when MToon extension does not exist. + matDesc = default; + return false; + } + + matDesc = new MaterialDescriptor( + GltfMaterialImportUtils.ImportMaterialName(i, src), + m_opaque.shader, + null, + new Dictionary(), + new Dictionary(), + new Dictionary(), + new Dictionary(), + new List>(), + new[] { (MaterialDescriptor.MaterialGenerateAsyncFunc)AsyncAction } + ); + return true; + + Task AsyncAction(Material x, GetTextureAsyncFunc y, IAwaitCaller z) => GenerateMaterialAsync(data, src, x, y, z); + } + + public static async Task GenerateMaterialAsync(GltfData data, glTFMaterial src, Material dst, GetTextureAsyncFunc getTextureAsync, IAwaitCaller awaitCaller) + { + var context = new TinyMToonMaterialContext(dst); + + // ImportSurfaceSettings(src, context); + await ImportBaseColorAsync(data, src, context, getTextureAsync, awaitCaller); + // await ImportMetallicRoughnessAsync(data, src, context, getTextureAsync, awaitCaller); + // await ImportOcclusionAsync(data, src, context, getTextureAsync, awaitCaller); + // await ImportNormalAsync(data, src, context, getTextureAsync, awaitCaller); + // await ImportEmissionAsync(data, src, context, getTextureAsync, awaitCaller); + + // context.Validate(); + } + + public static async Task ImportBaseColorAsync(GltfData data, glTFMaterial src, TinyMToonMaterialContext context, GetTextureAsyncFunc getTextureAsync, IAwaitCaller awaitCaller) + { + var baseColorFactor = GltfMaterialImportUtils.ImportLinearBaseColorFactor(data, src); + if (baseColorFactor.HasValue) + { + context.BaseColorSrgb = baseColorFactor.Value.gamma; + } + + if (src is { pbrMetallicRoughness: { baseColorTexture: { index: >= 0 } } }) + { + if (GltfPbrTextureImporter.TryBaseColorTexture(data, src, out _, out var desc)) + { + context.BaseTexture = await getTextureAsync(desc, awaitCaller); + context.BaseTextureOffset = desc.Offset; + context.BaseTextureScale = desc.Scale; + } + } + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialImporter.cs.meta b/Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialImporter.cs.meta new file mode 100644 index 000000000..45cb388c7 --- /dev/null +++ b/Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialImporter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 65362ac3cba13c14299e8a8ce356927d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialDescriptorGenerator.cs b/Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialImporter.cs similarity index 79% rename from Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialDescriptorGenerator.cs rename to Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialImporter.cs index 960cf7b8f..35f137a28 100644 --- a/Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialDescriptorGenerator.cs +++ b/Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialImporter.cs @@ -6,49 +6,21 @@ using UnityEngine; namespace UniVRM10.VRM10Viewer { - /// - /// TinyPbr 向け - /// - public sealed class TinyPbrMaterialDescriptorGenerator : IMaterialDescriptorGenerator + public class TinyPbrMaterialImporter : IMaterialImporter { - public UrpGltfPbrMaterialImporter PbrMaterialImporter { get; } = new(); - public UrpGltfDefaultMaterialImporter DefaultMaterialImporter { get; } = new(); + // public const string ALPHABLEND_SHADER_NAME = "Shader Graphs/TinyPbrAlphaBlend"; + // public const string OPAQUE_SHADER_NAME = "Shader Graphs/TinyPbrOpaque"; - public Material OpaqueMaterial { get; set; } - public Material AlphaBlendMaterial { get; set; } + Material m_opaque; + Material m_alphablend; - /// TinyPbr material - public TinyPbrMaterialDescriptorGenerator( - Material opaque, - Material alphaBlend - ) + public TinyPbrMaterialImporter(Material opaque, Material alphablend) { - if (opaque == null) - { - throw new ArgumentNullException("opaque"); - } - OpaqueMaterial = opaque; - AlphaBlendMaterial = alphaBlend ?? opaque; + m_opaque = opaque; + m_alphablend = alphablend; } - public MaterialDescriptor Get(GltfData data, int i) - { - // UNLIT - if (BuiltInGltfUnlitMaterialImporter.TryCreateParam(data, i, out var param)) return param; - - if (TryCreateParam(data, i, out param)) return param; - - // NOTE: Fallback to default material - if (Symbols.VRM_DEVELOP) - { - UniGLTFLogger.Warning($"material: {i} out of range. fallback"); - } - return GetGltfDefault(GltfMaterialImportUtils.ImportMaterialName(i, null)); - } - - public MaterialDescriptor GetGltfDefault(string materialName = null) => DefaultMaterialImporter.CreateParam(materialName); - - public bool TryCreateParam(GltfData data, int i, out MaterialDescriptor matDesc) + bool IMaterialImporter.TryCreateParam(GltfData data, int i, out MaterialDescriptor matDesc) { if (i < 0 || i >= data.GLTF.materials.Count) { @@ -59,7 +31,7 @@ namespace UniVRM10.VRM10Viewer var src = data.GLTF.materials[i]; matDesc = new MaterialDescriptor( GltfMaterialImportUtils.ImportMaterialName(i, src), - src.alphaMode == "BLEND" ? AlphaBlendMaterial.shader : OpaqueMaterial.shader, + src.alphaMode == "BLEND" ? m_alphablend.shader : m_opaque.shader, null, new Dictionary(), new Dictionary(), diff --git a/Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialImporter.cs.meta b/Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialImporter.cs.meta new file mode 100644 index 000000000..c29e35b99 --- /dev/null +++ b/Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialImporter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0f9b3156e6cb9e84b924ab9e062df7fe +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity b/Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity index a18ab6f3c..05cf34b7c 100644 --- a/Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity +++ b/Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity @@ -30642,7 +30642,7 @@ MonoBehaviour: type: 3} m_alphaBlendMaterial: {fileID: -876546973899608171, guid: 868190a58757d6242bb3ca456402f82f, type: 3} - m_cutoffMaterial: {fileID: -876546973899608171, guid: 9a01f29343f749440b30e3ff1c26b013, + m_mtoonMaterial: {fileID: -876546973899608171, guid: 181d2f25392c4884c88480261b6d6b57, type: 3} m_useCustomMaterial: {fileID: 731212246} m_openModel: {fileID: 2009818433} diff --git a/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs b/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs index f07222901..84fe2a800 100644 --- a/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs +++ b/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs @@ -27,6 +27,8 @@ namespace UniVRM10.VRM10Viewer Material m_opaqueMaterial = default; [SerializeField] Material m_alphaBlendMaterial = default; + [SerializeField] + Material m_mtoonMaterial = default; [Header("UI")] [SerializeField] @@ -481,8 +483,23 @@ namespace UniVRM10.VRM10Viewer VRM10Blinker m_autoBlink; VRM10AIUEO m_autoLipsync; + private class UnlitMaterialImporter : IMaterialImporter + { + bool IMaterialImporter.TryCreateParam(GltfData data, int i, out MaterialDescriptor matDesc) + { + return BuiltInGltfUnlitMaterialImporter.TryCreateParam(data, i, out matDesc); + } + } + private UnlitMaterialImporter m_unlitImporter = new(); + + private TinyMToonrMaterialImporter m_mtoonImporter; + private TinyPbrMaterialImporter m_pbrImporter; + private void Start() { + m_mtoonImporter = new(m_mtoonMaterial); + m_pbrImporter = new(m_opaqueMaterial, m_alphaBlendMaterial); + m_autoEmotion = gameObject.AddComponent(); m_autoBlink = gameObject.AddComponent(); m_autoLipsync = gameObject.AddComponent(); @@ -775,10 +792,7 @@ namespace UniVRM10.VRM10Viewer { if (m_useCustomMaterial.isOn) { - return new TinyPbrMaterialDescriptorGenerator( - m_opaqueMaterial, - m_alphaBlendMaterial - ); + return new OrderedMaterialDescriptorGenerator(m_mtoonImporter, m_unlitImporter, m_pbrImporter); } else {