Merge pull request #2577 from ousttrue/fix/vrm10viewer_custom_material

[URP][vrm10viewer] ShaderGraph material sample
This commit is contained in:
ousttrue 2025-02-07 16:36:44 +09:00 committed by GitHub
commit be9dde69f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
42 changed files with 16583 additions and 1231 deletions

View File

@ -45,7 +45,7 @@ MonoBehaviour:
value: 65472
diffusion:
overrideState: 1
value: 7
value: 6.4
anamorphicRatio:
overrideState: 0
value: 0

View File

@ -118,7 +118,7 @@ namespace UniVRM10
}
}
private static bool TryGetShadeMultiplyTexture(GltfData data, VRMC_materials_mtoon mToon, out SubAssetKey key, out TextureDescriptor desc)
public static bool TryGetShadeMultiplyTexture(GltfData data, VRMC_materials_mtoon mToon, out SubAssetKey key, out TextureDescriptor desc)
{
return TryGetSRGBTexture(data, new Vrm10TextureInfo(mToon.ShadeMultiplyTexture), out key, out desc);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 6b60fe85d745eda4281e3278fcb0657c
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: fd08e80eb7e04e849b8a6d534e48efea
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 45c6d2335bae988419dbc2ec65c33dae
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}

View File

@ -1,975 +0,0 @@
{
"m_SGVersion": 3,
"m_Type": "UnityEditor.ShaderGraph.GraphData",
"m_ObjectId": "77181a4b19324ebdb175da71cf4f6186",
"m_Properties": [
{
"m_Id": "92f5ab11614c4ec1b4d632f73041ba65"
}
],
"m_Keywords": [],
"m_Dropdowns": [],
"m_CategoryData": [
{
"m_Id": "0778abfa54c94f9abfd0482e1de4d602"
}
],
"m_Nodes": [
{
"m_Id": "f56f676a56e04566a12f41980b760358"
},
{
"m_Id": "307a94d3f1ca45a39f6170433e3c81c6"
},
{
"m_Id": "7b57df1b4e444208bd41b7b749f485d0"
},
{
"m_Id": "80fce1dbcef04945aa9b988609dbe324"
},
{
"m_Id": "6f683c2eb23a4baf8dc028500640b75a"
},
{
"m_Id": "6098dc7f36d84b83b8421cc0e56ed1a0"
},
{
"m_Id": "53f1bc01113946bc946f0808f16df02b"
},
{
"m_Id": "0f64718141f34878916463ec72c9d2d8"
},
{
"m_Id": "58ee8fea72cc4a649f9a1198b12d621b"
},
{
"m_Id": "6637a91f035a40e798e76f70bed17d7e"
},
{
"m_Id": "305a571d629e4b258d80c3ad877cb596"
}
],
"m_GroupDatas": [],
"m_StickyNoteDatas": [],
"m_Edges": [
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "305a571d629e4b258d80c3ad877cb596"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "6637a91f035a40e798e76f70bed17d7e"
},
"m_SlotId": 1
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "6637a91f035a40e798e76f70bed17d7e"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "80fce1dbcef04945aa9b988609dbe324"
},
"m_SlotId": 0
}
}
],
"m_VertexContext": {
"m_Position": {
"x": 0.0,
"y": 0.0
},
"m_Blocks": [
{
"m_Id": "f56f676a56e04566a12f41980b760358"
},
{
"m_Id": "307a94d3f1ca45a39f6170433e3c81c6"
},
{
"m_Id": "7b57df1b4e444208bd41b7b749f485d0"
}
]
},
"m_FragmentContext": {
"m_Position": {
"x": 0.0,
"y": 200.0
},
"m_Blocks": [
{
"m_Id": "80fce1dbcef04945aa9b988609dbe324"
},
{
"m_Id": "6f683c2eb23a4baf8dc028500640b75a"
},
{
"m_Id": "6098dc7f36d84b83b8421cc0e56ed1a0"
},
{
"m_Id": "53f1bc01113946bc946f0808f16df02b"
},
{
"m_Id": "0f64718141f34878916463ec72c9d2d8"
},
{
"m_Id": "58ee8fea72cc4a649f9a1198b12d621b"
}
]
},
"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": "15cb78699c8c4194ad103421699dbd17"
}
]
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "02acc5a4d1de49f087b1a9268cf423ed",
"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.CategoryData",
"m_ObjectId": "0778abfa54c94f9abfd0482e1de4d602",
"m_Name": "",
"m_ChildObjectList": [
{
"m_Id": "92f5ab11614c4ec1b4d632f73041ba65"
}
]
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.BlockNode",
"m_ObjectId": "0f64718141f34878916463ec72c9d2d8",
"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": "a8a3476bbfe8465fbf208d8592d231a3"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_SerializedDescriptor": "SurfaceDescription.Emission"
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget",
"m_ObjectId": "15cb78699c8c4194ad103421699dbd17",
"m_Datas": [],
"m_ActiveSubTarget": {
"m_Id": "352f1953e12a45019330c49643812248"
},
"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.Vector1MaterialSlot",
"m_ObjectId": "1773542df3cf4760b4bc7081934f54ca",
"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": "1b504994184f46fb86fd313496af2752",
"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.TangentMaterialSlot",
"m_ObjectId": "1c1aa306b109406fae4e7ad7412fdb14",
"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.NormalMaterialSlot",
"m_ObjectId": "204b111e465b44809369f1d3e5a90370",
"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.SamplerStateMaterialSlot",
"m_ObjectId": "2b57ee1b447443b39131b7d7ca5656c4",
"m_Id": 3,
"m_DisplayName": "Sampler",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "Sampler",
"m_StageCapability": 3,
"m_BareResource": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.PropertyNode",
"m_ObjectId": "305a571d629e4b258d80c3ad877cb596",
"m_Group": {
"m_Id": ""
},
"m_Name": "Property",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -482.6666564941406,
"y": 233.3333282470703,
"width": 140.0,
"height": 35.99998474121094
}
},
"m_Slots": [
{
"m_Id": "46fb52b8b307424ab27250d54f2c27f9"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_Property": {
"m_Id": "92f5ab11614c4ec1b4d632f73041ba65"
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.BlockNode",
"m_ObjectId": "307a94d3f1ca45a39f6170433e3c81c6",
"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": "e1de0ca351fd43ff866485e33328e300"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_SerializedDescriptor": "VertexDescription.Normal"
}
{
"m_SGVersion": 2,
"m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalLitSubTarget",
"m_ObjectId": "352f1953e12a45019330c49643812248",
"m_WorkflowMode": 1,
"m_NormalDropOffSpace": 0,
"m_ClearCoat": false,
"m_BlendModePreserveSpecular": true
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
"m_ObjectId": "408c7be450e8421abf78f79621f38a90",
"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.Texture2DMaterialSlot",
"m_ObjectId": "46fb52b8b307424ab27250d54f2c27f9",
"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.UVMaterialSlot",
"m_ObjectId": "4c1d0e69fdc7482b9e9587c61e9aee52",
"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": "53f1bc01113946bc946f0808f16df02b",
"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": "1773542df3cf4760b4bc7081934f54ca"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_SerializedDescriptor": "SurfaceDescription.Smoothness"
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.BlockNode",
"m_ObjectId": "58ee8fea72cc4a649f9a1198b12d621b",
"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": "1b504994184f46fb86fd313496af2752"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_SerializedDescriptor": "SurfaceDescription.Occlusion"
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.BlockNode",
"m_ObjectId": "6098dc7f36d84b83b8421cc0e56ed1a0",
"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": "cd2a46a6fe0746ae965dc193ce0757eb"
}
],
"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.PositionMaterialSlot",
"m_ObjectId": "619a91e5d75d4a629f14de895dbebb39",
"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.SampleTexture2DNode",
"m_ObjectId": "6637a91f035a40e798e76f70bed17d7e",
"m_Group": {
"m_Id": ""
},
"m_Name": "Sample Texture 2D",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -322.0,
"y": 200.0,
"width": 209.3333282470703,
"height": 438.6666259765625
}
},
"m_Slots": [
{
"m_Id": "02acc5a4d1de49f087b1a9268cf423ed"
},
{
"m_Id": "8057542115c941488ee696e0d023e9d8"
},
{
"m_Id": "c47fe1183b3b44d1ad66a998fde085f5"
},
{
"m_Id": "408c7be450e8421abf78f79621f38a90"
},
{
"m_Id": "70bb30a82355421ca010103090de0f4a"
},
{
"m_Id": "7aa32b9c5fc74c8088ac31ed5fc87f50"
},
{
"m_Id": "4c1d0e69fdc7482b9e9587c61e9aee52"
},
{
"m_Id": "2b57ee1b447443b39131b7d7ca5656c4"
}
],
"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.BlockNode",
"m_ObjectId": "6f683c2eb23a4baf8dc028500640b75a",
"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": "204b111e465b44809369f1d3e5a90370"
}
],
"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": "70bb30a82355421ca010103090de0f4a",
"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.ColorRGBMaterialSlot",
"m_ObjectId": "7454a78d02bb4f79b6ff0f81f6b795a0",
"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.Texture2DInputMaterialSlot",
"m_ObjectId": "7aa32b9c5fc74c8088ac31ed5fc87f50",
"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.BlockNode",
"m_ObjectId": "7b57df1b4e444208bd41b7b749f485d0",
"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": "1c1aa306b109406fae4e7ad7412fdb14"
}
],
"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.Vector1MaterialSlot",
"m_ObjectId": "8057542115c941488ee696e0d023e9d8",
"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": "80fce1dbcef04945aa9b988609dbe324",
"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": "7454a78d02bb4f79b6ff0f81f6b795a0"
}
],
"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.Internal.Texture2DShaderProperty",
"m_ObjectId": "92f5ab11614c4ec1b4d632f73041ba65",
"m_Guid": {
"m_GuidSerialized": "df5eef53-f7a6-40ef-8fca-1fd91f86d83f"
},
"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.ColorRGBMaterialSlot",
"m_ObjectId": "a8a3476bbfe8465fbf208d8592d231a3",
"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.Vector1MaterialSlot",
"m_ObjectId": "c47fe1183b3b44d1ad66a998fde085f5",
"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.Vector1MaterialSlot",
"m_ObjectId": "cd2a46a6fe0746ae965dc193ce0757eb",
"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.NormalMaterialSlot",
"m_ObjectId": "e1de0ca351fd43ff866485e33328e300",
"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.BlockNode",
"m_ObjectId": "f56f676a56e04566a12f41980b760358",
"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": "619a91e5d75d4a629f14de895dbebb39"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_SerializedDescriptor": "VertexDescription.Position"
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 868190a58757d6242bb3ca456402f82f
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 2fe3270edce96f4438a6dcc501a8c5cd
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

