Skip to content

Commit

Permalink
Create gltfMtlx.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
kwokcb committed Sep 29, 2023
1 parent 54533c6 commit d1fe7d8
Showing 1 changed file with 148 additions and 0 deletions.
148 changes: 148 additions & 0 deletions source/MaterialXglTF/gltfMtlx.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1.38.8\n"
]
}
],
"source": [
"import MaterialX as mx\n",
"\n",
"print(mx.__version__)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[\n",
" {\n",
" \"pbrMetallicRoughness\": {\n",
" \"baseColorTexture\": {\n",
" \"index\": 0\n",
" },\n",
" \"metallicRoughnessTexture\": {\n",
" \"index\": 1\n",
" }\n",
" },\n",
" \"normalTexture\": {\n",
" \"index\": 2\n",
" },\n",
" \"emissiveFactor\": [\n",
" 1.0,\n",
" 1.0,\n",
" 1.0\n",
" ],\n",
" \"emissiveTexture\": {\n",
" \"index\": 3\n",
" },\n",
" \"name\": \"M_BoomBox\"\n",
" },\n",
" {\n",
" \"pbrMetallicRoughness\": {\n",
" \"baseColorTexture\": {\n",
" \"index\": 4\n",
" },\n",
" \"metallicFactor\": 0.0,\n",
" \"roughnessFactor\": 0.735\n",
" },\n",
" \"name\": \"M_Coordinates\"\n",
" }\n",
"]\n"
]
}
],
"source": [
"import json\n",
"import os\n",
"\n",
"gltfFile = None\n",
"gltfFileName = '../../resources/glTF_import/BoomBoxWithAxes/glTF/BoomBoxWithAxes.gltf'\n",
"if os.path.exists(gltfFileName):\n",
" gltfFile = open(gltfFileName, 'r')\n",
"\n",
"gltfJson = None\n",
"if gltfFile:\n",
" gltfJson = json.load(gltfFile)\n",
"\n",
"materials = None\n",
"if gltfJson:\n",
" materials = gltfJson['materials']\n",
" #print(json.dumps(gltfJson, indent=2))\n",
" print(json.dumps(materials, indent=2))\n",
" #print(gltfJson['materials'])\n"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Scan material: M_BoomBox\n",
" pbrMetallicRoughness: {'baseColorTexture': {'index': 0}, 'metallicRoughnessTexture': {'index': 1}}\n",
" emissiveTexture: {'index': 3}\n",
" emissiveFactor: [1.0, 1.0, 1.0]\n",
"Scan material: M_Coordinates\n",
" pbrMetallicRoughness: {'baseColorTexture': {'index': 4}, 'metallicFactor': 0.0, 'roughnessFactor': 0.735}\n"
]
}
],
"source": [
"for material in materials:\n",
" print('Scan material: %s' % material['name'])\n",
" print(' pbrMetallicRoughness: %s' % material['pbrMetallicRoughness'])\n",
" #print(' normalTexture: %s' % material['normalTexture'])\n",
" #print(' occlusionTexture: %s' % material['occlusionTexture'])\n",
" if 'emissiveTexture' in material:\n",
" print(' emissiveTexture: %s' % material['emissiveTexture'])\n",
" if 'emissiveFactor' in material:\n",
" print(' emissiveFactor: %s' % material['emissiveFactor'])\n",
" #print(' alphaMode: %s' % material['alphaMode'])\n",
" #print(' alphaCutoff: %s' % material['alphaCutoff'])\n",
" #print(' doubleSided: %s' % material['doubleSided'])\n",
" #print(' extensions: %s' % material['extensions'])\n",
" #print(' extras: %s' % material['extras'])\n",
" #print(' name: %s' % material['name'])\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit d1fe7d8

Please sign in to comment.