Skip to content

Commit

Permalink
Basic File Texture Support (#2) (#12)
Browse files Browse the repository at this point in the history
* - Add basic texture / image append if a file reference is found.
- Add simple file example.

* - Cleanup constant strings.
- Extract out fallback texture logic to addFallbackTexture() method.
- Normalize variable naming.

* More cleanup. Remove python build scripts as using shell scripts.
  • Loading branch information
kwokcb authored Oct 8, 2024
1 parent 6072346 commit 95cb2c7
Show file tree
Hide file tree
Showing 73 changed files with 3,146 additions and 2,234 deletions.
54 changes: 41 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,24 +135,24 @@ The two input colors, and a texture coordinate tiling option are exposed on the
```mermaid
graph TB
subgraph NG_main
NG_main_uvtiling([uvtiling:8,8])
NG_main_uvtiling([input:vector2:8,8])
style NG_main_uvtiling fill:#09D, color:#FFF
NG_main_color1([color1:1,0.094118,0.031373])
NG_main_color1([input:color3:1,0.094118,0.031373])
style NG_main_color1 fill:#09D, color:#FFF
NG_main_color2([color2:0.035294,0.090196,0.878431])
NG_main_color2([input:color3:0.035294,0.090196,0.878431])
style NG_main_color2 fill:#09D, color:#FFF
NG_main_output_N_mtlxmix_out([output_N_mtlxmix_out])
NG_main_output_N_mtlxmix_out([output:color3])
style NG_main_output_N_mtlxmix_out fill:#09D, color:#FFF
NG_main_N_mtlxmix[N_mtlxmix]
NG_main_N_mtlxdotproduct[N_mtlxdotproduct]
NG_main_N_mtlxmult[N_mtlxmult]
NG_main_N_mtlxsubtract[N_mtlxsubtract]
NG_main_N_mtlxfloor[N_mtlxfloor]
NG_main_N_modulo[N_modulo]
NG_main_Texcoord[Texcoord:0]
NG_main_N_mtlxmix[mix:color3]
NG_main_N_mtlxdotproduct[dotproduct:float]
NG_main_N_mtlxmult[multiply:vector2]
NG_main_N_mtlxsubtract[subtract:vector2]
NG_main_N_mtlxfloor[floor:vector2]
NG_main_N_modulo[modulo:float]
NG_main_Texcoord[texcoord:vector2:0]
end
Gltf_pbr[Gltf_pbr]
MAT_Gltf_pbr([MAT_Gltf_pbr])
Gltf_pbr[gltf_pbr:surfaceshader]
MAT_Gltf_pbr([surfacematerial:material])
style MAT_Gltf_pbr fill:#090, color:#FFF
NG_main_N_mtlxmix --> NG_main_output_N_mtlxmix_out
NG_main_color1 --"fg"--> NG_main_N_mtlxmix
Expand All @@ -176,6 +176,34 @@ graph TB
</td>
</tr>

<tr>
<td>Pattern graph using a file texture

```mermaid
graph TB
subgraph nodegraph1
nodegraph1_output_color3([output_color3:color3])
style nodegraph1_output_color3 fill:#09D, color:#FFF
nodegraph1_image_color3[image_color3:color3]
nodegraph1_place2d_vector2[place2d_vector2:vector2]
nodegraph1_texcoord_vector2[texcoord_vector2:vector2:1]
end
gltf_pbr_surfaceshader[gltf_pbr_surfaceshader:surfaceshader]
surfacematerial([surfacematerial:material])
style surfacematerial fill:#090, color:#FFF
nodegraph1_image_color3 --> nodegraph1_output_color3
nodegraph1_place2d_vector2 --"texcoord"--> nodegraph1_image_color3
nodegraph1_texcoord_vector2 --"texcoord"--> nodegraph1_place2d_vector2
nodegraph1_output_color3 --"base_color"--> gltf_pbr_surfaceshader
gltf_pbr_surfaceshader --"surfaceshader"--> surfacematerial
```

</td>
<td><a href="./tests/data/streams_images/gltf_simple_filetexture.mtlx">MTLX</a>
<a href="./tests/data/streams_images/gltf_simple_filetexture.gltf">GLTF</a>
<td><img src="./tests/data/streams_images/gltf_simple_filetexture.png">
</tr>

</table>

</details>
56 changes: 43 additions & 13 deletions documents/README_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,24 @@ The two input colors, and a texture coordinate tiling option are exposed on the

graph TB
subgraph NG_main
NG_main_uvtiling([uvtiling:8,8])
NG_main_uvtiling([input:vector2:8,8])
style NG_main_uvtiling fill:#09D, color:#FFF
NG_main_color1([color1:1,0.094118,0.031373])
NG_main_color1([input:color3:1,0.094118,0.031373])
style NG_main_color1 fill:#09D, color:#FFF
NG_main_color2([color2:0.035294,0.090196,0.878431])
NG_main_color2([input:color3:0.035294,0.090196,0.878431])
style NG_main_color2 fill:#09D, color:#FFF
NG_main_output_N_mtlxmix_out([output_N_mtlxmix_out])
NG_main_output_N_mtlxmix_out([output:color3])
style NG_main_output_N_mtlxmix_out fill:#09D, color:#FFF
NG_main_N_mtlxmix[N_mtlxmix]
NG_main_N_mtlxdotproduct[N_mtlxdotproduct]
NG_main_N_mtlxmult[N_mtlxmult]
NG_main_N_mtlxsubtract[N_mtlxsubtract]
NG_main_N_mtlxfloor[N_mtlxfloor]
NG_main_N_modulo[N_modulo]
NG_main_Texcoord[Texcoord:0]
NG_main_N_mtlxmix[mix:color3]
NG_main_N_mtlxdotproduct[dotproduct:float]
NG_main_N_mtlxmult[multiply:vector2]
NG_main_N_mtlxsubtract[subtract:vector2]
NG_main_N_mtlxfloor[floor:vector2]
NG_main_N_modulo[modulo:float]
NG_main_Texcoord[texcoord:vector2:0]
end
Gltf_pbr[Gltf_pbr]
MAT_Gltf_pbr([MAT_Gltf_pbr])
Gltf_pbr[gltf_pbr:surfaceshader]
MAT_Gltf_pbr([surfacematerial:material])
style MAT_Gltf_pbr fill:#090, color:#FFF
NG_main_N_mtlxmix --> NG_main_output_N_mtlxmix_out
NG_main_color1 --"fg"--> NG_main_N_mtlxmix
Expand All @@ -182,6 +182,36 @@ graph TB
</td>
</tr>

<tr>
<td>Pattern graph using a file texture

<pre><code class="language-mermaid"><div class="mermaid">

graph TB
subgraph nodegraph1
nodegraph1_output_color3([output_color3:color3])
style nodegraph1_output_color3 fill:#09D, color:#FFF
nodegraph1_image_color3[image_color3:color3]
nodegraph1_place2d_vector2[place2d_vector2:vector2]
nodegraph1_texcoord_vector2[texcoord_vector2:vector2:1]
end
gltf_pbr_surfaceshader[gltf_pbr_surfaceshader:surfaceshader]
surfacematerial([surfacematerial:material])
style surfacematerial fill:#090, color:#FFF
nodegraph1_image_color3 --> nodegraph1_output_color3
nodegraph1_place2d_vector2 --"texcoord"--> nodegraph1_image_color3
nodegraph1_texcoord_vector2 --"texcoord"--> nodegraph1_place2d_vector2
nodegraph1_output_color3 --"base_color"--> gltf_pbr_surfaceshader
gltf_pbr_surfaceshader --"surfaceshader"--> surfacematerial
</div></code></pre>


</td>
<td><a href="$TOP/tests/data/streams_images/gltf_simple_filetexture.mtlx">MTLX</a>
<a href="$TOP/tests/data/streams_images/gltf_simple_filetexture.gltf">GLTF</a>
<td><img src="$TOP/tests/data/streams_images/gltf_simple_filetexture.png">
</tr>

</table>

</details>
3 changes: 1 addition & 2 deletions documents/html/annotated.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@
<tr id="row_0_0_" class="odd"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span id="arr_0_0_" class="arrow" onclick="dynsection.toggleFolder('0_0_')">&#9660;</span><span class="icona"><span class="icon">N</span></span><a class="el" href="namespacegltf__materialx__converter_1_1converter.html" target="_self">converter</a></td><td class="desc"></td></tr>
<tr id="row_0_0_0_" class="even"><td class="entry"><span style="width:48px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html" target="_self">glTFMaterialXConverter</a></td><td class="desc">Class for converting to convert between glTF Texture Procedurals content and MaterialX </td></tr>
<tr id="row_0_1_" class="odd"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span id="arr_0_1_" class="arrow" onclick="dynsection.toggleFolder('0_1_')">&#9660;</span><span class="icona"><span class="icon">N</span></span><a class="el" href="namespacegltf__materialx__converter_1_1utilities.html" target="_self">utilities</a></td><td class="desc"></td></tr>
<tr id="row_0_1_0_" class="even"><td class="entry"><span style="width:48px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classgltf__materialx__converter_1_1utilities_1_1_mtlx_document_compare.html" target="_self">MtlxDocumentCompare</a></td><td class="desc">Class to compare two MaterialX documents </td></tr>
<tr id="row_0_1_1_" class="odd"><td class="entry"><span style="width:48px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classgltf__materialx__converter_1_1utilities_1_1_m_tlx_shading_model_translator.html" target="_self">MTlxShadingModelTranslator</a></td><td class="desc">Class to translate shading models within a MaterialX document </td></tr>
<tr id="row_0_1_0_" class="even"><td class="entry"><span style="width:48px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classgltf__materialx__converter_1_1utilities_1_1_mtlx_shading_model_translator.html" target="_self">MtlxShadingModelTranslator</a></td><td class="desc">Class to translate shading models within a MaterialX document </td></tr>
</table>
</div><!-- directory -->
</div><!-- contents -->
Expand Down
3 changes: 1 addition & 2 deletions documents/html/annotated_dup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ var annotated_dup =
[ "glTFMaterialXConverter", "classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html", "classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter" ]
] ],
[ "utilities", "namespacegltf__materialx__converter_1_1utilities.html", [
[ "MtlxDocumentCompare", "classgltf__materialx__converter_1_1utilities_1_1_mtlx_document_compare.html", "classgltf__materialx__converter_1_1utilities_1_1_mtlx_document_compare" ],
[ "MTlxShadingModelTranslator", "classgltf__materialx__converter_1_1utilities_1_1_m_tlx_shading_model_translator.html", "classgltf__materialx__converter_1_1utilities_1_1_m_tlx_shading_model_translator" ]
[ "MtlxShadingModelTranslator", "classgltf__materialx__converter_1_1utilities_1_1_mtlx_shading_model_translator.html", "classgltf__materialx__converter_1_1utilities_1_1_mtlx_shading_model_translator" ]
] ]
] ]
];
2 changes: 1 addition & 1 deletion documents/html/classes.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<dd><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">glTFMaterialXConverter</a> (<a class="el" href="namespacegltf__materialx__converter_1_1converter.html">gltf_materialx_converter.converter</a>)</dd></dl>
<dl class="classindex odd">
<dt class="alphachar"><a id="letter_M" name="letter_M">M</a></dt>
<dd><a class="el" href="classgltf__materialx__converter_1_1utilities_1_1_mtlx_document_compare.html">MtlxDocumentCompare</a> (<a class="el" href="namespacegltf__materialx__converter_1_1utilities.html">gltf_materialx_converter.utilities</a>)</dd><dd><a class="el" href="classgltf__materialx__converter_1_1utilities_1_1_m_tlx_shading_model_translator.html">MTlxShadingModelTranslator</a> (<a class="el" href="namespacegltf__materialx__converter_1_1utilities.html">gltf_materialx_converter.utilities</a>)</dd></dl>
<dd><a class="el" href="classgltf__materialx__converter_1_1utilities_1_1_mtlx_shading_model_translator.html">MtlxShadingModelTranslator</a> (<a class="el" href="namespacegltf__materialx__converter_1_1utilities.html">gltf_materialx_converter.utilities</a>)</dd></dl>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,18 @@
<p>This is the complete list of members for <a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a>, including all inherited members.</p>
<table class="directory">
<tr class="even"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#a876ab5a3ed460c0d503f743ac230d256">__init__</a>(self)</td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
<tr class="odd"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#a891ca10001b4621870d9f3b8b00ae531">array_types</a></td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
<tr class="odd"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#a0a28f13a847e1d3651015d52b010a4e3">addFallbackTexture</a>(self, json, fallback)</td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
<tr class="even"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#a281152b32096c9f00ae17dc76d115b25">getMetaData</a>(self)</td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
<tr class="odd"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#aa3398dc2465c52711c9a3619907ac72e">initializeGLTFTexture</a>(self, texture, name, uri, images)</td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
<tr class="even"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#a76d4a55f730d618932d8f4b1156010ab">logger</a></td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
<tr class="odd"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#a10b0e6e34c9b79cd37bc8734b730296e">materialXGraphToGLTF</a>(self, graph, json, materials)</td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
<tr class="even"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#a13dd4d09a0cda6a38b0290c9c2da64dc">materialXtoGLTF</a>(self, mtlxDoc)</td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
<tr class="odd"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#ae55050ea785c8c0b4c49294ebb1c26d3">set_debug</a>(self, debug)</td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
<tr class="even"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#a4a7697df181cc733606b98cf97de80e3">stringToScalar</a>(self, value, type)</td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
<tr class="odd"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#aca2b95f0687103c3df9421fd52fed809">materialXGraphToGLTF</a>(self, graph, json)</td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
<tr class="even"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#a777f89bb1d6aa44dab5f665308b4b2bf">materialXtoGLTF</a>(self, mtlx_doc)</td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
<tr class="odd"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#a122308eed2e043c1d2f1b5eb5e4a5538">setDebug</a>(self, debug)</td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
<tr class="even"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#aa2d09aaec15970dc73c4344e96ac9f1f">setMetaData</a>(self, metadata)</td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
<tr class="odd"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#a4a7697df181cc733606b98cf97de80e3">stringToScalar</a>(self, value, type)</td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
<tr class="even"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#a60bf670d7627233b6d9843bedb380174">supported_array_types</a></td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
<tr class="odd"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#afb374ea8e2ad8fd73f3b6c43ec88c653">supported_metadata</a></td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
<tr class="even"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#a76b36ec4ddab911fe626726108d480e6">supported_scalar_types</a></td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
<tr class="odd"><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html#a0e2ffcbc50f1981c660e9cbf51e829ac">supported_types</a></td><td class="entry"><a class="el" href="classgltf__materialx__converter_1_1converter_1_1gl_t_f_material_x_converter.html">gltf_materialx_converter.converter.glTFMaterialXConverter</a></td><td class="entry"></td></tr>
</table></div><!-- contents -->
</div><!-- doc-content -->
Expand Down
Loading

0 comments on commit 95cb2c7

Please sign in to comment.