View File

@ -0,0 +1,127 @@
fileFormatVersion: 2
guid: d8c7685da35f7994799534cbc1acce4a
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

View File

@ -0,0 +1,127 @@
fileFormatVersion: 2
guid: 909670d47b2f55d4a991788acca59d7e
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

View File

@ -0,0 +1,127 @@
fileFormatVersion: 2
guid: 51ce5cf2de6d788449c2fdd4b8488a92
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

View File

@ -0,0 +1,127 @@
fileFormatVersion: 2
guid: 3ab316f1cf207684abb754d9a2731c66
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,6 @@
#?RADIANCE
SOFTWARE=GEGL
FORMAT=32-bit_rle_rgbe
-Y 2 +X 2
€€€<EFBFBD>€€€<EFBFBD>€€€<EFBFBD>€€€<EFBFBD>

View File

@ -0,0 +1,127 @@
fileFormatVersion: 2
guid: 09e6225be3a2a43489e11a41cb198377
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
using UniGLTF;
namespace UniVRM10.VRM10Viewer
{
public interface IMaterialImporter
{
bool TryCreateParam(GltfData data, int i, out MaterialDescriptor matDesc);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a73adafc0b11d6e459306666f5b0ceb8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,41 @@
using UniGLTF;
namespace UniVRM10.VRM10Viewer
{
public sealed class OrderedMaterialDescriptorGenerator : IMaterialDescriptorGenerator
{
private IMaterialImporter[] _importers;
public UrpGltfDefaultMaterialImporter DefaultMaterialImporter { get; } = new();
/// <summary>
/// 順に TryCreateParam を実行して最初に成功したら終わる。
/// 全て失敗したら UrpGltfDefaultMaterialImporter を実行する。
/// 通常 vrm-1.0, unlit, pbr の順に試行する。
/// </summary>
/// <param name="importers"></param>
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);
}
}

View File

@ -0,0 +1,133 @@
using System.Dynamic;
using UnityEngine;
namespace UniVRM10.VRM10Viewer
{
public class TinyMToonMaterialContext
{
//
// When using shadergraph, you need to expose the following properties.
//
/// <summary>
/// Color = White
/// </summary>
private static readonly int BaseColorProp = Shader.PropertyToID("_BaseColor");
/// <summary>
/// Texture2D = white
/// When using shadergraph, require "Set as Main Texture"
/// </summary>
private static readonly int BaseMapProp = Shader.PropertyToID("_BaseMap");
private static readonly int ShadingColorFactorProp = Shader.PropertyToID("_ShadingColor");
private static readonly int ShadingMapProp = Shader.PropertyToID("_ShadingMap");
private static readonly int ShadingToonyFactorProp = Shader.PropertyToID("_ShadingToonyFactor");
/// <summary>
/// float = 1.0
/// </summary>
private static readonly int BumpScaleProp = Shader.PropertyToID("_BumpScale");
/// <summary>
/// Texture2D = [0, 0, 1.0]
/// </summary>
private static readonly int BumpMapProp = Shader.PropertyToID("_BumpMap");
/// <summary>
/// Color = black
/// </summary>
private static readonly int EmissionColorProp = Shader.PropertyToID("_EmissionColor");
/// <summary>
/// Texture2D = black
/// </summary>
private static readonly int EmissionMapProp = Shader.PropertyToID("_EmissionMap");
/// <summary>
/// boolean keyword
/// </summary>
private static readonly int CutoffEnabledProp = Shader.PropertyToID("_CutoffEnabled");
/// <summary>
/// float = 0.5
/// </summary>
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 Color ShadingColorFactorSrgb
{
get => Material.GetColor(ShadingColorFactorProp);
set => Material.SetColor(ShadingColorFactorProp, value);
}
public Texture ShadingTexture
{
get => Material.GetTexture(ShadingMapProp);
set => Material.SetTexture(ShadingMapProp, value);
}
public float ShadingToonyFactor
{
get => Material.GetFloat(ShadingToonyFactorProp);
set => Material.SetFloat(ShadingToonyFactorProp, 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);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 74278bbebb772d043ad87b46a42e9cc3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using UniGLTF;
using UniGLTF.Extensions.VRMC_materials_mtoon;
using UnityEngine;
namespace UniVRM10.VRM10Viewer
{
public class TinyMToonrMaterialImporter : IMaterialImporter
{
private Material m_opaque;
private Material m_alphablend;
public TinyMToonrMaterialImporter(Material opaque, Material alphablend)
{
m_opaque = opaque;
m_alphablend = alphablend;
}
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),
src.alphaMode == "BLEND" ? m_alphablend.shader : m_opaque.shader,
null,
new Dictionary<string, TextureDescriptor>(),
new Dictionary<string, float>(),
new Dictionary<string, Color>(),
new Dictionary<string, Vector4>(),
new List<Action<Material>>(),
new[] { (MaterialDescriptor.MaterialGenerateAsyncFunc)AsyncAction }
);
return true;
Task AsyncAction(Material x, GetTextureAsyncFunc y, IAwaitCaller z) => GenerateMaterialAsync(data, src, mtoon, x, y, z);
}
public static async Task GenerateMaterialAsync(GltfData data, glTFMaterial src, VRMC_materials_mtoon mtoon, Material dst, GetTextureAsyncFunc getTextureAsync, IAwaitCaller awaitCaller)
{
var context = new TinyMToonMaterialContext(dst);
ImportSurfaceSettings(src, context);
await ImportBaseShadeColorAsync(data, src, mtoon, 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 void ImportSurfaceSettings(glTFMaterial src, TinyMToonMaterialContext context)
{
// context.SurfaceType = src.alphaMode switch
// {
// "OPAQUE" => UrpLitSurfaceType.Opaque,
// "MASK" => UrpLitSurfaceType.Transparent,
// "BLEND" => UrpLitSurfaceType.Transparent,
// _ => UrpLitSurfaceType.Opaque,
// };
// context.BlendMode = context.SurfaceType switch
// {
// UrpLitSurfaceType.Transparent => UrpLitBlendMode.Alpha,
// _ => UrpLitBlendMode.Alpha,
// };
context.CutoffEnabled = src.alphaMode == "MASK";
context.Cutoff = src.alphaCutoff;
// context.CullMode = src.doubleSided ? CullMode.Off : CullMode.Back;
}
public static async Task ImportBaseShadeColorAsync(GltfData data, glTFMaterial src, VRMC_materials_mtoon mtoon, 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;
}
}
context.ShadingToonyFactor = mtoon.ShadingToonyFactor.GetValueOrDefault();
var shadeColor = mtoon.ShadeColorFactor?.ToColor3(UniGLTF.ColorSpace.Linear, UniGLTF.ColorSpace.sRGB);
context.ShadingColorFactorSrgb = shadeColor.GetValueOrDefault(Color.white);
if (mtoon is { ShadeMultiplyTexture: { Index: >= 0 } })
{
if (Vrm10MToonTextureImporter.TryGetShadeMultiplyTexture(data, mtoon, out var _, out var desc))
{
context.ShadingTexture = await getTextureAsync(desc, awaitCaller);
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 65362ac3cba13c14299e8a8ce356927d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,33 +0,0 @@
using UnityEngine;
namespace UniVRM10.VRM10Viewer
{
public class TinyPbrContext
{
private static readonly int BaseMap = Shader.PropertyToID("_BaseMap");
public readonly Material Material;
public Texture BaseTexture
{
get => Material.GetTexture(BaseMap);
set => Material.SetTexture(BaseMap, value);
}
public Vector2 BaseTextureOffset
{
get => Material.GetTextureOffset(BaseMap);
set => Material.SetTextureOffset(BaseMap, value);
}
public Vector2 BaseTextureScale
{
get => Material.GetTextureScale(BaseMap);
set => Material.SetTextureScale(BaseMap, value);
}
public TinyPbrContext(Material material)
{
Material = material;
}
}
}

View File

@ -1,84 +0,0 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using UniGLTF;
using UnityEngine;
namespace UniVRM10.VRM10Viewer
{
/// <summary>
/// GLTF の MaterialImporter
/// </summary>
public sealed class TinyPbrDescriptorGenerator : IMaterialDescriptorGenerator
{
public UrpGltfPbrMaterialImporter PbrMaterialImporter { get; } = new();
public UrpGltfDefaultMaterialImporter DefaultMaterialImporter { get; } = new();
public Material Material { get; set; }
public TinyPbrDescriptorGenerator(Material material)
{
Material = material;
}
public MaterialDescriptor Get(GltfData data, int i)
{
// TODO: VRM
// UNLIT
MaterialDescriptor param;
// if (BuiltInGltfUnlitMaterialImporter.TryCreateParam(data, i, out 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)
{
if (i < 0 || i >= data.GLTF.materials.Count)
{
matDesc = default;
return false;
}
var src = data.GLTF.materials[i];
matDesc = new MaterialDescriptor(
GltfMaterialImportUtils.ImportMaterialName(i, src),
Material.shader,
null,
new Dictionary<string, TextureDescriptor>(),
new Dictionary<string, float>(),
new Dictionary<string, Color>(),
new Dictionary<string, Vector4>(),
new List<Action<Material>>(),
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 TinyPbrContext(dst);
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;
}
}
}
}
}

View File

@ -0,0 +1,154 @@
using UnityEngine;
namespace UniVRM10.VRM10Viewer
{
public class TinyPbrMaterialContext
{
//
// When using shadergraph, you need to expose the following properties.
//
/// <summary>
/// Color = White
/// </summary>
private static readonly int BaseColorProp = Shader.PropertyToID("_BaseColor");
/// <summary>
/// Texture2D = white
/// When using shadergraph, require "Set as Main Texture"
/// </summary>
private static readonly int BaseMapProp = Shader.PropertyToID("_BaseMap");
/// <summary>
/// float = 1.0
/// </summary>
private static readonly int OcclusionStrengthProp = Shader.PropertyToID("_OcclusionStrength");
/// <summary>
/// Texture2D.Red = 1.0.
/// </summary>
private static readonly int OcclusionMapProp = Shader.PropertyToID("_OcclusionMap");
private static readonly int RoughnessProp = Shader.PropertyToID("_Roughness");
private static readonly int MetallicProp = Shader.PropertyToID("_Metallic");
/// <summary>
/// Texture2D.Green = 1.0. The roughness
/// Texture2D.Blue = 1.0. The metalness
/// </summary>
private static readonly int MetallicRoughnessMapProp = Shader.PropertyToID("_MetallicRoughnessMap");
/// <summary>
/// float = 1.0
/// </summary>
private static readonly int BumpScaleProp = Shader.PropertyToID("_BumpScale");
/// <summary>
/// Texture2D = [0, 0, 1.0]
/// </summary>
private static readonly int BumpMapProp = Shader.PropertyToID("_BumpMap");
/// <summary>
/// Color = black
/// </summary>
private static readonly int EmissionColorProp = Shader.PropertyToID("_EmissionColor");
/// <summary>
/// Texture2D = black
/// </summary>
private static readonly int EmissionMapProp = Shader.PropertyToID("_EmissionMap");
/// <summary>
/// boolean keyword
/// </summary>
private static readonly int CutoffEnabledProp = Shader.PropertyToID("_CutoffEnabled");
/// <summary>
/// float = 0.5
/// </summary>
private static readonly int CutoffProp = Shader.PropertyToID("_Cutoff");
public readonly Material Material;
public TinyPbrMaterialContext(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);
}
}
}

View File

@ -0,0 +1,163 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using UniGLTF;
using UnityEngine;
namespace UniVRM10.VRM10Viewer
{
public class TinyPbrMaterialImporter : IMaterialImporter
{
// public const string ALPHABLEND_SHADER_NAME = "Shader Graphs/TinyPbrAlphaBlend";
// public const string OPAQUE_SHADER_NAME = "Shader Graphs/TinyPbrOpaque";
Material m_opaque;
Material m_alphablend;
public TinyPbrMaterialImporter(Material opaque, Material alphablend)
{
m_opaque = opaque;
m_alphablend = alphablend;
}
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];
matDesc = new MaterialDescriptor(
GltfMaterialImportUtils.ImportMaterialName(i, src),
src.alphaMode == "BLEND" ? m_alphablend.shader : m_opaque.shader,
null,
new Dictionary<string, TextureDescriptor>(),
new Dictionary<string, float>(),
new Dictionary<string, Color>(),
new Dictionary<string, Vector4>(),
new List<Action<Material>>(),
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 TinyPbrMaterialContext(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 void ImportSurfaceSettings(glTFMaterial src, TinyPbrMaterialContext context)
{
// context.SurfaceType = src.alphaMode switch
// {
// "OPAQUE" => UrpLitSurfaceType.Opaque,
// "MASK" => UrpLitSurfaceType.Transparent,
// "BLEND" => UrpLitSurfaceType.Transparent,
// _ => UrpLitSurfaceType.Opaque,
// };
// context.BlendMode = context.SurfaceType switch
// {
// UrpLitSurfaceType.Transparent => UrpLitBlendMode.Alpha,
// _ => UrpLitBlendMode.Alpha,
// };
context.CutoffEnabled = src.alphaMode == "MASK";
context.Cutoff = src.alphaCutoff;
// context.CullMode = src.doubleSided ? CullMode.Off : CullMode.Back;
}
public static async Task ImportBaseColorAsync(GltfData data, glTFMaterial src, TinyPbrMaterialContext 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;
}
}
}
public static async Task ImportMetallicRoughnessAsync(GltfData data, glTFMaterial src, TinyPbrMaterialContext context, GetTextureAsyncFunc getTextureAsync, IAwaitCaller awaitCaller)
{
if (src.pbrMetallicRoughness != null)
{
context.Metallic = src.pbrMetallicRoughness.metallicFactor;
context.Roughness = src.pbrMetallicRoughness.roughnessFactor;
}
if (src is { pbrMetallicRoughness: { metallicRoughnessTexture: { index: >= 0 } } })
{
var (offset, scale) = GltfTextureImporter.GetTextureOffsetAndScale(src.pbrMetallicRoughness.metallicRoughnessTexture);
if (GltfTextureImporter.TryCreateLinear(data, src.pbrMetallicRoughness.metallicRoughnessTexture.index, offset, scale, out var _, out var desc))
{
context.MetallicRoughnessMap = await getTextureAsync(desc, awaitCaller);
}
}
}
public static async Task ImportOcclusionAsync(GltfData data, glTFMaterial src, TinyPbrMaterialContext context, GetTextureAsyncFunc getTextureAsync, IAwaitCaller awaitCaller)
{
if (src.occlusionTexture != null)
{
context.OcclusionStrength = src.occlusionTexture.strength;
}
if (src is { occlusionTexture: { index: >= 0 } })
{
var (offset, scale) = GltfTextureImporter.GetTextureOffsetAndScale(src.occlusionTexture);
if (GltfTextureImporter.TryCreateLinear(data, src.occlusionTexture.index, offset, scale, out var _, out var desc))
{
context.OcclusionTexture = await getTextureAsync(desc, awaitCaller);
}
}
}
private static async Task ImportNormalAsync(GltfData data, glTFMaterial src, TinyPbrMaterialContext context, GetTextureAsyncFunc getTextureAsync, IAwaitCaller awaitCaller)
{
if (src.normalTexture is { index: >= 0 })
{
if (GltfPbrTextureImporter.TryNormalTexture(data, src, out _, out var desc))
{
context.BumpMap = await getTextureAsync(desc, awaitCaller);
context.BumpScale = src.normalTexture.scale;
}
}
}
private static async Task ImportEmissionAsync(GltfData data, glTFMaterial src, TinyPbrMaterialContext context, GetTextureAsyncFunc getTextureAsync, IAwaitCaller awaitCaller)
{
var emissiveFactor = GltfMaterialImportUtils.ImportLinearEmissiveFactor(data, src);
if (emissiveFactor.HasValue)
{
context.EmissionColorLinear = emissiveFactor.Value;
}
if (src is { emissiveTexture: { index: >= 0 } })
{
if (GltfPbrTextureImporter.TryEmissiveTexture(data, src, out _, out var desc))
{
context.EmissionTexture = await getTextureAsync(desc, awaitCaller);
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0f9b3156e6cb9e84b924ab9e062df7fe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -10,7 +10,7 @@ namespace UniVRM10.VRM10Viewer
Vrm10Instance m_vrm;
public Vrm10Instance Instance => m_vrm;
public Vrm10RuntimeControlRig ControlRig => m_vrm.Runtime.ControlRig;
public Vrm10Runtime Runtime => m_vrm.Runtime;
public Vrm10Runtime Runtime => m_vrm?.Runtime;
public Loaded(RuntimeGltfInstance instance)
{

View File

@ -4717,7 +4717,7 @@ Transform:
m_GameObject: {fileID: 322182884}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 0, y: -0.001, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@ -30638,7 +30638,13 @@ MonoBehaviour:
Root: {fileID: 124675793}
m_version: {fileID: 1268276256}
m_faceCamera: {fileID: 1150163685}
m_customMaterial: {fileID: -876546973899608171, guid: ac58f8c11a130e04ba883a82ae4b78e4,
m_pbrOpaqueMaterial: {fileID: -876546973899608171, guid: ac58f8c11a130e04ba883a82ae4b78e4,
type: 3}
m_pbrAlphaBlendMaterial: {fileID: -876546973899608171, guid: 868190a58757d6242bb3ca456402f82f,
type: 3}
m_mtoonMaterialOpaque: {fileID: -876546973899608171, guid: fd08e80eb7e04e849b8a6d534e48efea,
type: 3}
m_mtoonMaterialAlphaBlend: {fileID: -876546973899608171, guid: 6b60fe85d745eda4281e3278fcb0657c,
type: 3}
m_useCustomMaterial: {fileID: 731212246}
m_openModel: {fileID: 2009818433}

View File

@ -24,7 +24,13 @@ namespace UniVRM10.VRM10Viewer
[Header("Material")]
[SerializeField]
Material m_customMaterial = default;
Material m_pbrOpaqueMaterial = default;
[SerializeField]
Material m_pbrAlphaBlendMaterial = default;
[SerializeField]
Material m_mtoonMaterialOpaque = default;
[SerializeField]
Material m_mtoonMaterialAlphaBlend = default;
[Header("UI")]
[SerializeField]
@ -479,8 +485,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_mtoonMaterialOpaque, m_mtoonMaterialAlphaBlend);
m_pbrImporter = new(m_pbrOpaqueMaterial, m_pbrAlphaBlendMaterial);
m_autoEmotion = gameObject.AddComponent<VRM10AutoExpression>();
m_autoBlink = gameObject.AddComponent<VRM10Blinker>();
m_autoLipsync = gameObject.AddComponent<VRM10AIUEO>();
@ -499,13 +520,13 @@ namespace UniVRM10.VRM10Viewer
Motion = BvhMotion.LoadBvhFromText(m_motion.text);
if (m_useCustomMaterial.isOn)
{
Motion.SetBoxManMaterial(Instantiate(m_customMaterial));
Motion.SetBoxManMaterial(Instantiate(m_pbrOpaqueMaterial));
}
}
if (ArgumentChecker.TryGetFirstLoadable(out var cmd))
{
var _ = LoadModel(cmd);
var _ = LoadModelPath(cmd);
}
m_texts.Start();
@ -558,96 +579,97 @@ namespace UniVRM10.VRM10Viewer
StopSpringBoneWriteback = m_springbonePause.isOn,
SupportsScalingAtRuntime = m_springboneScaling.isOn,
});
}
m_happy.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Happy);
m_angry.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Angry);
m_sad.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Sad);
m_relaxed.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Relaxed);
m_surprised.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Surprised);
m_lipAa.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Aa);
m_lipIh.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Ih);
m_lipOu.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Ou);
m_lipEe.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Ee);
m_lipOh.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Oh);
m_blink.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Blink);
if (m_enableAutoExpression.isOn)
{
vrm.Runtime.Expression.SetWeight(ExpressionKey.Happy, m_autoEmotion.Happy);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Angry, m_autoEmotion.Angry);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Sad, m_autoEmotion.Sad);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Relaxed, m_autoEmotion.Relaxed);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Surprised, m_autoEmotion.Surprised);
m_happy.m_expression.SetValueWithoutNotify(m_autoEmotion.Happy);
m_angry.m_expression.SetValueWithoutNotify(m_autoEmotion.Angry);
m_sad.m_expression.SetValueWithoutNotify(m_autoEmotion.Sad);
m_relaxed.m_expression.SetValueWithoutNotify(m_autoEmotion.Relaxed);
m_surprised.m_expression.SetValueWithoutNotify(m_autoEmotion.Surprised);
}
else
{
vrm.Runtime.Expression.SetWeight(ExpressionKey.Happy, m_happy.m_expression.value);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Angry, m_angry.m_expression.value);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Sad, m_sad.m_expression.value);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Relaxed, m_relaxed.m_expression.value);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Surprised, m_surprised.m_expression.value);
}
m_happy.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Happy);
m_angry.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Angry);
m_sad.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Sad);
m_relaxed.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Relaxed);
m_surprised.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Surprised);
m_lipAa.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Aa);
m_lipIh.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Ih);
m_lipOu.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Ou);
m_lipEe.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Ee);
m_lipOh.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Oh);
m_blink.ApplyRuntime(m_loaded.Instance.Vrm.Expression.Blink);
if (m_enableLipSync.isOn)
{
vrm.Runtime.Expression.SetWeight(ExpressionKey.Aa, m_autoLipsync.Aa);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Ih, m_autoLipsync.Ih);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Ou, m_autoLipsync.Ou);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Ee, m_autoLipsync.Ee);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Oh, m_autoLipsync.Oh);
m_lipAa.m_expression.SetValueWithoutNotify(m_autoLipsync.Aa);
m_lipIh.m_expression.SetValueWithoutNotify(m_autoLipsync.Ih);
m_lipOu.m_expression.SetValueWithoutNotify(m_autoLipsync.Ou);
m_lipEe.m_expression.SetValueWithoutNotify(m_autoLipsync.Ee);
m_lipOh.m_expression.SetValueWithoutNotify(m_autoLipsync.Oh);
}
else
{
vrm.Runtime.Expression.SetWeight(ExpressionKey.Aa, m_lipAa.m_expression.value);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Ih, m_lipIh.m_expression.value);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Ou, m_lipOu.m_expression.value);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Ee, m_lipEe.m_expression.value);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Oh, m_lipOh.m_expression.value);
}
if (m_enableAutoExpression.isOn)
{
vrm.Runtime.Expression.SetWeight(ExpressionKey.Happy, m_autoEmotion.Happy);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Angry, m_autoEmotion.Angry);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Sad, m_autoEmotion.Sad);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Relaxed, m_autoEmotion.Relaxed);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Surprised, m_autoEmotion.Surprised);
m_happy.m_expression.SetValueWithoutNotify(m_autoEmotion.Happy);
m_angry.m_expression.SetValueWithoutNotify(m_autoEmotion.Angry);
m_sad.m_expression.SetValueWithoutNotify(m_autoEmotion.Sad);
m_relaxed.m_expression.SetValueWithoutNotify(m_autoEmotion.Relaxed);
m_surprised.m_expression.SetValueWithoutNotify(m_autoEmotion.Surprised);
}
else
{
vrm.Runtime.Expression.SetWeight(ExpressionKey.Happy, m_happy.m_expression.value);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Angry, m_angry.m_expression.value);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Sad, m_sad.m_expression.value);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Relaxed, m_relaxed.m_expression.value);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Surprised, m_surprised.m_expression.value);
}
if (m_enableAutoBlink.isOn)
{
vrm.Runtime.Expression.SetWeight(ExpressionKey.Blink, m_autoBlink.BlinkValue);
m_blink.m_expression.SetValueWithoutNotify(m_autoBlink.BlinkValue);
}
else
{
vrm.Runtime.Expression.SetWeight(ExpressionKey.Blink, m_blink.m_expression.value);
}
if (m_enableLipSync.isOn)
{
vrm.Runtime.Expression.SetWeight(ExpressionKey.Aa, m_autoLipsync.Aa);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Ih, m_autoLipsync.Ih);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Ou, m_autoLipsync.Ou);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Ee, m_autoLipsync.Ee);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Oh, m_autoLipsync.Oh);
m_lipAa.m_expression.SetValueWithoutNotify(m_autoLipsync.Aa);
m_lipIh.m_expression.SetValueWithoutNotify(m_autoLipsync.Ih);
m_lipOu.m_expression.SetValueWithoutNotify(m_autoLipsync.Ou);
m_lipEe.m_expression.SetValueWithoutNotify(m_autoLipsync.Ee);
m_lipOh.m_expression.SetValueWithoutNotify(m_autoLipsync.Oh);
}
else
{
vrm.Runtime.Expression.SetWeight(ExpressionKey.Aa, m_lipAa.m_expression.value);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Ih, m_lipIh.m_expression.value);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Ou, m_lipOu.m_expression.value);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Ee, m_lipEe.m_expression.value);
vrm.Runtime.Expression.SetWeight(ExpressionKey.Oh, m_lipOh.m_expression.value);
}
if (m_useLookAtTarget.isOn)
{
var (yaw, pitch) = vrm.Runtime.LookAt.CalculateYawPitchFromLookAtPosition(m_lookAtTarget.transform.position);
vrm.Runtime.LookAt.SetYawPitchManually(yaw, pitch);
m_yaw.value = yaw;
m_pitch.value = pitch;
}
else
{
vrm.Runtime.LookAt.SetYawPitchManually(m_yaw.value, m_pitch.value);
}
if (m_enableAutoBlink.isOn)
{
vrm.Runtime.Expression.SetWeight(ExpressionKey.Blink, m_autoBlink.BlinkValue);
m_blink.m_expression.SetValueWithoutNotify(m_autoBlink.BlinkValue);
}
else
{
vrm.Runtime.Expression.SetWeight(ExpressionKey.Blink, m_blink.m_expression.value);
}
if (vrm.TryGetBoneTransform(HumanBodyBones.Head, out var head))
{
var initLocarlRotation = vrm.DefaultTransformStates[head].LocalRotation;
var r = head.rotation * Quaternion.Inverse(initLocarlRotation);
var pos = head.position
+ (r * Vector3.forward * 0.7f)
+ (r * Vector3.up * 0.07f)
;
m_faceCamera.position = pos;
m_faceCamera.rotation = r;
if (m_useLookAtTarget.isOn)
{
var (yaw, pitch) = vrm.Runtime.LookAt.CalculateYawPitchFromLookAtPosition(m_lookAtTarget.transform.position);
vrm.Runtime.LookAt.SetYawPitchManually(yaw, pitch);
m_yaw.value = yaw;
m_pitch.value = pitch;
}
else
{
vrm.Runtime.LookAt.SetYawPitchManually(m_yaw.value, m_pitch.value);
}
if (vrm.TryGetBoneTransform(HumanBodyBones.Head, out var head))
{
var initLocarlRotation = vrm.DefaultTransformStates[head].LocalRotation;
var r = head.rotation * Quaternion.Inverse(initLocarlRotation);
var pos = head.position
+ (r * Vector3.forward * 0.7f)
+ (r * Vector3.up * 0.07f)
;
m_faceCamera.position = pos;
m_faceCamera.rotation = r;
}
}
}
}
@ -657,10 +679,10 @@ namespace UniVRM10.VRM10Viewer
string FileDialog()
{
#if UNITY_EDITOR
return UnityEditor.EditorUtility.OpenFilePanel("Open VRM", "", "vrm");
#if UNITY_EDITOR
return UnityEditor.EditorUtility.OpenFilePanel("Open VRM", "", "vrm,glb,gltf,zip");
#elif UNITY_STANDALONE_WIN
return VRM10FileDialogForWindows.FileDialog("open VRM", "vrm");
return VRM10FileDialogForWindows.FileDialog("open VRM", "vrm", "glb", "gltf", "zip");
#elif UNITY_WEBGL
// Open WebGL_VRM10_VRM10Viewer_FileDialog
// see: Assets/UniGLTF/Runtime/Utils/Plugins/OpenFile.jslib
@ -675,19 +697,7 @@ namespace UniVRM10.VRM10Viewer
void OnOpenModelClicked()
{
var path = FileDialog();
if (string.IsNullOrEmpty(path))
{
return;
}
var ext = Path.GetExtension(path).ToLower();
if (ext != ".vrm")
{
UniGLTFLogger.Warning($"{path} is not vrm");
return;
}
_ = LoadModel(path);
_ = LoadModelPath(path);
}
/// <summary>
@ -704,15 +714,15 @@ namespace UniVRM10.VRM10Viewer
{
var www = new WWW(url);
yield return www;
var _ = LoadModel("WebGL.vrm", www.bytes);
var _ = LoadModelBytes("WebGL.vrm", www.bytes);
}
async void OnOpenMotionClicked()
{
#if UNITY_STANDALONE_WIN
#if UNITY_EDITOR
var path = UnityEditor.EditorUtility.OpenFilePanel("Open Motion", "", "bvh,gltf,glb,vrma");
#elif UNITY_STANDALONE_WIN
var path = VRM10FileDialogForWindows.FileDialog("open Motion", "bvh", "gltf", "glb", "vrma");
#elif UNITY_EDITOR
var path = UnityEditor.EditorUtility.OpenFilePanel("Open Motion", "", "bvh");
#else
var path = Application.dataPath + "/default.bvh";
#endif
@ -780,23 +790,11 @@ namespace UniVRM10.VRM10Viewer
}
}
static IMaterialDescriptorGenerator GetVrmMaterialDescriptorGenerator(bool useUrp)
{
if (useUrp)
{
return new UrpVrm10MaterialDescriptorGenerator();
}
else
{
return new BuiltInVrm10MaterialDescriptorGenerator();
}
}
IMaterialDescriptorGenerator GetMaterialDescriptorGenerator()
{
if (m_useCustomMaterial.isOn)
{
return new TinyPbrDescriptorGenerator(m_customMaterial);
return new OrderedMaterialDescriptorGenerator(m_mtoonImporter, m_unlitImporter, m_pbrImporter);
}
else
{
@ -808,11 +806,14 @@ namespace UniVRM10.VRM10Viewer
{
if (m_useAsync.isOn)
{
#if UNITY_WEBGL
return new RuntimeOnlyNoThreadAwaitCaller();
#else
return new RuntimeOnlyAwaitCaller();
#endif
if (Application.platform == RuntimePlatform.WebGLPlayer)
{
return new RuntimeOnlyNoThreadAwaitCaller();
}
else
{
return new RuntimeOnlyAwaitCaller();
}
}
else
{
@ -820,13 +821,13 @@ namespace UniVRM10.VRM10Viewer
}
}
async Task LoadModel(string path)
async Task LoadModelPath(string path)
{
var bytes = await File.ReadAllBytesAsync(path);
await LoadModel(path, bytes);
await LoadModelBytes(path, bytes);
}
async Task LoadModel(string path, byte[] bytes)
async Task LoadModelBytes(string path, byte[] bytes)
{
// cleanup
m_loaded?.Dispose();
@ -837,6 +838,9 @@ namespace UniVRM10.VRM10Viewer
try
{
//
// try VRM
//
UniGLTFLogger.Log($"{path}");
var vrm10Instance = await Vrm10.LoadBytesAsync(bytes,
canLoadVrm0X: true,
@ -876,16 +880,34 @@ namespace UniVRM10.VRM10Viewer
m_lipOh.OnLoad(m_loaded.Instance.Vrm.Expression.Oh);
m_blink.OnLoad(m_loaded.Instance.Vrm.Expression.Blink);
}
catch (Exception ex)
catch (Exception)
{
if (ex is OperationCanceledException)
try
{
UniGLTFLogger.Warning($"Canceled to Load: {path}");
//
// fallback gltf
//
var instance = await GltfUtility.LoadBytesAsync(path, bytes,
awaitCaller: GetIAwaitCaller(),
materialGenerator: GetMaterialDescriptorGenerator()
);
instance.ShowMeshes();
instance.EnableUpdateWhenOffscreen();
m_loaded = new Loaded(instance);
m_showBoxMan.isOn = false;
}
else
catch (Exception ex)
{
UniGLTFLogger.Error($"Failed to Load: {path}");
UniGLTFLogger.Exception(ex);
if (ex is OperationCanceledException)
{
UniGLTFLogger.Warning($"Canceled to Load: {path}");
}
else
{
UniGLTFLogger.Error($"Failed to Load: {path}");
UniGLTFLogger.Exception(ex);
}
}
}
}