Skip to content

Commit

Permalink
Implement a basic glTF exporter for materials
Browse files Browse the repository at this point in the history
  • Loading branch information
myaaaaaaaaa committed Nov 6, 2024
1 parent 5dbd41d commit bd8b6ae
Showing 1 changed file with 247 additions and 0 deletions.
247 changes: 247 additions & 0 deletions addons/material_maker/nodes/material.mmg
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,253 @@
}
]
},
"GLTF/Plane": {
"export_extension": "gltf",
"files": [
{
"conditions": "$(connected:albedo_tex)",
"file_name": "$(path_prefix)_albedo.png",
"output": 0,
"type": "texture"
},
{
"conditions": "$(connected:ao_tex) or $(connected:roughness_tex) or $(connected:metallic_tex)",
"file_name": "$(path_prefix)_orm.png",
"output": 1,
"type": "texture"
},
{
"conditions": "$(connected:emission_tex)",
"file_name": "$(path_prefix)_emission.png",
"output": 2,
"type": "texture"
},
{
"conditions": "$(connected:normal_tex)",
"file_name": "$(path_prefix)_normal.png",
"output": 3,
"type": "texture"
},
{
"file_name": "$(path_prefix).gltf",
"prompt_overwrite": true,
"template": [
"{",
"\t\"asset\":{",
"\t\t\"generator\":\"Material Maker export\",",
"\t\t\"version\":\"2.0\"",
"\t},",
"\t\"scene\":0,",
"\t\"scenes\":[",
"\t\t{",
"\t\t\t\"name\":\"Scene\",",
"\t\t\t\"nodes\":[",
"\t\t\t\t0",
"\t\t\t]",
"\t\t}",
"\t],",
"\t\"nodes\":[",
"\t\t{",
"\t\t\t\"mesh\":0,",
"\t\t\t\"name\":\"Plane\"",
"\t\t}",
"\t],",
"\t\"materials\":[",
"\t\t{",
"\t\t\t\"doubleSided\":true,",
"\t\t\t\"emissiveTexture\":{",
"\t\t\t\t\"index\":0",
"\t\t\t},",
"\t\t\t\"name\":\"$(file_prefix)\",",
"\t\t\t\"normalTexture\":{",
"\t\t\t\t\"index\":1",
"\t\t\t},",
"\t\t\t\"occlusionTexture\":{",
"\t\t\t\t\"index\":2",
"\t\t\t},",
"\t\t\t\"pbrMetallicRoughness\":{",
"\t\t\t\t\"baseColorTexture\":{",
"\t\t\t\t\t\"index\":3",
"\t\t\t\t},",
"\t\t\t\t\"metallicRoughnessTexture\":{",
"\t\t\t\t\t\"index\":2",
"\t\t\t\t}",
"\t\t\t}",
"\t\t}",
"\t],",
"\t\"meshes\":[",
"\t\t{",
"\t\t\t\"name\":\"Plane\",",
"\t\t\t\"primitives\":[",
"\t\t\t\t{",
"\t\t\t\t\t\"attributes\":{",
"\t\t\t\t\t\t\"POSITION\":0,",
"\t\t\t\t\t\t\"NORMAL\":1,",
"\t\t\t\t\t\t\"TEXCOORD_0\":2",
"\t\t\t\t\t},",
"\t\t\t\t\t\"indices\":3,",
"\t\t\t\t\t\"material\":0",
"\t\t\t\t}",
"\t\t\t]",
"\t\t}",
"\t],",
"\t\"textures\":[",
"\t\t{",
"\t\t\t\"sampler\":0,",
"\t\t\t\"source\":0",
"\t\t},",
"\t\t{",
"\t\t\t\"sampler\":0,",
"\t\t\t\"source\":1",
"\t\t},",
"\t\t{",
"\t\t\t\"sampler\":0,",
"\t\t\t\"source\":2",
"\t\t},",
"\t\t{",
"\t\t\t\"sampler\":0,",
"\t\t\t\"source\":3",
"\t\t}",
"\t],",
"\t\"images\":[",
"\t\t{",
"$if $(connected:emission_tex)",
"\t\t\t\"uri\":\"$(file_prefix)_emission.png\",",
"$else",
"\t\t\t\"bufferView\":4,",
"$fi",
"\t\t\t\"mimeType\":\"image/png\",",
"\t\t\t\"name\":\"emission\"",
"\t\t},",
"\t\t{",
"$if $(connected:normal_tex)",
"\t\t\t\"uri\":\"$(file_prefix)_normal.png\",",
"$else",
"\t\t\t\"bufferView\":5,",
"$fi",
"\t\t\t\"mimeType\":\"image/png\",",
"\t\t\t\"name\":\"normal\"",
"\t\t},",
"\t\t{",
"$if $(connected:ao_tex) or $(connected:roughness_tex) or $(connected:metallic_tex)",
"\t\t\t\"uri\":\"$(file_prefix)_orm.png\",",
"$else",
"\t\t\t\"bufferView\":6,",
"$fi",
"\t\t\t\"mimeType\":\"image/png\",",
"\t\t\t\"name\":\"orm\"",
"\t\t},",
"\t\t{",
"$if $(connected:albedo_tex)",
"\t\t\t\"uri\":\"$(file_prefix)_albedo.png\",",
"$else",
"\t\t\t\"bufferView\":7,",
"$fi",
"\t\t\t\"mimeType\":\"image/png\",",
"\t\t\t\"name\":\"albedo\"",
"\t\t}",
"\t],",
"\t\"accessors\":[",
"\t\t{",
"\t\t\t\"bufferView\":0,",
"\t\t\t\"componentType\":5126,",
"\t\t\t\"count\":4,",
"\t\t\t\"max\":[",
"\t\t\t\t2,",
"\t\t\t\t0,",
"\t\t\t\t2",
"\t\t\t],",
"\t\t\t\"min\":[",
"\t\t\t\t-2,",
"\t\t\t\t0,",
"\t\t\t\t-2",
"\t\t\t],",
"\t\t\t\"type\":\"VEC3\"",
"\t\t},",
"\t\t{",
"\t\t\t\"bufferView\":1,",
"\t\t\t\"componentType\":5126,",
"\t\t\t\"count\":4,",
"\t\t\t\"type\":\"VEC3\"",
"\t\t},",
"\t\t{",
"\t\t\t\"bufferView\":2,",
"\t\t\t\"componentType\":5126,",
"\t\t\t\"count\":4,",
"\t\t\t\"type\":\"VEC2\"",
"\t\t},",
"\t\t{",
"\t\t\t\"bufferView\":3,",
"\t\t\t\"componentType\":5123,",
"\t\t\t\"count\":6,",
"\t\t\t\"type\":\"SCALAR\"",
"\t\t}",
"\t],",
"\t\"bufferViews\":[",
"\t\t{",
"\t\t\t\"buffer\":0,",
"\t\t\t\"byteLength\":48,",
"\t\t\t\"byteOffset\":0,",
"\t\t\t\"target\":34962",
"\t\t},",
"\t\t{",
"\t\t\t\"buffer\":0,",
"\t\t\t\"byteLength\":48,",
"\t\t\t\"byteOffset\":48,",
"\t\t\t\"target\":34962",
"\t\t},",
"\t\t{",
"\t\t\t\"buffer\":0,",
"\t\t\t\"byteLength\":32,",
"\t\t\t\"byteOffset\":96,",
"\t\t\t\"target\":34962",
"\t\t},",
"\t\t{",
"\t\t\t\"buffer\":0,",
"\t\t\t\"byteLength\":12,",
"\t\t\t\"byteOffset\":128,",
"\t\t\t\"target\":34963",
"\t\t},",
"\t\t{",
"\t\t\t\"buffer\":0,",
"\t\t\t\"byteLength\":83,",
"\t\t\t\"byteOffset\":140",
"\t\t},",
"\t\t{",
"\t\t\t\"buffer\":0,",
"\t\t\t\"byteLength\":83,",
"\t\t\t\"byteOffset\":224",
"\t\t},",
"\t\t{",
"\t\t\t\"buffer\":0,",
"\t\t\t\"byteLength\":83,",
"\t\t\t\"byteOffset\":308",
"\t\t},",
"\t\t{",
"\t\t\t\"buffer\":0,",
"\t\t\t\"byteLength\":83,",
"\t\t\t\"byteOffset\":392",
"\t\t}",
"\t],",
"\t\"samplers\":[",
"\t\t{",
"\t\t\t\"magFilter\":9729,",
"\t\t\t\"minFilter\":9987",
"\t\t}",
"\t],",
"\t\"buffers\":[",
"\t\t{",
"\t\t\t\"byteLength\":476,",
"\t\t\t\"uri\":\"data:application/octet-stream;base64,AAAAwAAAAAAAAABAAAAAQAAAAAAAAABAAAAAwAAAAAAAAADAAAAAQAAAAAAAAADAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAwAAAQEAAAABAAABAQAAAAMAAAIC/AAAAQAAAgL8AAAEAAwAAAAMAAgCJUE5HDQoaCgAAAA1JSERSAAAAIAAAACABAwAAAEm06LcAAAADUExURQAAAKd6PdoAAAALSURBVAgdYxjkAAAAoAABl5qtUgAAAABJRU5ErkJgggCJUE5HDQoaCgAAAA1JSERSAAAAIAAAACABAwAAAEm06LcAAAADUExURYCA/1DOUZwAAAALSURBVAgdYxjkAAAAoAABl5qtUgAAAABJRU5ErkJgggCJUE5HDQoaCgAAAA1JSERSAAAAIAAAACABAwAAAEm06LcAAAADUExURf+AACJhkXwAAAALSURBVAgdYxjkAAAAoAABl5qtUgAAAABJRU5ErkJgggCJUE5HDQoaCgAAAA1JSERSAAAAIAAAACABAwAAAEm06LcAAAADUExURQAAAKd6PdoAAAALSURBVAgdYxjkAAAAoAABl5qtUgAAAABJRU5ErkJgggA=\"",
"\t\t}",
"\t]",
"}",
""
],
"type": "template"
}
]
},
"Godot/Godot 3 Spatial": {
"export_extension": "tres",
"files": [
Expand Down

0 comments on commit bd8b6ae

Please sign in to comment.