Skip to content

Commit

Permalink
1.38.9 Release Update (#13)
Browse files Browse the repository at this point in the history
* Minor doc / code update for 1.38.9 MTLX requirement.

* Mermaid version fix.

* Notebook update.
  • Loading branch information
kwokcb committed Mar 7, 2024
1 parent ab695ad commit e7cf15d
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 65 deletions.
7 changes: 3 additions & 4 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ <h2 id="contents">Contents</h2>
<li><a href="#documentation">Documentation</a></li>
</ul>
<h2 id="introduction">Introduction</h2>
<p>This package supports the bi-directional translation between MaterialX materials and glTF materials. The minimum version of MaterialX required is 1.38 8 and the target glTF version is 2.0.1.</p>
<p>This package supports the bi-directional translation between MaterialX materials and glTF materials. The minimum version of MaterialX required is 1.38.9 and the target glTF version is 2.0.1.</p>
<p>See the <a href="https://kwokcb.github.io/materialxgltf/">home page</a> for this project.</p>
<p>Below is an example of converting the &quot;Damaged Helmet&quot; asset (found in the <strong><a href="https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/DamagedHelmet">glTF Sample Model repository</a></strong>) to MaterialX and previewing.<br>
<img src="https://github.com/kwokcb/glTF_MaterialX/raw/main/docs/gltf_import-graphEditor2.png" width="80%"></p>
Expand All @@ -388,14 +388,13 @@ <h2 id="installation">Installation</h2>
<p>or the <strong><a href="https://github.com/kwokcb/materialxgltf">source repository</a></strong> can be cloned and the package built from the command line:</p>
<pre class="hljs"><code><div>py -m build
</div></code></pre>
<p>This will build a distribution folder called <code>dist</code> which contains<br>
a zip file which can be installed using:</p>
<p>This will build a distribution folder called <code>dist</code> which contains a zip file which can be installed using:</p>
<pre class="hljs"><code><div>pip --install &lt;name of zip&gt;
</div></code></pre>
<h3 id="requirements">Requirements</h3>
<p>Requires the installation of the following packages:</p>
<ul>
<li><code>materialx</code> version 1.38.8 or higher: For editing MaterialX documents.</li>
<li><code>materialx</code> version 1.38.9 or higher: For editing MaterialX documents.</li>
<li><code>pygltflib</code> : For conversion from <code>glTF</code> to <code>glb</code> including packaging dependent geometry and image resources.</li>
</ul>
<h2 id="documentation">Documentation</h2>
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## Introduction

This package supports the bi-directional translation between MaterialX materials and glTF materials. The minimum version of MaterialX required is 1.38 8 and the target glTF version is 2.0.1.
This package supports the bi-directional translation between MaterialX materials and glTF materials. The minimum version of MaterialX required is 1.38.9 and the target glTF version is 2.0.1.

See the [home page](https://kwokcb.github.io/materialxgltf/) for this project.

Expand All @@ -34,8 +34,7 @@ or the **[source repository](https://github.com/kwokcb/materialxgltf)** can be c
py -m build
```

This will build a distribution folder called `dist` which contains
a zip file which can be installed using:
This will build a distribution folder called `dist` which contains a zip file which can be installed using:

```bash
pip --install <name of zip>
Expand All @@ -45,7 +44,7 @@ pip --install <name of zip>

Requires the installation of the following packages:

* `materialx` version 1.38.8 or higher: For editing MaterialX documents.
* `materialx` version 1.38.9 or higher: For editing MaterialX documents.
* `pygltflib` : For conversion from `glTF` to `glb` including packaging dependent geometry and image resources.


Expand Down
33 changes: 15 additions & 18 deletions docs/examples.html

Large diffs are not rendered by default.

59 changes: 28 additions & 31 deletions docs/examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -41,7 +41,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -65,7 +65,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 16,
"metadata": {},
"outputs": [
{
Expand All @@ -76,7 +76,6 @@
"```text\n",
"BoomBoxWithAxes.gltf\n",
"BoomBoxWithAxes.mtlx\n",
"BoomBoxWithAxes.mtlx.glb\n",
"BoomBoxWithAxes.mtlx.gltf\n",
"BoomBoxWithAxes_baseColor.png\n",
"BoomBoxWithAxes_baseColor1.png\n",
Expand All @@ -88,13 +87,11 @@
"gltf_test_nondefault_pbr.mtlx\n",
"gltf_test_nondefault_pbr.mtlx.glb\n",
"gltf_test_nondefault_pbr.mtlx.gltf\n",
"Marble_3D_baked_gltf_pbr_base_color.png\n",
"Marble_3D_gltf_pbr_base_color.png\n",
"shaderball.gltf\n",
"shaderball_data.bin\n",
"standard_surface_marble_solid.mtlx\n",
"standard_surface_marble_solid.mtlx_baked.mtlx\n",
"standard_surface_marble_solid.mtlx_baked.mtlx_baked.mtlx\n",
"\n",
"```\n",
"</details>\n"
Expand Down Expand Up @@ -127,7 +124,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 17,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -235,7 +232,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 18,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -345,14 +342,14 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 19,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"> Load MaterialX document: D:\\Work\\materialx\\materialxgltf\\src\\materialxgltf\\data\\BoomBoxWithAxes.mtlx\n",
"> Load MaterialX document: d:\\Work\\materialx\\materialxgltf\\.venv\\lib\\site-packages\\materialxgltf\\data\\BoomBoxWithAxes.mtlx\n",
"- Convert MaterialX node to glTF: M_BoomBox\n",
"- Append single ORM texture BoomBoxWithAxes_roughnessMetallic.png\n",
"- Convert MaterialX node to glTF: M_Coordinates\n",
Expand All @@ -367,7 +364,7 @@
"```json\n",
"{\n",
" \"asset\": {\n",
" \"copyright\": \"Copyright 2022-2023: Bernard Kwok.\",\n",
" \"copyright\": \"Copyright 2022-2024: Bernard Kwok.\",\n",
" \"generator\": \"MaterialX 1.38 to glTF 2.0 generator. https://github.com/kwokcb/glTF_MaterialX\",\n",
" \"version\": \"2.0\"\n",
" },\n",
Expand Down Expand Up @@ -501,16 +498,16 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"> Load glTF geometry file: shaderBall.gltf\n",
"- glTF geometry file:D:\\Work\\materialx\\materialxgltf\\src\\materialxgltf\\data\\shaderBall.gltf\n",
"- Embedding glTF geometry file:D:\\Work\\materialx\\materialxgltf\\src\\materialxgltf\\data\\shaderBall.gltf\n",
"- glTF geometry file:d:\\Work\\materialx\\materialxgltf\\.venv\\lib\\site-packages\\materialxgltf\\data\\shaderBall.gltf\n",
"- Embedding glTF geometry file:d:\\Work\\materialx\\materialxgltf\\.venv\\lib\\site-packages\\materialxgltf\\data\\shaderBall.gltf\n",
"- Convert MaterialX node to glTF: M_BoomBox\n",
"- Append single ORM texture BoomBoxWithAxes_roughnessMetallic.png\n",
"- Convert MaterialX node to glTF: M_Coordinates\n",
Expand All @@ -526,7 +523,7 @@
"{\n",
" \"asset\": {\n",
" \"version\": \"2.0\",\n",
" \"copyright\": \"Copyright 2022-2023: Bernard Kwok.\",\n",
" \"copyright\": \"Copyright 2022-2024: Bernard Kwok.\",\n",
" \"generator\": \"MaterialX 1.38 to glTF 2.0 generator. https://github.com/kwokcb/glTF_MaterialX\"\n",
" },\n",
" \"accessors\": [\n",
Expand Down Expand Up @@ -942,16 +939,16 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 21,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"> Load glTF geometry file: D:\\Work\\materialx\\materialxgltf\\src\\materialxgltf\\data\\shaderBall.gltf\n",
"- glTF geometry file:D:\\Work\\materialx\\materialxgltf\\src\\materialxgltf\\data\\shaderBall.gltf\n",
"- Embedding glTF geometry file:D:\\Work\\materialx\\materialxgltf\\src\\materialxgltf\\data\\shaderBall.gltf\n",
"> Load glTF geometry file: d:\\Work\\materialx\\materialxgltf\\.venv\\lib\\site-packages\\materialxgltf\\data\\shaderBall.gltf\n",
"- glTF geometry file:d:\\Work\\materialx\\materialxgltf\\.venv\\lib\\site-packages\\materialxgltf\\data\\shaderBall.gltf\n",
"- Embedding glTF geometry file:d:\\Work\\materialx\\materialxgltf\\.venv\\lib\\site-packages\\materialxgltf\\data\\shaderBall.gltf\n",
"- Convert MaterialX node to glTF: M_BoomBox\n",
"- Append single ORM texture BoomBoxWithAxes_roughnessMetallic.png\n",
"- Convert MaterialX node to glTF: M_Coordinates\n",
Expand All @@ -967,7 +964,7 @@
"{\n",
" \"asset\": {\n",
" \"version\": \"2.0\",\n",
" \"copyright\": \"Copyright 2022-2023: Bernard Kwok.\",\n",
" \"copyright\": \"Copyright 2022-2024: Bernard Kwok.\",\n",
" \"generator\": \"MaterialX 1.38 to glTF 2.0 generator. https://github.com/kwokcb/glTF_MaterialX\"\n",
" },\n",
" \"accessors\": [\n",
Expand Down Expand Up @@ -1385,7 +1382,7 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 22,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1477,7 +1474,7 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 23,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1548,9 +1545,9 @@
" <input name=\"mix\" type=\"float\" nodename=\"power\" />\n",
" </mix>\n",
" <standard_surface_to_gltf_pbr name=\"node1\" type=\"multioutput\" nodedef=\"ND_standard_surface_to_gltf_pbr\">\n",
" <input name=\"base\" type=\"float\" value=\"1\" />\n",
" <input name=\"base_color\" type=\"color3\" nodename=\"color_mix\" />\n",
" <input name=\"specular_roughness\" type=\"float\" value=\"0.1\" />\n",
" <input name=\"base\" type=\"float\" value=\"1\" colorspace=\"lin_rec709\" />\n",
" <input name=\"base_color\" type=\"color3\" nodename=\"color_mix\" colorspace=\"lin_rec709\" />\n",
" <input name=\"specular_roughness\" type=\"float\" value=\"0.1\" colorspace=\"lin_rec709\" />\n",
" </standard_surface_to_gltf_pbr>\n",
" <output name=\"base_color_out\" type=\"color3\" nodename=\"node1\" output=\"base_color_out\" />\n",
" <output name=\"metallic_out\" type=\"float\" nodename=\"node1\" output=\"metallic_out\" />\n",
Expand Down Expand Up @@ -1632,7 +1629,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 24,
"metadata": {},
"outputs": [
{
Expand All @@ -1645,7 +1642,7 @@
"<materialx version=\"1.38\" colorspace=\"lin_rec709\">\n",
" <nodegraph name=\"NG_baked\" colorspace=\"srgb_texture\">\n",
" <image name=\"base_color_baked\" type=\"color3\">\n",
" <input name=\"file\" type=\"filename\" value=\"D:\\Work\\materialx\\materialxgltf\\src\\materialxgltf\\data\\Marble_3D_gltf_pbr_base_color.png\" />\n",
" <input name=\"file\" type=\"filename\" value=\"d:\\Work\\materialx\\materialxgltf\\.venv\\lib\\site-packages\\materialxgltf\\data\\Marble_3D_gltf_pbr_base_color.png\" />\n",
" </image>\n",
" <output name=\"base_color_output\" type=\"color3\" nodename=\"base_color_baked\" />\n",
" </nodegraph>\n",
Expand Down Expand Up @@ -1703,14 +1700,14 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"- Remapped URI: \"D:/Work/materialx/materialxgltf/src/materialxgltf/data/Marble_3D_gltf_pbr_base_color.png\" to \"Marble_3D_gltf_pbr_base_color.png\"\n"
"- Remapped URI: \"d:/Work/materialx/materialxgltf/.venv/lib/site-packages/materialxgltf/data/Marble_3D_gltf_pbr_base_color.png\" to \"Marble_3D_gltf_pbr_base_color.png\"\n"
]
},
{
Expand Down Expand Up @@ -1765,7 +1762,7 @@
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": 26,
"metadata": {},
"outputs": [
{
Expand All @@ -1784,7 +1781,7 @@
"```json\n",
"{\n",
" \"asset\": {\n",
" \"copyright\": \"Copyright 2022-2023: Bernard Kwok.\",\n",
" \"copyright\": \"Copyright 2022-2024: Bernard Kwok.\",\n",
" \"generator\": \"MaterialX 1.38 to glTF 2.0 generator. https://github.com/kwokcb/glTF_MaterialX\",\n",
" \"version\": \"2.0\"\n",
" },\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/gallery.html
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@

</style>

<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.min.js"></script>
</head>
<body>
<script>
Expand Down Expand Up @@ -453,7 +453,7 @@ <h4 id="%22standard-surface%22-shading-model-conversions">&quot;Standard Surface
</tbody>
</table>
<p>The following are examples materials from <a href="https://github.com/PrismPipeline/QuiltiX" target="_blank">QuiltiX (0.5.0)</a>. This library uses QuiltiX by creating a <a href="https://github.com/kwokcb/QuiltiX/blob/gltf_plugin/plugins/pluginQuiltX.py" target="_blank">custom script</a> which calls into QuiltiX and extends the functionality by adding in glTF import and export menu items.<br>
Some QuiltiX and MaterialX code fixes and overriding to use the MaterialX 1.38.8 definition library for OpenUSD was required. The results of a few examples which come with QuiltIX are shown.</p>
QuiltiX and MaterialX to use the MaterialX 1.38.9 definition library for OpenUSD was required. The results of a few examples which come with QuiltIX are shown.</p>
<table>
<thead>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion docs/gallery.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ MaterialX files with multiple materials are each converted and then packaged int
| | | |

The following are examples materials from <a href="https://github.com/PrismPipeline/QuiltiX" target="_blank">QuiltiX (0.5.0)</a>. This library uses QuiltiX by creating a <a href="https://github.com/kwokcb/QuiltiX/blob/gltf_plugin/plugins/pluginQuiltX.py" target="_blank">custom script</a> which calls into QuiltiX and extends the functionality by adding in glTF import and export menu items.
Some QuiltiX and MaterialX code fixes and overriding to use the MaterialX 1.38.8 definition library for OpenUSD was required. The results of a few examples which come with QuiltIX are shown.
QuiltiX and MaterialX to use the MaterialX 1.38.9 definition library for OpenUSD was required. The results of a few examples which come with QuiltIX are shown.

| | | |
| :--: | :--: | :--: |
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "materialxgltf"
version = "0.0.4"
version = "1.38.9"
authors = [
{ name="Bernard Kwok", email="[email protected]" },
]
Expand All @@ -20,7 +20,7 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"materialx>=1.38.8",
"materialx>=1.38.9",
"pygltflib"
]
[tool.setuptools.packages.find]
Expand Down
4 changes: 2 additions & 2 deletions src/materialxgltf/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1929,8 +1929,8 @@ def writeCopyright(self, doc, gltfJson):
asset = gltfJson['asset']
else:
asset = gltfJson['asset'] = {}
asset['copyright'] = 'Copyright 2022-2023: Bernard Kwok.'
asset['generator'] = 'MaterialX ' + doc.getVersionString() + ' to glTF 2.0 generator. https://github.com/kwokcb/glTF_MaterialX'
asset['copyright'] = 'Copyright 2022-2024: Bernard Kwok.'
asset['generator'] = 'MaterialX ' + doc.getVersionString() + ' to glTF 2.0 generator. https://github.com/kwokcb/materialxgltf'
asset['version'] = '2.0'

def materialX2glTF(self, doc, gltfJson, resetMaterials):
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<materialx version="1.38" colorspace="lin_rec709">
<nodegraph name="NG_baked" colorspace="srgb_texture">
<image name="base_color_baked" type="color3">
<input name="file" type="filename" value="D:\Work\materialx\materialxgltf\src\materialxgltf\data\Marble_3D_gltf_pbr_base_color.png" />
</image>
<output name="base_color_output" type="color3" nodename="base_color_baked" />
</nodegraph>
<gltf_pbr name="SR_marble1_baked" type="surfaceshader">
<input name="base_color" type="color3" output="base_color_output" nodegraph="NG_baked" />
<input name="metallic" type="float" value="0" />
<input name="roughness" type="float" value="0.0980392" />
<input name="clearcoat_roughness" type="float" value="0.0980392" />
</gltf_pbr>
<surfacematerial name="Marble_3D_baked" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="SR_marble1_baked" />
</surfacematerial>
</materialx>
2 changes: 2 additions & 0 deletions src/materialxgltf/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
MTLX_GLTF_NORMALMAP_IMAGE = 'gltf_normalmap'
MTLX_DEFAULT_COLORSPACE = 'srgb_texture'
# mx.PortElement.NODE_NAME_ATTRIBUTE is not exposed
MTLX_INTERFACEINPUT_NAME_ATTRIBUTE = 'interfacename'
MTLX_NODE_NAME_ATTRIBUTE = 'nodename'
MTLX_NODEGRAPH_NAME_ATTRIBUTE = 'nodegraph'
MTLX_COLOR_SPACE_ATTRIBUTE = 'colorspace' # mx.Element.COLOR_SPACE_ATTRIBUTE is not exposed
MTLX_VEC3_STRING = 'vector3'
EMPTY_STRING = ''
Expand Down
4 changes: 3 additions & 1 deletion src/materialxgltf/gltf2Mtlx.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ def gltf2Mtlx(gltfFileName, mtlxFileName, options=GLTF2MtlxOptions()):
err = 'Error converting glTF file to MaterialX file'
else:
status, err = doc.validate()
print(mx.writeToXmlString(doc))
if not status:
print('Validation error: ', err)
#print(mx.writeToXmlString(doc))
Util.writeMaterialXDoc(doc, mtlxFileName)

return status, err
Expand Down

0 comments on commit e7cf15d

Please sign in to comment.