Skip to content

Commit

Permalink
Bump to v0.0.2 (#2)
Browse files Browse the repository at this point in the history
Update Jupyter book, gallery and readme
- Fix baking calls to use proper search path option
- Add GLTF->MTLX test suite folder.
- Add in few glTF -> MTLX render examples
  • Loading branch information
kwokcb committed Nov 9, 2023
1 parent 73dec6c commit 1089d2e
Show file tree
Hide file tree
Showing 14 changed files with 797 additions and 250 deletions.
25 changes: 13 additions & 12 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,17 @@ <h2 id="contents">Contents</h2>
</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>Below is an example of converting the &quot;Damaged Helmet&quot; asset (found in the <a href="https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/DamagedHelmet">glTF Sample Model repository</a> to MaterialX and previewing.<br>
<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>
<p>The functionality found here is equivalent to the C++ module available in<br>
<a href="https://github.com/kwokcb/glTF_MaterialX">this repository</a>. Note that additional documentation can be found on that site.</p>
<strong><a href="https://github.com/kwokcb/glTF_MaterialX">this repository</a></strong>. Note that additional documentation can be found on that site.</p>
<h2 id="installation">Installation</h2>
<p>The minimum version of Python is assumed to be 3.9.</p>
<p>The package can be installed using `pip``:</p>
<p>The package hosted on <strong><a href="https://pypi.org/project/materialxgltf/">PyPi</a></strong> can be installed using <code>pip</code>:</p>
<pre class="hljs"><code><div>pip install materialxgltf
</div></code></pre>
<p>or the <a href="https://github.com/kwokcb/materialxgltf">source repository</a> can be cloned and the package built from the command line:</p>
<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>
Expand All @@ -398,25 +399,25 @@ <h3 id="requirements">Requirements</h3>
<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>
<p>For more detailed information about the workflow this package supports, please refer to this <a href="https://kwokcb.github.io/MaterialX_Learn/documents/workflow_gltf.html">documentation</a>.</p>
<p>Refer to <a href="https://kwokcb.github.io/materialxgltf/docs/html">this documentation</a> for API usage.</p>
<p>For more detailed information about the workflow this package supports, please refer to this <strong><a href="https://kwokcb.github.io/MaterialX_Learn/documents/workflow_gltf.html">documentation</a></strong>.</p>
<p>For API usage, refer to <strong><a href="https://kwokcb.github.io/materialxgltf/docs/html">this documentation</a></strong>.</p>
<h2 id="usage">Usage</h2>
<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.js">
</script>
<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.js"></script>
<p><model-viewer style='background-color:rgba(0, 0, 0, 1.0); width: 48em; height: 48em' id='viewer1' ar interaction-prompt='none' camera-controls touch-action='pan-y' src='./docs/data/BoomBoxWithAxes_primMaterials.glb' shadow-intensity='0.3' alt='BoomBox With Axes Per Prim Material' poster='./docs/data/BoomBoxWithAxes_primMaterials.png'></model-viewer></p>
<p>The following shows is a set of progressive examples to convert from a glTF file to MaterialX and then to a new glTF file for &quot;shader ball&quot; preview of<br>
extracted materials.</p>
<p>Note that the sample data is included as part of the package for convenience.</p>
<p>The sample input file is the &quot;BoomBox with Axes&quot; file from the glTF sample repository found <a href="https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/BoomBoxWithAxes/glTF">here</a>.</p>
<p>The sample input file is the &quot;BoomBox with Axes&quot; file from the glTF sample repository found <strong><a href="https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/BoomBoxWithAxes/glTF">here</a></strong>.</p>
<img src="https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/BoomBoxWithAxes/screenshot/screenshot.jpg">
<p>This is converted from glTF to a MaterialX document which can be previewed / modified using an integration which supports MaterialX. Here the file is loaded into the &quot;MaterialX Graph Editor&quot; which comes with <a href="https://github.com/AcademySoftwareFoundation/MaterialX/releases">MaterialX releases</a>.</p>
<p>This is converted from glTF to a MaterialX document which can be previewed / modified using an integration which supports MaterialX. Here the file is loaded into the &quot;MaterialX Graph Editor&quot; which comes with <strong><a href="https://github.com/AcademySoftwareFoundation/MaterialX/releases">MaterialX releases</a></strong>.</p>
<p><img src="https://raw.githubusercontent.com/kwokcb/MaterialX_Learn/main/documents/images/gltf_to_mtlx_boombox_with_axes.png" alt="MaterialX Graph Editor Snapshot"
width="80%"></p>
<p>The converted materials are then used to create a new glTF file using sample &quot;shaderball&quot; data with each material found assigned to different instances of the &quot;shaderball&quot;</p>
<p><img src="https://raw.githubusercontent.com/kwokcb/MaterialX_Learn/main/documents/images/mtlx_to_gltf_materialviewer.png" alt="VSCode Snapshot"
width="50%"></p>
<h2 id="interactive-example">Interactive Example</h2>
<p>A <code>Jupyter</code> notebook which performs the same steps is available <a href="https://kwokcb.github.io/docs/examples.html">here</a>. This or any other notebook can be used if the user wishes to test the package in an interactive environment.</p>
<p>A <code>Jupyter</code> notebook which performs the same steps is available <strong><a href="https://kwokcb.github.io/materialxgltf/docs/examples.html">here</a></strong>.</p>
<p>This or any other notebook can be used if the user wishes to test the package in an interactive environment.</p>
<h3 id="import-the-package">Import the package</h3>
<pre class="hljs"><code><div><span class="hljs-keyword">import</span> materialxgltf.core <span class="hljs-keyword">as</span> core
</div></code></pre>
Expand Down Expand Up @@ -543,7 +544,7 @@ <h3 id="translate-shader-and-bake-textures">Translate Shader and Bake Textures</
<p>All materials are assumed to use glTF PBR surface shaders.<br>
Conversion to this shading model can be performed via MaterialX<br>
utilities, which includes texture baking.</p>
<p>Please refer to the sample Jupyter notebook for an example of shader<br>
<p>Please refer to the <strong><a href="https://kwokcb.github.io/materialxgltf/docs/examples.html">sample Jupyter notebook</a></strong> for an example of shader<br>
translation and baking using some convenience functions included with the package.<br>
Note that they do not need to be used as the core MaterialX distribution provides<br>
access to the APIs used in this package.</p>
Expand Down
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ This package supports the bi-directional translation between MaterialX materials

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

Below is an example of converting the "Damaged Helmet" asset (found in the [glTF Sample Model repository](https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/DamagedHelmet) to MaterialX and previewing.
Below is an example of converting the "Damaged Helmet" asset (found in the **[glTF Sample Model repository](https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/DamagedHelmet)**) to MaterialX and previewing.
<img src="https://github.com/kwokcb/glTF_MaterialX/raw/main/docs/gltf_import-graphEditor2.png" width="80%">

The functionality found here is equivalent to the C++ module available in
[this repository](https://github.com/kwokcb/glTF_MaterialX). Note that additional documentation can be found on that site.
**[this repository](https://github.com/kwokcb/glTF_MaterialX)**. Note that additional documentation can be found on that site.

## Installation

The minimum version of Python is assumed to be 3.9.

The package hosted on [PyPi](https://pypi.org/project/materialxgltf/) can be installed using `pip`:
The package hosted on **[PyPi](https://pypi.org/project/materialxgltf/)** can be installed using `pip`:

```bash
pip install materialxgltf
```

or the [source repository](https://github.com/kwokcb/materialxgltf) can be cloned and the package built from the command line:
or the **[source repository](https://github.com/kwokcb/materialxgltf)** can be cloned and the package built from the command line:

```bash
py -m build
Expand All @@ -51,9 +51,9 @@ Requires the installation of the following packages:

## Documentation

For more detailed information about the workflow this package supports, please refer to this [documentation](https://kwokcb.github.io/MaterialX_Learn/documents/workflow_gltf.html).
For more detailed information about the workflow this package supports, please refer to this **[documentation](https://kwokcb.github.io/MaterialX_Learn/documents/workflow_gltf.html)**.

For API usage, refer to [this documentation](https://kwokcb.github.io/materialxgltf/docs/html).
For API usage, refer to **[this documentation](https://kwokcb.github.io/materialxgltf/docs/html)**.

## Usage

Expand All @@ -66,11 +66,11 @@ extracted materials.

Note that the sample data is included as part of the package for convenience.

The sample input file is the "BoomBox with Axes" file from the glTF sample repository found [here](https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/BoomBoxWithAxes/glTF).
The sample input file is the "BoomBox with Axes" file from the glTF sample repository found **[here](https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/BoomBoxWithAxes/glTF)**.

<img src="https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/BoomBoxWithAxes/screenshot/screenshot.jpg">

This is converted from glTF to a MaterialX document which can be previewed / modified using an integration which supports MaterialX. Here the file is loaded into the "MaterialX Graph Editor" which comes with [MaterialX releases](https://github.com/AcademySoftwareFoundation/MaterialX/releases).
This is converted from glTF to a MaterialX document which can be previewed / modified using an integration which supports MaterialX. Here the file is loaded into the "MaterialX Graph Editor" which comes with **[MaterialX releases](https://github.com/AcademySoftwareFoundation/MaterialX/releases)**.

<img src="https://raw.githubusercontent.com/kwokcb/MaterialX_Learn/main/documents/images/gltf_to_mtlx_boombox_with_axes.png" alt="MaterialX Graph Editor Snapshot"
width="80%">
Expand All @@ -82,7 +82,9 @@ width="50%">

## Interactive Example

A `Jupyter` notebook which performs the same steps is available [here](https://kwokcb.github.io/docs/examples.html). This or any other notebook can be used if the user wishes to test the package in an interactive environment.
A `Jupyter` notebook which performs the same steps is available **[here](https://kwokcb.github.io/materialxgltf/docs/examples.html)**.

This or any other notebook can be used if the user wishes to test the package in an interactive environment.

### Import the package
```python
Expand Down Expand Up @@ -229,7 +231,7 @@ All materials are assumed to use glTF PBR surface shaders.
Conversion to this shading model can be performed via MaterialX
utilities, which includes texture baking.

Please refer to the sample Jupyter notebook for an example of shader
Please refer to the **[sample Jupyter notebook](https://kwokcb.github.io/materialxgltf/docs/examples.html)** for an example of shader
translation and baking using some convenience functions included with the package.
Note that they do not need to be used as the core MaterialX distribution provides
access to the APIs used in this package.
Expand Down
36 changes: 36 additions & 0 deletions docs/data/RTS_GLTF/DamagedHelmet.gltf_converted.mtlx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0"?>
<materialx version="1.38">
<!-- Generated shader: Material_MR -->
<gltf_pbr name="Material_MR" type="surfaceshader" nodedef="ND_gltf_pbr_surfaceshader">
<input name="base_color" type="color3" nodename="image_base_color" output="outcolor" />
<input name="alpha" type="float" nodename="image_base_color" output="outa" />
<input name="metallic" type="float" nodename="image_orm" channels="z" />
<input name="roughness" type="float" nodename="image_orm" channels="y" />
<input name="occlusion" type="float" nodename="image_occlusion" channels="x" />
<input name="normal" type="vector3" nodename="image_normal" />
<input name="emissive" type="color3" nodename="image_emissive" output="outcolor" />
</gltf_pbr>
<!-- Generated material: MAT_Material_MR -->
<surfacematerial name="MAT_Material_MR" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="Material_MR" />
</surfacematerial>
<gltf_colorimage name="image_base_color" type="multioutput">
<input name="file" type="filename" value="Default_albedo.jpg" colorspace="srgb_texture" />
</gltf_colorimage>
<gltf_image name="image_orm" type="vector3">
<input name="file" type="filename" value="Default_metalRoughness.jpg" />
</gltf_image>
<gltf_normalmap name="image_normal" type="vector3">
<input name="file" type="filename" value="Default_normal.jpg" />
</gltf_normalmap>
<gltf_image name="image_occlusion" type="float">
<input name="file" type="filename" value="Default_AO.jpg" />
</gltf_image>
<gltf_colorimage name="image_emissive" type="multioutput">
<input name="file" type="filename" value="Default_emissive.jpg" colorspace="srgb_texture" />
</gltf_colorimage>
<!-- Generated material assignments -->
<look name="look">
<materialassign name="MAT_Material_MR" material="MAT_Material_MR" geom="/node_damagedHelmet__6514/mesh_helmet_LP_13930damagedHelmet" />
</look>
</materialx>
Loading

0 comments on commit 1089d2e

Please sign in to comment.