diff --git a/README.html b/README.html index c2f154e..08b7cc3 100644 --- a/README.html +++ b/README.html @@ -407,6 +407,7 @@

Dependencies

  1. The MaterialX 1.39 or greater package for PhysicallyBased OpenPBR shader creation
  2. The requests package.
  3. +
  4. The pillow package for image handling for GPUOpen package handling

Building

The GitHub repository can be cloned and the package built using:

diff --git a/README.md b/README.md index 84ce56c..9bc74ae 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ The Python utilities require: 1. The MaterialX 1.39 or greater package for PhysicallyBased OpenPBR shader creation 2. The `requests` package. +3. The `pillow` package for image handling for GPUOpen package handling

Building

diff --git a/documents/html/_js_g_p_u_open_loader_8js_source.html b/documents/html/_js_g_p_u_open_loader_8js_source.html new file mode 100644 index 0000000..21c9ac2 --- /dev/null +++ b/documents/html/_js_g_p_u_open_loader_8js_source.html @@ -0,0 +1,256 @@ + + + + + + + +MaterialXMaterials: JsGPUOpenLoader.js Source File + + + + + + + + + + + + + + +
+
+ + + + + + +
+
MaterialXMaterials +  0.0.1 +
+
Utilities for retrieving materials from remote servers
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
JsGPUOpenLoader.js
+
+
+
+
2  constructor() {
+
3  this.rootUrl = 'https://api.matlib.gpuopen.com/api';
+
4  this.url = `${this.rootUrl}/materials`;
+
5  this.packageUrl = `${this.rootUrl}/packages`;
+
6  this.materials = null;
+
7 
+
8  this.logger = console;
+
9  }
+
10 
+
11  async getMaterials() {
+
12  /*
+
13  * Get the materials returned from the GPUOpen material database.
+
14  * Will loop based on the linked-list of materials stored in the database.
+
15  * Currently, the batch size requested is 100 materials per batch.
+
16  * @return: List of material lists
+
17  */
+
18 
+
19  this.materials = [];
+
20  this.materialNames = [];
+
21 
+
22  let url = this.url;
+
23  const headers = {
+
24  'Accept': 'application/json'
+
25  };
+
26 
+
27  // Get batches of materials. Start with the first 100.
+
28  let params = new URLSearchParams({
+
29  limit: 100,
+
30  offset: 0
+
31  });
+
32 
+
33  //url = 'https://api.physicallybased.info/materials'
+
34 
+
35  let haveMoreMaterials = true;
+
36  while (haveMoreMaterials)
+
37  {
+
38  try {
+
39  console.log('----- fetch url', url)
+
40  const response = //await fetch(`${url}?${params.toString()}`, { headers });
+
41  await fetch(url, {
+
42  mode: 'cors',
+
43  method: 'GET',
+
44  headers: headers,
+
45  params: {
+
46  'limit': 100,
+
47  'offset': 0
+
48  }
+
49  })
+
50  if (response.ok) {
+
51  const rawResponse = await response.text();
+
52 
+
53  // Split the response text assuming the JSON objects are concatenated
+
54  const jsonStrings = rawResponse.split('}{');
+
55  let jsonResultString = jsonStrings[0] + (jsonStrings.length > 1 ? '}' : '');
+
56  const jsonObject = JSON.parse(jsonResultString);
+
57  this.materials.push(jsonObject);
+
58  haveMoreMaterials = true;
+
59 
+
60  // Scan for next batch of materials
+
61  const nextQuery = jsonObject['next'];
+
62  if (nextQuery) {
+
63  // Get limit and offset from the query string
+
64  const queryParts = new URL(nextQuery).searchParams;
+
65  params = new URLSearchParams({
+
66  limit: queryParts.get('limit') || 100,
+
67  offset: queryParts.get('offset') || 0
+
68  });
+
69  this.logger.info(`Fetch set of materials: limit: ${params.get('limit')} offset: ${params.get('offset')}`);
+
70  } else {
+
71  haveMoreMaterials = false;
+
72  break;
+
73  }
+
74  } else {
+
75  this.logger.info(`Error: ${response.status}, ${await response.text()}`);
+
76  haveMoreMaterials = true;
+
77  }
+
78  } catch (error) {
+
79  this.logger.info(`Error: ${error.message}`);
+
80  haveMoreMaterials = true;
+
81  }
+
82 
+
83  break;
+
84  }
+
85 
+
86  return this.materials;
+
87  }
+
88 
+
89  async downloadPackage(listNumber, materialNumber, packageId = 0) {
+
90  if (this.materials === null || this.materials.length === 0) {
+
91  return [null, null];
+
92  }
+
93 
+
94  const jsonData = this.materials[listNumber];
+
95  if (!jsonData) {
+
96  return [null, null];
+
97  }
+
98 
+
99  let jsonResults = null;
+
100  let jsonResult = null;
+
101  if ('results' in jsonData) {
+
102  jsonResults = jsonData['results'];
+
103  if (jsonResults.length <= materialNumber) {
+
104  return [null, null];
+
105  } else {
+
106  jsonResult = jsonResults[materialNumber];
+
107  }
+
108  }
+
109 
+
110  if (!jsonResult) {
+
111  return [null, null];
+
112  }
+
113 
+
114  let jsonPackages = null;
+
115  if ('packages' in jsonResult) {
+
116  jsonPackages = jsonResult['packages'];
+
117  }
+
118  if (!jsonPackages) {
+
119  return [null, null];
+
120  }
+
121 
+
122  if (jsonPackages.length <= packageId) {
+
123  return [null, null];
+
124  }
+
125  const packageIdValue = jsonPackages[packageId];
+
126 
+
127  if (!packageIdValue) {
+
128  return [null, null];
+
129  }
+
130 
+
131  const url = `${this.packageUrl}/${packageIdValue}/download`;
+
132  const response = await fetch(url);
+
133  const data = await response.arrayBuffer();
+
134  const title = jsonResult['title'];
+
135  return [data, title];
+
136  }
+
137 
+
138  async downloadPackageByExpression(searchExpr, packageId = 0) {
+
139  const downloadList = [];
+
140 
+
141  const foundList = await this.findMaterialsByName(searchExpr);
+
142  if (foundList.length > 0) {
+
143  for (const found of foundList) {
+
144  const listNumber = found['listNumber'];
+
145  const materialNumber = found['materialNumber'];
+
146  const matName = found['title'];
+
147  this.logger.info(`> Download material: ${matName} List: ${listNumber}. Index: ${materialNumber}`);
+
148  const [data, title] = await this.downloadPackage(listNumber, materialNumber, packageId);
+
149  downloadList.push([data, title]);
+
150  }
+
151  }
+
152  return downloadList;
+
153  }
+
154 }
+ +
+
+ + + + diff --git a/documents/html/_js_material_x_physically_based_8js_source.html b/documents/html/_js_material_x_physically_based_8js_source.html index 21cbb27..c695197 100644 --- a/documents/html/_js_material_x_physically_based_8js_source.html +++ b/documents/html/_js_material_x_physically_based_8js_source.html @@ -170,242 +170,283 @@
149  //'metalness': 'metalness',
150  'ior': 'specular_IOR',
151  //'transmission': 'transmission',
-
152  'thinFilmIor': 'thin_film_IOR',
-
153  'thinFilmThickness': 'thin_film_thickness',
-
154  'transmissionDispersion': 'transmission_dispersion',
-
155  }
-
156  // Remap keys for OpenPBR shading model.
-
157  const openpbr_remapKeys = {
-
158  'color': 'base_color',
-
159  'specularColor': 'specular_color',
-
160  'roughness': 'specular_roughness', // 'base_diffuse_roughness',
-
161  'metalness': 'base_metalness',
-
162  'ior': 'specular_ior',
-
163  'transmission': 'transmission_weight',
-
164  'subsurfaceRadius': 'subsurface_radius',
-
165  'thinFilmIor': 'thinfilm_ior',
-
166  'thinFilmThickness': 'thinfilm_thickness',
-
167  'transmissionDispersion': 'transmission_dispersion_scale',
-
168  }
-
169  // Remap keys for Khronos glTF shading model.
-
170  const gltf_remapKeys = {
-
171  'color': 'base_color',
-
172  'specularColor': 'specular_color',
-
173  'roughness': 'roughness',
-
174  'metalness': 'metallic',
-
175  //'ior': 'ior',
-
176  //'transmission': 'transmission',
-
177  }
-
178 
-
179  this.remapMap = {}
-
180  this.remapMap['standard_surface'] = standard_surface_remapKeys;
-
181  this.remapMap['gltf_pbr'] = gltf_remapKeys;
-
182  this.remapMap['open_pbr_surface'] = openpbr_remapKeys;
-
183  }
-
184 
-
189  loadMaterialX()
-
190  {
-
191  return new Promise((resolve, reject) => {
-
192  MaterialX().then((mtlx) => {
-
193  this.mx = mtlx;
-
194  resolve();
-
195  }).catch((error) => {
-
196  reject(error);
-
197  });
-
198  });
-
199  }
-
200 
-
205  async getPhysicallyBasedMaterials()
-
206  {
-
207  try {
-
208  this.materials = null
-
209  this.materialNames = [];
-
210 
-
211  const response = await fetch(this.url, {
-
212  method: 'GET',
-
213  headers: this.headers
-
214  });
-
215 
-
216  if (!response.ok) {
-
217  throw new Error('Network response was not ok ' + response.statusText);
-
218  }
-
219 
-
220  this.materials = await response.json();
-
221  for (let i = 0; i < this.materials.length; i++) {
-
222  this.materialNames.push(this.materials[i]['name']);
-
223  }
-
224  return this.materials;
-
225  } catch (error) {
-
226  console.error('There has been a problem with your fetch operation:', error);
-
227  }
-
228 
-
229  return null;
-
230  }
-
231 
-
236  loadStandardLibraries()
-
237  {
-
238  if (!this.mx) {
-
239  // Call the asynchronous function and then perform additional logic
-
240  this.loadMaterialX().then(() => {
-
241 
-
242  this.esslgenerator = new this.mx.EsslShaderGenerator();
-
243  this.esslgenContext = new this.mx.GenContext(this.esslgenerator);
-
244  this.stdlib = this.mx.loadStandardLibraries(this.esslgenContext);
-
245  let children = this.stdlib.getChildren();
-
246  for (let i = 0; i < children.length; i++) {
-
247  let child = children[i];
-
248  child.setSourceUri('STDLIB_ELEMENT');
-
249  }
-
250 
-
251  console.log("MaterialX is loaded");
-
252  }).catch((error) => {
-
253  console.error("Error loading MaterialX:", error);
-
254  });
-
255  }
-
256  }
-
257 
-
263  skipLibraryElement(element)
-
264  {
-
265  return !elem.hasSourceUri()
-
266  }
-
267 
-
272  getMaterialXString()
-
273  {
-
274  if (!this.doc) {
-
275  console.error('No MaterialX document to convert');
-
276  return '';
-
277  }
-
278 
-
279  // Create write options
-
280  const writeOptions = new this.mx.XmlWriteOptions();
-
281  writeOptions.writeXIncludeEnable = false;
-
282  //writeOptions.writeXIncludes = false;
-
283  writeOptions.elementPredicate = this.skipLibraryElement;
-
284 
-
285  // Convert the MaterialX document to a string
-
286  const mtlx = this.mx.writeToXmlString(this.doc, writeOptions);
-
287  return mtlx;
-
288  }
-
289 
-
295  addComment(doc, commentString)
-
296  {
-
297  let comment = doc.addChildOfCategory('comment')
-
298  comment.setDocString(commentString)
-
299  }
-
300 
-
301 
-
311  convertToMaterialX(shaderCategory, addAllInputs = false, materialNames = [], remapKeys = {}, shaderPreFix = '')
-
312  {
-
313  if (!this.mx) {
-
314  console.error('MaterialX module is not loaded');
-
315  return false;
-
316  }
-
317 
-
318  if (!this.materials) {
-
319  console.warn('No Physically Based Materials to convert');
-
320  return false;
-
321  }
-
322 
-
323  if (remapKeys.length == 0) {
-
324  remapKeys = this.getInputRemapping(shaderCategory);
-
325  }
-
326 
-
327  // Create a dummy doc with the surface shader with all inputs
-
328  // as reference
-
329  let refDoc = this.mx.createDocument();
-
330  refDoc.importLibrary(this.stdlib);
-
331  const refNode = refDoc.addNode(shaderCategory, 'refShader', this.mx.SURFACE_SHADER_TYPE_STRING);
-
332  //refNode.addInputsFromNodeDef() -- This is missing from the JS API.
-
333  this.doc = this.mx.createDocument();
-
334 
-
335  // Add header comments
-
336  this.addComment(this.doc, 'Physically Based Materials from https://api.physicallybased.info ');
-
337  this.addComment(this.doc, ' Processed via API and converted to MaterialX ');
-
338  this.addComment(this.doc, ' Target Shading Model: ' + shaderCategory);
-
339  this.addComment(this.doc, ' Utility Author: Bernard Kwok. kwokcb@gmail.com ');
-
340 
-
341  // Add properties to the material
-
342  for (let i = 0; i < this.materials.length; i++) {
-
343  const mat = this.materials[i];
-
344  let matName = mat['name'];
-
345 
-
346  // Filter by material name(s)
-
347  if (materialNames.length > 0 && !materialNames.includes(matName)) {
-
348  // Skip material
-
349  console.log('Skipping material:', matName);
-
350  continue;
-
351  }
-
352 
-
353 
-
354  if (shaderPreFix.length > 0) {
-
355  matName = shaderPreFix + '_' + matName;
-
356  }
-
357 
-
358  const shaderName = this.doc.createValidChildName('SPB_' + matName);
-
359  this.addComment(this.doc, ' Generated shader: ' + shaderName + ' ');
-
360  const shaderNode = this.doc.addNode(shaderCategory, shaderName, this.mx.SURFACE_SHADER_TYPE_STRING);
-
361  let docString = mat['description'];
-
362  const refString = mat['reference'];
-
363  if (refString.length > 0) {
-
364  if (docString.length > 0) {
-
365  docString += '. ';
-
366  }
-
367  docString += 'Reference: ' + refString[0];
-
368  }
-
369  if (docString.length > 0) {
-
370  shaderNode.setDocString(docString);
-
371  }
-
372 
-
373  // Create a new material
-
374  const materialName = this.doc.createValidChildName('MPB_' + matName);
-
375  this.addComment(this.doc, ' Generated material: ' + materialName + ' ');
-
376  const materialNode = this.doc.addNode(this.mx.SURFACE_MATERIAL_NODE_STRING, materialName, this.mx.MATERIAL_TYPE_STRING);
-
377  const shaderInput = materialNode.addInput(this.mx.SURFACE_SHADER_TYPE_STRING, this.mx.SURFACE_SHADER_TYPE_STRING);
-
378  shaderInput.setAttribute(MTLX_NODE_NAME_ATTRIBUTE, shaderNode.getName());
-
379 
-
380  // Warning this is a bit bespoke for remapping keys
-
381  // to Autodesk Standard Surface shader inputs
-
382  const skipKeys = ['name', "density", "category", "description", "sources", "tags", "reference"];
-
383 
-
384  Object.entries(mat).forEach(([key, value]) => {
-
385  if (!skipKeys.includes(key)) {
-
386  if (remapKeys[key]) {
-
387  key = remapKeys[key];
-
388  }
-
389 
-
390  let refInput = refNode.getInput(key);
-
391  if (!refInput)
-
392  refInput = refNode.addInputFromNodeDef(key);
-
393  if (refInput) {
-
394  const input = shaderNode.addInput(key);
-
395  input.copyContentFrom(refInput);
-
396  if (input) {
-
397  // Convert number vector to string
-
398  if (Array.isArray(value)) {
-
399  value = value.join(',');
-
400  }
-
401  // Convert number to string
-
402  else if (typeof value === 'number') {
-
403  value = value.toString();
-
404  }
-
405  // Note: This API has side-effects as the
-
406  // type is set to "string" when the value is set. Thus
-
407  // we must explicitly set the type here.
-
408  input.setValueString(value, refInput.getType());
-
409  }
-
410  }
-
411  else {
-
412  //console.log('>>> Cannot create input:', key)
+
152  'transmission_color': 'transmission_color',
+
153  'thinFilmIor': 'thin_film_IOR',
+
154  'thinFilmThickness': 'thin_film_thickness',
+
155  'transmissionDispersion': 'transmission_dispersion',
+
156  }
+
157  // Remap keys for OpenPBR shading model.
+
158  const openpbr_remapKeys = {
+
159  'color': 'base_color',
+
160  'specularColor': 'specular_color',
+
161  'roughness': 'specular_roughness', // 'base_diffuse_roughness',
+
162  'metalness': 'base_metalness',
+
163  'ior': 'specular_ior',
+
164  'transmission': 'transmission_weight',
+
165  'transmission_color': 'transmission_color',
+
166  'subsurfaceRadius': 'subsurface_radius',
+
167  'thinFilmIor': 'thinfilm_ior',
+
168  'thinFilmThickness': 'thinfilm_thickness',
+
169  'transmissionDispersion': 'transmission_dispersion_scale',
+
170  }
+
171  // Remap keys for Khronos glTF shading model.
+
172  const gltf_remapKeys = {
+
173  'color': 'base_color',
+
174  'specularColor': 'specular_color',
+
175  'roughness': 'roughness',
+
176  'metalness': 'metallic',
+
177  //'ior': 'ior',
+
178  //'transmission': 'transmission',
+
179  }
+
180 
+
181  this.remapMap = {}
+
182  this.remapMap['standard_surface'] = standard_surface_remapKeys;
+
183  this.remapMap['gltf_pbr'] = gltf_remapKeys;
+
184  this.remapMap['open_pbr_surface'] = openpbr_remapKeys;
+
185  }
+
186 
+
191  loadMaterialX()
+
192  {
+
193  return new Promise((resolve, reject) => {
+
194  MaterialX().then((mtlx) => {
+
195  this.mx = mtlx;
+
196  resolve();
+
197  }).catch((error) => {
+
198  reject(error);
+
199  });
+
200  });
+
201  }
+
202 
+
207  async getPhysicallyBasedMaterials()
+
208  {
+
209  try {
+
210  this.materials = null
+
211  this.materialNames = [];
+
212 
+
213  const response = await fetch(this.url, {
+
214  method: 'GET',
+
215  headers: this.headers
+
216  });
+
217 
+
218  if (!response.ok) {
+
219  throw new Error('Network response was not ok ' + response.statusText);
+
220  }
+
221 
+
222  this.materials = await response.json();
+
223  for (let i = 0; i < this.materials.length; i++) {
+
224  this.materialNames.push(this.materials[i]['name']);
+
225  }
+
226  return this.materials;
+
227  } catch (error) {
+
228  console.error('There has been a problem with your fetch operation:', error);
+
229  }
+
230 
+
231  return null;
+
232  }
+
233 
+
238  loadStandardLibraries()
+
239  {
+
240  if (!this.mx) {
+
241  // Call the asynchronous function and then perform additional logic
+
242  this.loadMaterialX().then(() => {
+
243 
+
244  this.esslgenerator = new this.mx.EsslShaderGenerator();
+
245  this.esslgenContext = new this.mx.GenContext(this.esslgenerator);
+
246  this.stdlib = this.mx.loadStandardLibraries(this.esslgenContext);
+
247  let children = this.stdlib.getChildren();
+
248  for (let i = 0; i < children.length; i++) {
+
249  let child = children[i];
+
250  child.setSourceUri('STDLIB_ELEMENT');
+
251  }
+
252 
+
253  console.log("MaterialX is loaded");
+
254  }).catch((error) => {
+
255  console.error("Error loading MaterialX:", error);
+
256  });
+
257  }
+
258  }
+
259 
+
265  skipLibraryElement(element)
+
266  {
+
267  return !elem.hasSourceUri()
+
268  }
+
269 
+
274  getMaterialXString()
+
275  {
+
276  if (!this.doc) {
+
277  console.error('No MaterialX document to convert');
+
278  return '';
+
279  }
+
280 
+
281  // Create write options
+
282  const writeOptions = new this.mx.XmlWriteOptions();
+
283  writeOptions.writeXIncludeEnable = false;
+
284  //writeOptions.writeXIncludes = false;
+
285  writeOptions.elementPredicate = this.skipLibraryElement;
+
286 
+
287  // Convert the MaterialX document to a string
+
288  const mtlx = this.mx.writeToXmlString(this.doc, writeOptions);
+
289  return mtlx;
+
290  }
+
291 
+
297  addComment(doc, commentString)
+
298  {
+
299  let comment = doc.addChildOfCategory('comment')
+
300  comment.setDocString(commentString)
+
301  }
+
302 
+
303 
+
313  convertToMaterialX(shaderCategory, addAllInputs = false, materialNames = [], remapKeys = {}, shaderPreFix = '')
+
314  {
+
315  if (!this.mx) {
+
316  console.error('MaterialX module is not loaded');
+
317  return false;
+
318  }
+
319 
+
320  if (!this.materials) {
+
321  console.warn('No Physically Based Materials to convert');
+
322  return false;
+
323  }
+
324 
+
325  if (remapKeys.length == 0) {
+
326  remapKeys = this.getInputRemapping(shaderCategory);
+
327  }
+
328 
+
329  // Create a dummy doc with the surface shader with all inputs
+
330  // as reference
+
331  let refDoc = this.mx.createDocument();
+
332  refDoc.importLibrary(this.stdlib);
+
333  const refNode = refDoc.addNode(shaderCategory, 'refShader', this.mx.SURFACE_SHADER_TYPE_STRING);
+
334  //refNode.addInputsFromNodeDef() -- This is missing from the JS API.
+
335  this.doc = this.mx.createDocument();
+
336 
+
337  // Add header comments
+
338  this.addComment(this.doc, 'Physically Based Materials from https://api.physicallybased.info ');
+
339  this.addComment(this.doc, ' Processed via API and converted to MaterialX ');
+
340  this.addComment(this.doc, ' Target Shading Model: ' + shaderCategory);
+
341  this.addComment(this.doc, ' Utility Author: Bernard Kwok. kwokcb@gmail.com ');
+
342 
+
343  // Add properties to the material
+
344  for (let i = 0; i < this.materials.length; i++) {
+
345  const mat = this.materials[i];
+
346  let matName = mat['name'];
+
347 
+
348  // Filter by material name(s)
+
349  if (materialNames.length > 0 && !materialNames.includes(matName)) {
+
350  // Skip material
+
351  console.log('Skipping material:', matName);
+
352  continue;
+
353  }
+
354 
+
355 
+
356  if (shaderPreFix.length > 0) {
+
357  matName = shaderPreFix + '_' + matName;
+
358  }
+
359 
+
360  const shaderName = this.doc.createValidChildName('SPB_' + matName);
+
361  this.addComment(this.doc, ' Generated shader: ' + shaderName + ' ');
+
362  const shaderNode = this.doc.addNode(shaderCategory, shaderName, this.mx.SURFACE_SHADER_TYPE_STRING);
+
363  let docString = mat['description'];
+
364  const refString = mat['reference'];
+
365  if (refString.length > 0) {
+
366  if (docString.length > 0) {
+
367  docString += '. ';
+
368  }
+
369  docString += 'Reference: ' + refString[0];
+
370  }
+
371  if (docString.length > 0) {
+
372  shaderNode.setDocString(docString);
+
373  }
+
374 
+
375  // Create a new material
+
376  const materialName = this.doc.createValidChildName('MPB_' + matName);
+
377  this.addComment(this.doc, ' Generated material: ' + materialName + ' ');
+
378  const materialNode = this.doc.addNode(this.mx.SURFACE_MATERIAL_NODE_STRING, materialName, this.mx.MATERIAL_TYPE_STRING);
+
379  const shaderInput = materialNode.addInput(this.mx.SURFACE_SHADER_TYPE_STRING, this.mx.SURFACE_SHADER_TYPE_STRING);
+
380  shaderInput.setAttribute(MTLX_NODE_NAME_ATTRIBUTE, shaderNode.getName());
+
381 
+
382  // Warning this is a bit bespoke for remapping keys
+
383  // to Autodesk Standard Surface shader inputs
+
384  const skipKeys = ['name', "density", "category", "description", "sources", "tags", "reference"];
+
385 
+
386  let metallness = null;
+
387  let roughness = null;
+
388  let transmission_color = null;
+
389  let transmission = null;
+
390  Object.entries(mat).forEach(([key, value]) => {
+
391 
+
392  if (!skipKeys.includes(key)) {
+
393 
+
394  if (key == 'metalness') {
+
395  metallness = value;
+
396  //console.log('Metalness:', metallness);
+
397  }
+
398  if (key == 'roughness') {
+
399  roughness = value;
+
400  //console.log('Roughness:', roughness);
+
401  }
+
402  if (key == 'transmission') {
+
403  transmission = value;
+
404  //console.log('Transmission:', transmission);
+
405  }
+
406  if (key == 'color') {
+
407  transmission_color = value;
+
408  //console.log('Color:', color);
+
409  }
+
410 
+
411  if (remapKeys[key]) {
+
412  key = remapKeys[key];
413  }
-
414  }
-
415  });
-
416  }
-
417  return true;
-
418  }
-
419 
-
420 }
+
414 
+
415  let refInput = refNode.getInput(key);
+
416  if (!refInput)
+
417  refInput = refNode.addInputFromNodeDef(key);
+
418  if (refInput) {
+
419  const input = shaderNode.addInput(key);
+
420  input.copyContentFrom(refInput);
+
421  if (input) {
+
422  // Convert number vector to string
+
423  if (Array.isArray(value)) {
+
424  value = value.join(',');
+
425  }
+
426  // Convert number to string
+
427  else if (typeof value === 'number') {
+
428  value = value.toString();
+
429  }
+
430  // Note: This API has side-effects as the
+
431  // type is set to "string" when the value is set. Thus
+
432  // we must explicitly set the type here.
+
433  input.setValueString(value, refInput.getType());
+
434  }
+
435  }
+
436  else {
+
437  //console.log('>>> Cannot create input:', key)
+
438  }
+
439  }
+
440  });
+
441 
+
442  if (transmission !== null && metallness !== null && roughness !== null && transmission_color !== null)
+
443  {
+
444  if (metallness == 0 && roughness == 0)
+
445  {
+
446  if (remapKeys['transmission_color']) {
+
447  let inputName = remapKeys['transmission_color'];
+
448  let input = shaderNode.addInput(inputName);
+
449  if (input) {
+
450  let value = transmission_color.join(',');
+
451  console.log(`Add "${inputName}": "${value}"`);
+
452  input.setValueString(value, 'color3');
+
453  }
+
454  }
+
455  }
+
456  };
+
457  }
+
458  return true;
+
459  }
+
460 
+
461 }
JsPhysicallyBasedMaterialLoader
Javascript class for querying materials from the Physically Based database and creating MaterialX mat...
Definition: JsMaterialXPhysicallyBased.js:8
-
JsPhysicallyBasedMaterialLoader::skipLibraryElement
skipLibraryElement(element)
Predicate to skip library elements.
Definition: JsMaterialXPhysicallyBased.js:263
+
JsPhysicallyBasedMaterialLoader::skipLibraryElement
skipLibraryElement(element)
Predicate to skip library elements.
Definition: JsMaterialXPhysicallyBased.js:265
JsPhysicallyBasedMaterialLoader::doc
doc
Working MaterialX document.
Definition: JsMaterialXPhysicallyBased.js:43
JsPhysicallyBasedMaterialLoader::getJSONMaterialNames
getJSONMaterialNames()
Get list of the Physically Based Material names.
Definition: JsMaterialXPhysicallyBased.js:94
JsPhysicallyBasedMaterialLoader::initializeInputRemapping
initializeInputRemapping()
Initialize the input remapping for different shading models.
Definition: JsMaterialXPhysicallyBased.js:142
@@ -414,19 +455,19 @@
JsPhysicallyBasedMaterialLoader::getMaterialXDocument
getMaterialXDocument()
Get the MaterialX document.
Definition: JsMaterialXPhysicallyBased.js:102
JsPhysicallyBasedMaterialLoader::remapMap
remapMap
Remap keys for input values for different shading models.
Definition: JsMaterialXPhysicallyBased.js:53
JsPhysicallyBasedMaterialLoader::materials
materials
List of Physically Based Materials.
Definition: JsMaterialXPhysicallyBased.js:23
-
JsPhysicallyBasedMaterialLoader::loadStandardLibraries
loadStandardLibraries()
Load the MaterialX standard libraries.
Definition: JsMaterialXPhysicallyBased.js:236
+
JsPhysicallyBasedMaterialLoader::loadStandardLibraries
loadStandardLibraries()
Load the MaterialX standard libraries.
Definition: JsMaterialXPhysicallyBased.js:238
JsPhysicallyBasedMaterialLoader::constructor
constructor(mtlx_module=null, mtlx_stdlib=null)
Constructor for the PhysicallyBasedMaterialLoader.
Definition: JsMaterialXPhysicallyBased.js:60
-
JsPhysicallyBasedMaterialLoader::loadMaterialX
loadMaterialX()
Load the MaterialX module.
Definition: JsMaterialXPhysicallyBased.js:189
-
JsPhysicallyBasedMaterialLoader::getMaterialXString
getMaterialXString()
Get the MaterialX document as a string.
Definition: JsMaterialXPhysicallyBased.js:272
-
JsPhysicallyBasedMaterialLoader::getPhysicallyBasedMaterials
async getPhysicallyBasedMaterials()
Get the Physically Based Materials from the API.
Definition: JsMaterialXPhysicallyBased.js:205
+
JsPhysicallyBasedMaterialLoader::loadMaterialX
loadMaterialX()
Load the MaterialX module.
Definition: JsMaterialXPhysicallyBased.js:191
+
JsPhysicallyBasedMaterialLoader::getMaterialXString
getMaterialXString()
Get the MaterialX document as a string.
Definition: JsMaterialXPhysicallyBased.js:274
+
JsPhysicallyBasedMaterialLoader::getPhysicallyBasedMaterials
async getPhysicallyBasedMaterials()
Get the Physically Based Materials from the API.
Definition: JsMaterialXPhysicallyBased.js:207
JsPhysicallyBasedMaterialLoader::materialNames
materialNames
List of Physically Based Material names.
Definition: JsMaterialXPhysicallyBased.js:28
JsPhysicallyBasedMaterialLoader::mx
mx
MaterialX module.
Definition: JsMaterialXPhysicallyBased.js:38
JsPhysicallyBasedMaterialLoader::mxMaterialNames
mxMaterialNames
List of MaterialX Material names.
Definition: JsMaterialXPhysicallyBased.js:33
JsPhysicallyBasedMaterialLoader::headers
headers
Headers for the fetch operation.
Definition: JsMaterialXPhysicallyBased.js:18
JsPhysicallyBasedMaterialLoader::url
url
URL to fetch the Physically Based Materials.
Definition: JsMaterialXPhysicallyBased.js:13
JsPhysicallyBasedMaterialLoader::stdlib
stdlib
MaterialX standard libraries.
Definition: JsMaterialXPhysicallyBased.js:48
-
JsPhysicallyBasedMaterialLoader::convertToMaterialX
convertToMaterialX(shaderCategory, addAllInputs=false, materialNames=[], remapKeys={}, shaderPreFix='')
Convert the Physically Based Materials to MaterialX.
Definition: JsMaterialXPhysicallyBased.js:311
-
JsPhysicallyBasedMaterialLoader::addComment
addComment(doc, commentString)
Add a comment to the MaterialX document.
Definition: JsMaterialXPhysicallyBased.js:295
+
JsPhysicallyBasedMaterialLoader::convertToMaterialX
convertToMaterialX(shaderCategory, addAllInputs=false, materialNames=[], remapKeys={}, shaderPreFix='')
Convert the Physically Based Materials to MaterialX.
Definition: JsMaterialXPhysicallyBased.js:313
+
JsPhysicallyBasedMaterialLoader::addComment
addComment(doc, commentString)
Add a comment to the MaterialX document.
Definition: JsMaterialXPhysicallyBased.js:297
JsPhysicallyBasedMaterialLoader::validateDocument
validateDocument()
Validate the MaterialX document.
Definition: JsMaterialXPhysicallyBased.js:111
diff --git a/documents/html/annotated.html b/documents/html/annotated.html index bdbd192..8aa4625 100644 --- a/documents/html/annotated.html +++ b/documents/html/annotated.html @@ -95,9 +95,8 @@  CGPUOpenMaterialLoaderThis class is used to load materials from the GPUOpen material database  NphysicallyBasedMaterialXClass to load Physically Based Materials from the PhysicallyBased site  CPhysicallyBasedMaterialLoaderClass to load Physically Based Materials from the PhysicallyBased site - Nmyserver - CMyHTTPRequestHandler - CJsPhysicallyBasedMaterialLoaderJavascript class for querying materials from the Physically Based database and creating MaterialX materials + CGPUOpenMaterialLoader + CJsPhysicallyBasedMaterialLoaderJavascript class for querying materials from the Physically Based database and creating MaterialX materials diff --git a/documents/html/annotated_dup.js b/documents/html/annotated_dup.js index fdad55f..b7ea91a 100644 --- a/documents/html/annotated_dup.js +++ b/documents/html/annotated_dup.js @@ -8,8 +8,6 @@ var annotated_dup = [ "PhysicallyBasedMaterialLoader", "classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html", "classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader" ] ] ] ] ], - [ "myserver", null, [ - [ "MyHTTPRequestHandler", "classmyserver_1_1_my_h_t_t_p_request_handler.html", "classmyserver_1_1_my_h_t_t_p_request_handler" ] - ] ], + [ "GPUOpenMaterialLoader", "class_g_p_u_open_material_loader.html", "class_g_p_u_open_material_loader" ], [ "JsPhysicallyBasedMaterialLoader", "class_js_physically_based_material_loader.html", "class_js_physically_based_material_loader" ] ]; \ No newline at end of file diff --git a/documents/html/bc_sd.png b/documents/html/bc_sd.png new file mode 100644 index 0000000..31ca888 Binary files /dev/null and b/documents/html/bc_sd.png differ diff --git a/documents/html/class_g_p_u_open_material_loader-members.html b/documents/html/class_g_p_u_open_material_loader-members.html new file mode 100644 index 0000000..c1d9bb9 --- /dev/null +++ b/documents/html/class_g_p_u_open_material_loader-members.html @@ -0,0 +1,107 @@ + + + + + + + +MaterialXMaterials: Member List + + + + + + + + + + + + + + +
+
+ + + + + + +
+
MaterialXMaterials +  0.0.1 +
+
Utilities for retrieving materials from remote servers
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
GPUOpenMaterialLoader Member List
+
+
+ +

This is the complete list of members for GPUOpenMaterialLoader, including all inherited members.

+ + + + + +
constructor() (defined in GPUOpenMaterialLoader)GPUOpenMaterialLoader
downloadPackage(listNumber, materialNumber, packageId=0) (defined in GPUOpenMaterialLoader)GPUOpenMaterialLoader
downloadPackageByExpression(searchExpr, packageId=0) (defined in GPUOpenMaterialLoader)GPUOpenMaterialLoader
getMaterials() (defined in GPUOpenMaterialLoader)GPUOpenMaterialLoader
+
+ + + + diff --git a/documents/html/class_g_p_u_open_material_loader.html b/documents/html/class_g_p_u_open_material_loader.html new file mode 100644 index 0000000..18e301a --- /dev/null +++ b/documents/html/class_g_p_u_open_material_loader.html @@ -0,0 +1,126 @@ + + + + + + + +MaterialXMaterials: GPUOpenMaterialLoader Class Reference + + + + + + + + + + + + + + +
+
+ + + + + + +
+
MaterialXMaterials +  0.0.1 +
+
Utilities for retrieving materials from remote servers
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
GPUOpenMaterialLoader Class Reference
+
+
+ + + + + + + + + + +

+Public Member Functions

constructor ()
 
+async getMaterials ()
 
+async downloadPackage (listNumber, materialNumber, packageId=0)
 
+async downloadPackageByExpression (searchExpr, packageId=0)
 
+

Detailed Description

+
+

Definition at line 1 of file JsGPUOpenLoader.js.

+

The documentation for this class was generated from the following file: +
+
+ + + + diff --git a/documents/html/class_g_p_u_open_material_loader.js b/documents/html/class_g_p_u_open_material_loader.js new file mode 100644 index 0000000..d4448af --- /dev/null +++ b/documents/html/class_g_p_u_open_material_loader.js @@ -0,0 +1,7 @@ +var class_g_p_u_open_material_loader = +[ + [ "constructor", "class_g_p_u_open_material_loader.html#a4155c2fcf6b2c38088f85c63e933aef9", null ], + [ "downloadPackage", "class_g_p_u_open_material_loader.html#ae420983c6072cceb216459ed5ab2a2aa", null ], + [ "downloadPackageByExpression", "class_g_p_u_open_material_loader.html#a44ccdf25c1654dd628e8351889298e83", null ], + [ "getMaterials", "class_g_p_u_open_material_loader.html#aa20236461b74f2fd756649fa63757f05", null ] +]; \ No newline at end of file diff --git a/documents/html/class_js_physically_based_material_loader.html b/documents/html/class_js_physically_based_material_loader.html index afc0bd2..e5d5bc6 100644 --- a/documents/html/class_js_physically_based_material_loader.html +++ b/documents/html/class_js_physically_based_material_loader.html @@ -222,11 +222,11 @@

Definition at line 295 of file JsMaterialXPhysicallyBased.js.

-
296  {
-
297  let comment = doc.addChildOfCategory('comment')
-
298  comment.setDocString(commentString)
-
299  }
+

Definition at line 297 of file JsMaterialXPhysicallyBased.js.

+
298  {
+
299  let comment = doc.addChildOfCategory('comment')
+
300  comment.setDocString(commentString)
+
301  }
@@ -349,117 +349,156 @@

Returns
True if the conversion is successful. False otherwise
-

Definition at line 311 of file JsMaterialXPhysicallyBased.js.

-
311  {}, shaderPreFix = '')
-
312  {
-
313  if (!this.mx) {
-
314  console.error('MaterialX module is not loaded');
-
315  return false;
-
316  }
-
317 
-
318  if (!this.materials) {
-
319  console.warn('No Physically Based Materials to convert');
-
320  return false;
-
321  }
-
322 
-
323  if (remapKeys.length == 0) {
-
324  remapKeys = this.getInputRemapping(shaderCategory);
-
325  }
-
326 
-
327  // Create a dummy doc with the surface shader with all inputs
-
328  // as reference
-
329  let refDoc = this.mx.createDocument();
-
330  refDoc.importLibrary(this.stdlib);
-
331  const refNode = refDoc.addNode(shaderCategory, 'refShader', this.mx.SURFACE_SHADER_TYPE_STRING);
-
332  //refNode.addInputsFromNodeDef() -- This is missing from the JS API.
-
333  this.doc = this.mx.createDocument();
-
334 
-
335  // Add header comments
-
336  this.addComment(this.doc, 'Physically Based Materials from https://api.physicallybased.info ');
-
337  this.addComment(this.doc, ' Processed via API and converted to MaterialX ');
-
338  this.addComment(this.doc, ' Target Shading Model: ' + shaderCategory);
-
339  this.addComment(this.doc, ' Utility Author: Bernard Kwok. kwokcb@gmail.com ');
-
340 
-
341  // Add properties to the material
-
342  for (let i = 0; i < this.materials.length; i++) {
-
343  const mat = this.materials[i];
-
344  let matName = mat['name'];
-
345 
-
346  // Filter by material name(s)
-
347  if (materialNames.length > 0 && !materialNames.includes(matName)) {
-
348  // Skip material
-
349  console.log('Skipping material:', matName);
-
350  continue;
-
351  }
-
352 
-
353 
-
354  if (shaderPreFix.length > 0) {
-
355  matName = shaderPreFix + '_' + matName;
-
356  }
-
357 
-
358  const shaderName = this.doc.createValidChildName('SPB_' + matName);
-
359  this.addComment(this.doc, ' Generated shader: ' + shaderName + ' ');
-
360  const shaderNode = this.doc.addNode(shaderCategory, shaderName, this.mx.SURFACE_SHADER_TYPE_STRING);
-
361  let docString = mat['description'];
-
362  const refString = mat['reference'];
-
363  if (refString.length > 0) {
-
364  if (docString.length > 0) {
-
365  docString += '. ';
-
366  }
-
367  docString += 'Reference: ' + refString[0];
-
368  }
-
369  if (docString.length > 0) {
-
370  shaderNode.setDocString(docString);
-
371  }
-
372 
-
373  // Create a new material
-
374  const materialName = this.doc.createValidChildName('MPB_' + matName);
-
375  this.addComment(this.doc, ' Generated material: ' + materialName + ' ');
-
376  const materialNode = this.doc.addNode(this.mx.SURFACE_MATERIAL_NODE_STRING, materialName, this.mx.MATERIAL_TYPE_STRING);
-
377  const shaderInput = materialNode.addInput(this.mx.SURFACE_SHADER_TYPE_STRING, this.mx.SURFACE_SHADER_TYPE_STRING);
-
378  shaderInput.setAttribute(MTLX_NODE_NAME_ATTRIBUTE, shaderNode.getName());
-
379 
-
380  // Warning this is a bit bespoke for remapping keys
-
381  // to Autodesk Standard Surface shader inputs
-
382  const skipKeys = ['name', "density", "category", "description", "sources", "tags", "reference"];
-
383 
-
384  Object.entries(mat).forEach(([key, value]) => {
-
385  if (!skipKeys.includes(key)) {
-
386  if (remapKeys[key]) {
-
387  key = remapKeys[key];
-
388  }
-
389 
-
390  let refInput = refNode.getInput(key);
-
391  if (!refInput)
-
392  refInput = refNode.addInputFromNodeDef(key);
-
393  if (refInput) {
-
394  const input = shaderNode.addInput(key);
-
395  input.copyContentFrom(refInput);
-
396  if (input) {
-
397  // Convert number vector to string
-
398  if (Array.isArray(value)) {
-
399  value = value.join(',');
-
400  }
-
401  // Convert number to string
-
402  else if (typeof value === 'number') {
-
403  value = value.toString();
-
404  }
-
405  // Note: This API has side-effects as the
-
406  // type is set to "string" when the value is set. Thus
-
407  // we must explicitly set the type here.
-
408  input.setValueString(value, refInput.getType());
-
409  }
-
410  }
-
411  else {
-
412  //console.log('>>> Cannot create input:', key)
+

Definition at line 313 of file JsMaterialXPhysicallyBased.js.

+
313  {}, shaderPreFix = '')
+
314  {
+
315  if (!this.mx) {
+
316  console.error('MaterialX module is not loaded');
+
317  return false;
+
318  }
+
319 
+
320  if (!this.materials) {
+
321  console.warn('No Physically Based Materials to convert');
+
322  return false;
+
323  }
+
324 
+
325  if (remapKeys.length == 0) {
+
326  remapKeys = this.getInputRemapping(shaderCategory);
+
327  }
+
328 
+
329  // Create a dummy doc with the surface shader with all inputs
+
330  // as reference
+
331  let refDoc = this.mx.createDocument();
+
332  refDoc.importLibrary(this.stdlib);
+
333  const refNode = refDoc.addNode(shaderCategory, 'refShader', this.mx.SURFACE_SHADER_TYPE_STRING);
+
334  //refNode.addInputsFromNodeDef() -- This is missing from the JS API.
+
335  this.doc = this.mx.createDocument();
+
336 
+
337  // Add header comments
+
338  this.addComment(this.doc, 'Physically Based Materials from https://api.physicallybased.info ');
+
339  this.addComment(this.doc, ' Processed via API and converted to MaterialX ');
+
340  this.addComment(this.doc, ' Target Shading Model: ' + shaderCategory);
+
341  this.addComment(this.doc, ' Utility Author: Bernard Kwok. kwokcb@gmail.com ');
+
342 
+
343  // Add properties to the material
+
344  for (let i = 0; i < this.materials.length; i++) {
+
345  const mat = this.materials[i];
+
346  let matName = mat['name'];
+
347 
+
348  // Filter by material name(s)
+
349  if (materialNames.length > 0 && !materialNames.includes(matName)) {
+
350  // Skip material
+
351  console.log('Skipping material:', matName);
+
352  continue;
+
353  }
+
354 
+
355 
+
356  if (shaderPreFix.length > 0) {
+
357  matName = shaderPreFix + '_' + matName;
+
358  }
+
359 
+
360  const shaderName = this.doc.createValidChildName('SPB_' + matName);
+
361  this.addComment(this.doc, ' Generated shader: ' + shaderName + ' ');
+
362  const shaderNode = this.doc.addNode(shaderCategory, shaderName, this.mx.SURFACE_SHADER_TYPE_STRING);
+
363  let docString = mat['description'];
+
364  const refString = mat['reference'];
+
365  if (refString.length > 0) {
+
366  if (docString.length > 0) {
+
367  docString += '. ';
+
368  }
+
369  docString += 'Reference: ' + refString[0];
+
370  }
+
371  if (docString.length > 0) {
+
372  shaderNode.setDocString(docString);
+
373  }
+
374 
+
375  // Create a new material
+
376  const materialName = this.doc.createValidChildName('MPB_' + matName);
+
377  this.addComment(this.doc, ' Generated material: ' + materialName + ' ');
+
378  const materialNode = this.doc.addNode(this.mx.SURFACE_MATERIAL_NODE_STRING, materialName, this.mx.MATERIAL_TYPE_STRING);
+
379  const shaderInput = materialNode.addInput(this.mx.SURFACE_SHADER_TYPE_STRING, this.mx.SURFACE_SHADER_TYPE_STRING);
+
380  shaderInput.setAttribute(MTLX_NODE_NAME_ATTRIBUTE, shaderNode.getName());
+
381 
+
382  // Warning this is a bit bespoke for remapping keys
+
383  // to Autodesk Standard Surface shader inputs
+
384  const skipKeys = ['name', "density", "category", "description", "sources", "tags", "reference"];
+
385 
+
386  let metallness = null;
+
387  let roughness = null;
+
388  let transmission_color = null;
+
389  let transmission = null;
+
390  Object.entries(mat).forEach(([key, value]) => {
+
391 
+
392  if (!skipKeys.includes(key)) {
+
393 
+
394  if (key == 'metalness') {
+
395  metallness = value;
+
396  //console.log('Metalness:', metallness);
+
397  }
+
398  if (key == 'roughness') {
+
399  roughness = value;
+
400  //console.log('Roughness:', roughness);
+
401  }
+
402  if (key == 'transmission') {
+
403  transmission = value;
+
404  //console.log('Transmission:', transmission);
+
405  }
+
406  if (key == 'color') {
+
407  transmission_color = value;
+
408  //console.log('Color:', color);
+
409  }
+
410 
+
411  if (remapKeys[key]) {
+
412  key = remapKeys[key];
413  }
-
414  }
-
415  });
-
416  }
-
417  return true;
-
418  }
+
414 
+
415  let refInput = refNode.getInput(key);
+
416  if (!refInput)
+
417  refInput = refNode.addInputFromNodeDef(key);
+
418  if (refInput) {
+
419  const input = shaderNode.addInput(key);
+
420  input.copyContentFrom(refInput);
+
421  if (input) {
+
422  // Convert number vector to string
+
423  if (Array.isArray(value)) {
+
424  value = value.join(',');
+
425  }
+
426  // Convert number to string
+
427  else if (typeof value === 'number') {
+
428  value = value.toString();
+
429  }
+
430  // Note: This API has side-effects as the
+
431  // type is set to "string" when the value is set. Thus
+
432  // we must explicitly set the type here.
+
433  input.setValueString(value, refInput.getType());
+
434  }
+
435  }
+
436  else {
+
437  //console.log('>>> Cannot create input:', key)
+
438  }
+
439  }
+
440  });
+
441 
+
442  if (transmission !== null && metallness !== null && roughness !== null && transmission_color !== null)
+
443  {
+
444  if (metallness == 0 && roughness == 0)
+
445  {
+
446  if (remapKeys['transmission_color']) {
+
447  let inputName = remapKeys['transmission_color'];
+
448  let input = shaderNode.addInput(inputName);
+
449  if (input) {
+
450  let value = transmission_color.join(',');
+
451  console.log(`Add "${inputName}": "${value}"`);
+
452  input.setValueString(value, 'color3');
+
453  }
+
454  }
+
455  }
+
456  };
+
457  }
+
458  return true;
+
459  }
getInputRemapping(shadingModel)
Get the remapping keys for a given shading model.
-
addComment(doc, commentString)
Add a comment to the MaterialX document.
+
addComment(doc, commentString)
Add a comment to the MaterialX document.
@@ -542,24 +581,24 @@

Returns
{string} - MaterialX document as a string. Empty string if no document
-

Definition at line 272 of file JsMaterialXPhysicallyBased.js.

-
273  {
-
274  if (!this.doc) {
-
275  console.error('No MaterialX document to convert');
-
276  return '';
-
277  }
-
278 
-
279  // Create write options
-
280  const writeOptions = new this.mx.XmlWriteOptions();
-
281  writeOptions.writeXIncludeEnable = false;
-
282  //writeOptions.writeXIncludes = false;
-
283  writeOptions.elementPredicate = this.skipLibraryElement;
-
284 
-
285  // Convert the MaterialX document to a string
-
286  const mtlx = this.mx.writeToXmlString(this.doc, writeOptions);
-
287  return mtlx;
-
288  }
-
skipLibraryElement(element)
Predicate to skip library elements.
+

Definition at line 274 of file JsMaterialXPhysicallyBased.js.

+
275  {
+
276  if (!this.doc) {
+
277  console.error('No MaterialX document to convert');
+
278  return '';
+
279  }
+
280 
+
281  // Create write options
+
282  const writeOptions = new this.mx.XmlWriteOptions();
+
283  writeOptions.writeXIncludeEnable = false;
+
284  //writeOptions.writeXIncludes = false;
+
285  writeOptions.elementPredicate = this.skipLibraryElement;
+
286 
+
287  // Convert the MaterialX document to a string
+
288  const mtlx = this.mx.writeToXmlString(this.doc, writeOptions);
+
289  return mtlx;
+
290  }
+
skipLibraryElement(element)
Predicate to skip library elements.
@@ -581,32 +620,32 @@

Returns
{object[]} - List of Physically Based Materials in JSON format
-

Definition at line 205 of file JsMaterialXPhysicallyBased.js.

-
206  {
-
207  try {
-
208  this.materials = null
-
209  this.materialNames = [];
-
210 
-
211  const response = await fetch(this.url, {
-
212  method: 'GET',
-
213  headers: this.headers
-
214  });
-
215 
-
216  if (!response.ok) {
-
217  throw new Error('Network response was not ok ' + response.statusText);
-
218  }
-
219 
-
220  this.materials = await response.json();
-
221  for (let i = 0; i < this.materials.length; i++) {
-
222  this.materialNames.push(this.materials[i]['name']);
-
223  }
-
224  return this.materials;
-
225  } catch (error) {
-
226  console.error('There has been a problem with your fetch operation:', error);
-
227  }
-
228 
-
229  return null;
-
230  }
+

Definition at line 207 of file JsMaterialXPhysicallyBased.js.

+
208  {
+
209  try {
+
210  this.materials = null
+
211  this.materialNames = [];
+
212 
+
213  const response = await fetch(this.url, {
+
214  method: 'GET',
+
215  headers: this.headers
+
216  });
+
217 
+
218  if (!response.ok) {
+
219  throw new Error('Network response was not ok ' + response.statusText);
+
220  }
+
221 
+
222  this.materials = await response.json();
+
223  for (let i = 0; i < this.materials.length; i++) {
+
224  this.materialNames.push(this.materials[i]['name']);
+
225  }
+
226  return this.materials;
+
227  } catch (error) {
+
228  console.error('There has been a problem with your fetch operation:', error);
+
229  }
+
230 
+
231  return null;
+
232  }
@@ -638,38 +677,40 @@

149  //'metalness': 'metalness',
150  'ior': 'specular_IOR',
151  //'transmission': 'transmission',
-
152  'thinFilmIor': 'thin_film_IOR',
-
153  'thinFilmThickness': 'thin_film_thickness',
-
154  'transmissionDispersion': 'transmission_dispersion',
-
155  }
-
156  // Remap keys for OpenPBR shading model.
-
157  const openpbr_remapKeys = {
-
158  'color': 'base_color',
-
159  'specularColor': 'specular_color',
-
160  'roughness': 'specular_roughness', // 'base_diffuse_roughness',
-
161  'metalness': 'base_metalness',
-
162  'ior': 'specular_ior',
-
163  'transmission': 'transmission_weight',
-
164  'subsurfaceRadius': 'subsurface_radius',
-
165  'thinFilmIor': 'thinfilm_ior',
-
166  'thinFilmThickness': 'thinfilm_thickness',
-
167  'transmissionDispersion': 'transmission_dispersion_scale',
-
168  }
-
169  // Remap keys for Khronos glTF shading model.
-
170  const gltf_remapKeys = {
-
171  'color': 'base_color',
-
172  'specularColor': 'specular_color',
-
173  'roughness': 'roughness',
-
174  'metalness': 'metallic',
-
175  //'ior': 'ior',
-
176  //'transmission': 'transmission',
-
177  }
-
178 
-
179  this.remapMap = {}
-
180  this.remapMap['standard_surface'] = standard_surface_remapKeys;
-
181  this.remapMap['gltf_pbr'] = gltf_remapKeys;
-
182  this.remapMap['open_pbr_surface'] = openpbr_remapKeys;
-
183  }
+
152  'transmission_color': 'transmission_color',
+
153  'thinFilmIor': 'thin_film_IOR',
+
154  'thinFilmThickness': 'thin_film_thickness',
+
155  'transmissionDispersion': 'transmission_dispersion',
+
156  }
+
157  // Remap keys for OpenPBR shading model.
+
158  const openpbr_remapKeys = {
+
159  'color': 'base_color',
+
160  'specularColor': 'specular_color',
+
161  'roughness': 'specular_roughness', // 'base_diffuse_roughness',
+
162  'metalness': 'base_metalness',
+
163  'ior': 'specular_ior',
+
164  'transmission': 'transmission_weight',
+
165  'transmission_color': 'transmission_color',
+
166  'subsurfaceRadius': 'subsurface_radius',
+
167  'thinFilmIor': 'thinfilm_ior',
+
168  'thinFilmThickness': 'thinfilm_thickness',
+
169  'transmissionDispersion': 'transmission_dispersion_scale',
+
170  }
+
171  // Remap keys for Khronos glTF shading model.
+
172  const gltf_remapKeys = {
+
173  'color': 'base_color',
+
174  'specularColor': 'specular_color',
+
175  'roughness': 'roughness',
+
176  'metalness': 'metallic',
+
177  //'ior': 'ior',
+
178  //'transmission': 'transmission',
+
179  }
+
180 
+
181  this.remapMap = {}
+
182  this.remapMap['standard_surface'] = standard_surface_remapKeys;
+
183  this.remapMap['gltf_pbr'] = gltf_remapKeys;
+
184  this.remapMap['open_pbr_surface'] = openpbr_remapKeys;
+
185  }
@@ -691,17 +732,17 @@

Returns
{Promise} - Promise to load the MaterialX module
-

Definition at line 189 of file JsMaterialXPhysicallyBased.js.

-
190  {
-
191  return new Promise((resolve, reject) => {
-
192  MaterialX().then((mtlx) => {
-
193  this.mx = mtlx;
-
194  resolve();
-
195  }).catch((error) => {
-
196  reject(error);
-
197  });
-
198  });
-
199  }
+

Definition at line 191 of file JsMaterialXPhysicallyBased.js.

+
192  {
+
193  return new Promise((resolve, reject) => {
+
194  MaterialX().then((mtlx) => {
+
195  this.mx = mtlx;
+
196  resolve();
+
197  }).catch((error) => {
+
198  reject(error);
+
199  });
+
200  });
+
201  }
@@ -723,28 +764,28 @@

Returns
{void}
-

Definition at line 236 of file JsMaterialXPhysicallyBased.js.

-
237  {
-
238  if (!this.mx) {
-
239  // Call the asynchronous function and then perform additional logic
-
240  this.loadMaterialX().then(() => {
-
241 
-
242  this.esslgenerator = new this.mx.EsslShaderGenerator();
-
243  this.esslgenContext = new this.mx.GenContext(this.esslgenerator);
-
244  this.stdlib = this.mx.loadStandardLibraries(this.esslgenContext);
-
245  let children = this.stdlib.getChildren();
-
246  for (let i = 0; i < children.length; i++) {
-
247  let child = children[i];
-
248  child.setSourceUri('STDLIB_ELEMENT');
-
249  }
-
250 
-
251  console.log("MaterialX is loaded");
-
252  }).catch((error) => {
-
253  console.error("Error loading MaterialX:", error);
-
254  });
-
255  }
-
256  }
-
loadMaterialX()
Load the MaterialX module.
+

Definition at line 238 of file JsMaterialXPhysicallyBased.js.

+
239  {
+
240  if (!this.mx) {
+
241  // Call the asynchronous function and then perform additional logic
+
242  this.loadMaterialX().then(() => {
+
243 
+
244  this.esslgenerator = new this.mx.EsslShaderGenerator();
+
245  this.esslgenContext = new this.mx.GenContext(this.esslgenerator);
+
246  this.stdlib = this.mx.loadStandardLibraries(this.esslgenContext);
+
247  let children = this.stdlib.getChildren();
+
248  for (let i = 0; i < children.length; i++) {
+
249  let child = children[i];
+
250  child.setSourceUri('STDLIB_ELEMENT');
+
251  }
+
252 
+
253  console.log("MaterialX is loaded");
+
254  }).catch((error) => {
+
255  console.error("Error loading MaterialX:", error);
+
256  });
+
257  }
+
258  }
+
loadMaterialX()
Load the MaterialX module.
@@ -773,10 +814,10 @@

Returns
True if the element is a library element. False otherwise
-

Definition at line 263 of file JsMaterialXPhysicallyBased.js.

-
264  {
-
265  return !elem.hasSourceUri()
-
266  }
+

Definition at line 265 of file JsMaterialXPhysicallyBased.js.

+
266  {
+
267  return !elem.hasSourceUri()
+
268  }
diff --git a/documents/html/classes.html b/documents/html/classes.html index 6f27620..ff630eb 100644 --- a/documents/html/classes.html +++ b/documents/html/classes.html @@ -88,18 +88,15 @@
Class Index
-
G | J | M | P
+
G | J | P
diff --git a/documents/html/classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html b/documents/html/classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html index b936c0f..bdb6a85 100644 --- a/documents/html/classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html +++ b/documents/html/classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html @@ -325,17 +325,17 @@

Returns
None
-

Definition at line 263 of file physicallyBasedMaterialX.py.

-
263  def addComment(self, doc, commentString):
-
264  '''
-
265  @brief Add a comment to the MaterialX document
-
266  @param doc The MaterialX document to add the comment to
-
267  @param commentString The comment string to add
-
268  @return None
-
269  '''
-
270  comment = doc.addChildOfCategory('comment')
-
271  comment.setDocString(commentString)
-
272 
+

Definition at line 265 of file physicallyBasedMaterialX.py.

+
265  def addComment(self, doc, commentString):
+
266  '''
+
267  @brief Add a comment to the MaterialX document
+
268  @param doc The MaterialX document to add the comment to
+
269  @param commentString The comment string to add
+
270  @return None
+
271  '''
+
272  comment = doc.addChildOfCategory('comment')
+
273  comment.setDocString(commentString)
+
274 

@@ -395,97 +395,121 @@

Returns
The MaterialX document
-

Definition at line 273 of file physicallyBasedMaterialX.py.

-
274  remapKeys = {}, shaderPreFix ='') -> mx.Document:
-
275  '''
-
276  @brief Convert the Physically Based Materials to MaterialX format for a given target shading model.
-
277  @param materialNames The list of material names to convert. If empty, all materials will be converted.
-
278  @param shaderCategory The target shading model to convert to. Default is 'standard_surface'.
-
279  @param remapKeys The remapping keys for the target shading model. If empty, the default remapping keys will be used.
-
280  @param shaderPreFix The prefix to add to the shader name. Default is an empty string.
-
281  @return The MaterialX document
-
282  '''
-
283  if not self.mx:
-
284  self.logger.critical(f'> {self._getMethodName()}: MaterialX module is required')
-
285  return None
-
286 
-
287  if not self.support_openpbr and shaderCategory == 'open_pbr_surface':
-
288  self.logger.warning(f'> OpenPBR shading model not supported in MaterialX version {self.mx.getVersionString()}')
-
289  return None
-
290 
-
291  if not self.materials:
-
292  self.logger.info('> No materials to convert')
-
293  return None
-
294 
-
295  if len(remapKeys) == 0:
-
296  remapKeys = self.getInputRemapping(shaderCategory)
-
297  if len(remapKeys) == 0:
-
298  self.logger.warning(f'> No remapping keys found for shading model: {shaderCategory}')
-
299 
-
300  # Create main document and import the library document
-
301  self.doc = self.mx.createDocument()
-
302  self.doc.importLibrary(self.stdlib)
-
303 
-
304  # Add header comments
-
305  self.addComment(self.doc, 'Physically Based Materials from https://api.physicallybased.info ')
-
306  self.addComment(self.doc, ' Processsed via API and converted to MaterialX ')
-
307  self.addComment(self.doc, ' Target Shading Model: ' + shaderCategory)
-
308  self.addComment(self.doc, ' Utility Author: Bernard Kwok. kwokcb@gmail.com ')
-
309 
-
310  # Add properties to the material
-
311  for mat in self.materials:
-
312  matName = mat['name']
-
313 
-
314  # Filter by material name(s)
-
315  if len(materialNames) > 0 and matName not in materialNames:
-
316  #self.logger.debug('Skip material: ' + matName)
-
317  continue
-
318 
-
319  if (len(shaderPreFix) > 0):
-
320  matName = shaderPreFix + '_' + matName
-
321 
-
322  shaderName = self.doc.createValidChildName('SHD_PBM_' + matName)
-
323  self.addComment(self.doc, ' Generated shader: ' + shaderName + ' ')
-
324  shaderNode = self.doc.addNode(shaderCategory, shaderName, self.mx.SURFACE_SHADER_TYPE_STRING)
-
325  docString = mat['description']
-
326  refString = mat['reference']
-
327  if len(refString) > 0:
-
328  if len(docString) > 0:
-
329  docString += '. '
-
330  docString += 'Reference: ' + refString[0]
-
331  if len(docString) > 0:
-
332  shaderNode.setDocString(docString)
-
333  #shaderNode.addInputsFromNodeDef()
-
334  #shaderNode.setAttribute(self.mx.InterfaceElement.NODE_DEF_ATTRIBUTE, nodedefString)
-
335 
-
336  # Create a new material
-
337  materialName = self.doc.createValidChildName('MAT_PBM_' + matName)
-
338  self.addComment(self.doc, ' Generated material: ' + materialName + ' ')
-
339  materialNode = self.doc.addNode(self.mx.SURFACE_MATERIAL_NODE_STRING, materialName, self.mx.MATERIAL_TYPE_STRING)
-
340  shaderInput = materialNode.addInput(self.mx.SURFACE_SHADER_TYPE_STRING, self.mx.SURFACE_SHADER_TYPE_STRING)
-
341  shaderInput.setAttribute(self.MTLX_NODE_NAME_ATTRIBUTE, shaderNode.getName())
-
342 
-
343  # Keys to skip.
-
344  skipKeys = ['name', "density", "category", "description", "sources", "tags", "reference"]
-
345 
-
346  for key, value in mat.items():
-
347  if (key not in skipKeys):
-
348  if key in remapKeys:
-
349  key = remapKeys[key]
-
350  input = shaderNode.addInputFromNodeDef(key)
-
351  if input:
-
352  # Convert number vector to string
-
353  if isinstance(value, list):
-
354  value = ','.join([str(x) for x in value])
-
355  # Convert number to string:
-
356  elif isinstance(value, (int, float)):
-
357  value = str(value)
-
358  input.setValueString(value)
-
359  #else:
-
360  # self.logger.debug('Skip unsupported key: ' + key)
-
361 
-
362  return self.doc
-
363 
+

Definition at line 275 of file physicallyBasedMaterialX.py.

+
276  remapKeys = {}, shaderPreFix ='') -> mx.Document:
+
277  '''
+
278  @brief Convert the Physically Based Materials to MaterialX format for a given target shading model.
+
279  @param materialNames The list of material names to convert. If empty, all materials will be converted.
+
280  @param shaderCategory The target shading model to convert to. Default is 'standard_surface'.
+
281  @param remapKeys The remapping keys for the target shading model. If empty, the default remapping keys will be used.
+
282  @param shaderPreFix The prefix to add to the shader name. Default is an empty string.
+
283  @return The MaterialX document
+
284  '''
+
285  if not self.mx:
+
286  self.logger.critical(f'> {self._getMethodName()}: MaterialX module is required')
+
287  return None
+
288 
+
289  if not self.support_openpbr and shaderCategory == 'open_pbr_surface':
+
290  self.logger.warning(f'> OpenPBR shading model not supported in MaterialX version {self.mx.getVersionString()}')
+
291  return None
+
292 
+
293  if not self.materials:
+
294  self.logger.info('> No materials to convert')
+
295  return None
+
296 
+
297  if len(remapKeys) == 0:
+
298  remapKeys = self.getInputRemapping(shaderCategory)
+
299  if len(remapKeys) == 0:
+
300  self.logger.warning(f'> No remapping keys found for shading model: {shaderCategory}')
+
301 
+
302  # Create main document and import the library document
+
303  self.doc = self.mx.createDocument()
+
304  self.doc.importLibrary(self.stdlib)
+
305 
+
306  # Add header comments
+
307  self.addComment(self.doc, 'Physically Based Materials from https://api.physicallybased.info ')
+
308  self.addComment(self.doc, ' Processsed via API and converted to MaterialX ')
+
309  self.addComment(self.doc, ' Target Shading Model: ' + shaderCategory)
+
310  self.addComment(self.doc, ' Utility Author: Bernard Kwok. kwokcb@gmail.com ')
+
311 
+
312  # Add properties to the material
+
313  for mat in self.materials:
+
314  matName = mat['name']
+
315 
+
316  # Filter by material name(s)
+
317  if len(materialNames) > 0 and matName not in materialNames:
+
318  #self.logger.debug('Skip material: ' + matName)
+
319  continue
+
320 
+
321  if (len(shaderPreFix) > 0):
+
322  matName = matName + '_' + shaderPreFix
+
323 
+
324  shaderName = self.doc.createValidChildName(matName + '_SHD_PBM')
+
325  self.addComment(self.doc, ' Generated shader: ' + shaderName + ' ')
+
326  shaderNode = self.doc.addNode(shaderCategory, shaderName, self.mx.SURFACE_SHADER_TYPE_STRING)
+
327  docString = mat['description']
+
328  refString = mat['reference']
+
329  if len(refString) > 0:
+
330  if len(docString) > 0:
+
331  docString += '. '
+
332  docString += 'Reference: ' + refString[0]
+
333  if len(docString) > 0:
+
334  shaderNode.setDocString(docString)
+
335  #shaderNode.addInputsFromNodeDef()
+
336  #shaderNode.setAttribute(self.mx.InterfaceElement.NODE_DEF_ATTRIBUTE, nodedefString)
+
337 
+
338  # Create a new material
+
339  materialName = self.doc.createValidChildName(matName + '_MAT_PBM')
+
340  self.addComment(self.doc, ' Generated material: ' + materialName + ' ')
+
341  materialNode = self.doc.addNode(self.mx.SURFACE_MATERIAL_NODE_STRING, materialName, self.mx.MATERIAL_TYPE_STRING)
+
342  shaderInput = materialNode.addInput(self.mx.SURFACE_SHADER_TYPE_STRING, self.mx.SURFACE_SHADER_TYPE_STRING)
+
343  shaderInput.setAttribute(self.MTLX_NODE_NAME_ATTRIBUTE, shaderNode.getName())
+
344 
+
345  # Keys to skip.
+
346  skipKeys = ['name', "density", "category", "description", "sources", "tags", "reference"]
+
347 
+
348  metallness = None
+
349  roughness = None
+
350  color = None
+
351  transmission = None
+
352  for key, value in mat.items():
+
353 
+
354  if (key not in skipKeys):
+
355  if key == 'metalness':
+
356  metallness = value
+
357  if key == 'roughness':
+
358  roughness = value
+
359  if key == 'transmission':
+
360  transmission = value
+
361  if key == 'color':
+
362  color = value
+
363 
+
364  if key in remapKeys:
+
365  key = remapKeys[key]
+
366  input = shaderNode.addInputFromNodeDef(key)
+
367  if input:
+
368  # Convert number vector to string
+
369  if isinstance(value, list):
+
370  value = ','.join([str(x) for x in value])
+
371  # Convert number to string:
+
372  elif isinstance(value, (int, float)):
+
373  value = str(value)
+
374  input.setValueString(value)
+
375  #else:
+
376  # self.logger.debug('Skip unsupported key: ' + key)
+
377 
+
378  if (transmission != None) and (metallness != None) and (roughness != None) and (color != None):
+
379  if (metallness == 0) and (roughness == 0):
+
380  if 'transmission_color' in remapKeys:
+
381  key = remapKeys['transmission_color']
+
382  input = shaderNode.addInputFromNodeDef(key)
+
383  if input:
+
384  self.logger.debug(f'Set transmission color {key}: {color}')
+
385  value = ','.join([str(x) for x in color])
+
386  input.setValueString(value)
+
387 
+
388  return self.doc
+
389 
@@ -508,21 +532,21 @@

Returns
The MaterialX document as a string
-

Definition at line 379 of file physicallyBasedMaterialX.py.

-
379  def convertToMaterialXString(self):
-
380  '''
-
381  @brief Convert the MaterialX document to a string
-
382  @return The MaterialX document as a string
-
383  '''
-
384  if not self.mx:
-
385  self.logger.critical(f'> {self._getMethodName()}: MaterialX module is required')
-
386  return
-
387 
-
388  writeOptions = self.mx.XmlWriteOptions()
-
389  writeOptions.writeXIncludeEnable = False
-
390  writeOptions.elementPredicate = self.skipLibraryElement
-
391  mtlx = self.mx.writeToXmlString(self.doc, writeOptions)
-
392  return mtlx
+

Definition at line 405 of file physicallyBasedMaterialX.py.

+
405  def convertToMaterialXString(self):
+
406  '''
+
407  @brief Convert the MaterialX document to a string
+
408  @return The MaterialX document as a string
+
409  '''
+
410  if not self.mx:
+
411  self.logger.critical(f'> {self._getMethodName()}: MaterialX module is required')
+
412  return
+
413 
+
414  writeOptions = self.mx.XmlWriteOptions()
+
415  writeOptions.writeXIncludeEnable = False
+
416  writeOptions.elementPredicate = self.skipLibraryElement
+
417  mtlx = self.mx.writeToXmlString(self.doc, writeOptions)
+
418  return mtlx
@@ -596,14 +620,14 @@

Returns
The list of material names
-

Definition at line 132 of file physicallyBasedMaterialX.py.

-
132  def getJSONMaterialNames(self) -> list:
-
133  '''
-
134  Get the list of material names from the JSON object
-
135  @return The list of material names
-
136  '''
-
137  return self.materialNames
-
138 
+

Definition at line 134 of file physicallyBasedMaterialX.py.

+
134  def getJSONMaterialNames(self) -> list:
+
135  '''
+
136  Get the list of material names from the JSON object
+
137  @return The list of material names
+
138  '''
+
139  return self.materialNames
+
140 
@@ -626,32 +650,32 @@

Returns
The JSON object representing the Physically Based Materials
-

Definition at line 179 of file physicallyBasedMaterialX.py.

-
179  def getMaterialsFromURL(self) -> dict:
-
180  '''
-
181  @brief Get the Physically Based Materials from the PhysicallyBased site
-
182  @return The JSON object representing the Physically Based Materials
-
183  '''
-
184 
-
185  self.materials = None
-
186  self.materialNames = []
-
187  url = self.uri
-
188  headers = {
-
189  'Accept': 'application/json'
-
190  }
-
191 
-
192  response = requests.get(url, headers=headers)
+

Definition at line 181 of file physicallyBasedMaterialX.py.

+
181  def getMaterialsFromURL(self) -> dict:
+
182  '''
+
183  @brief Get the Physically Based Materials from the PhysicallyBased site
+
184  @return The JSON object representing the Physically Based Materials
+
185  '''
+
186 
+
187  self.materials = None
+
188  self.materialNames = []
+
189  url = self.uri
+
190  headers = {
+
191  'Accept': 'application/json'
+
192  }
193 
-
194  if response.status_code == HTTPStatus.OK:
-
195  self.materials = response.json()
-
196  for mat in self.materials:
-
197  self.materialNames.append(mat['name'])
-
198 
-
199  else:
-
200  self.logger.error(f'> Status: {response.status_code}, {response.text}')
-
201 
-
202  return self.materials
-
203 
+
194  response = requests.get(url, headers=headers)
+
195 
+
196  if response.status_code == HTTPStatus.OK:
+
197  self.materials = response.json()
+
198  for mat in self.materials:
+
199  self.materialNames.append(mat['name'])
+
200 
+
201  else:
+
202  self.logger.error(f'> Status: {response.status_code}, {response.text}')
+
203 
+
204  return self.materials
+
205 
@@ -674,14 +698,14 @@

Returns
The MaterialX document
-

Definition at line 139 of file physicallyBasedMaterialX.py.

-
139  def getMaterialXDocument(self) -> mx.Document:
-
140  '''
-
141  Get the MaterialX document
-
142  @return The MaterialX document
-
143  '''
-
144  return self.doc
-
145 
+

Definition at line 141 of file physicallyBasedMaterialX.py.

+
141  def getMaterialXDocument(self) -> mx.Document:
+
142  '''
+
143  Get the MaterialX document
+
144  @return The MaterialX document
+
145  '''
+
146  return self.doc
+
147 
@@ -727,39 +751,41 @@

92  #'metalness': 'metalness',
93  'ior': 'specular_IOR',
94  #'transmission': 'transmission',
-
95  'thinFilmIor' : 'thin_film_IOR',
-
96  'thinFilmThickness' : 'thin_film_thickness',
-
97  'transmissionDispersion' : 'transmission_dispersion',
-
98  }
-
99  # Remap keys for OpenPBR shading model.
-
100  openpbr_remapKeys = {
-
101  'color': 'base_color',
-
102  'specularColor': 'specular_color',
-
103  'roughness': 'specular_roughness', # 'base_diffuse_roughness',
-
104  'metalness': 'base_metalness',
-
105  'ior': 'specular_ior',
-
106  'transmission': 'transmission_weight',
-
107  'subsurfaceRadius': 'subsurface_radius',
-
108  'thinFilmIor' : 'thinfilm_ior',
-
109  'thinFilmThickness' : 'thinfilm_thickness',
-
110  'transmissionDispersion' : 'transmission_dispersion_scale',
-
111  }
-
112  # Remap keys for Khronos glTF shading model.
-
113  gltf_remapKeys = {
-
114  'color': 'base_color',
-
115  'specularColor': 'specular_color',
-
116  'roughness': 'roughness',
-
117  'metalness': 'metallic',
-
118  #'ior': 'ior',
-
119  #'transmission': 'transmission',
-
120  }
-
121 
-
122  self.remapMap = {}
-
123  self.remapMap['standard_surface'] = standard_surface_remapKeys;
-
124  self.remapMap['gltf_pbr'] = gltf_remapKeys;
-
125  if self.support_openpbr:
-
126  self.remapMap['open_pbr_surface'] = openpbr_remapKeys;
-
127 
+
95  'transmission_color': 'transmission_color',
+
96  'thinFilmIor' : 'thin_film_IOR',
+
97  'thinFilmThickness' : 'thin_film_thickness',
+
98  'transmissionDispersion' : 'transmission_dispersion',
+
99  }
+
100  # Remap keys for OpenPBR shading model.
+
101  openpbr_remapKeys = {
+
102  'color': 'base_color',
+
103  'specularColor': 'specular_color',
+
104  'roughness': 'specular_roughness', # 'base_diffuse_roughness',
+
105  'metalness': 'base_metalness',
+
106  'ior': 'specular_ior',
+
107  'transmission': 'transmission_weight',
+
108  'transmission_color': 'transmission_color',
+
109  'subsurfaceRadius': 'subsurface_radius',
+
110  'thinFilmIor' : 'thinfilm_ior',
+
111  'thinFilmThickness' : 'thinfilm_thickness',
+
112  'transmissionDispersion' : 'transmission_dispersion_scale',
+
113  }
+
114  # Remap keys for Khronos glTF shading model.
+
115  gltf_remapKeys = {
+
116  'color': 'base_color',
+
117  'specularColor': 'specular_color',
+
118  'roughness': 'roughness',
+
119  'metalness': 'metallic',
+
120  #'ior': 'ior',
+
121  #'transmission': 'transmission',
+
122  }
+
123 
+
124  self.remapMap = {}
+
125  self.remapMap['standard_surface'] = standard_surface_remapKeys;
+
126  self.remapMap['gltf_pbr'] = gltf_remapKeys;
+
127  if self.support_openpbr:
+
128  self.remapMap['open_pbr_surface'] = openpbr_remapKeys;
+
129 
@@ -798,26 +824,26 @@

Returns
The JSON object representing the Physically Based Materials
-

Definition at line 146 of file physicallyBasedMaterialX.py.

-
146  def loadMaterialsFromFile(self, fileName) -> dict:
-
147  '''
-
148  @brief Load the Physically Based Materials from a JSON file
-
149  @param fileName The filename to load the JSON file from
-
150  @return The JSON object representing the Physically Based Materials
-
151  '''
-
152  self.materials = None
-
153  self.materialNames = []
-
154  if not os.path.exists(fileName):
-
155  self.logger.error(f'> File does not exist: {fileName}')
-
156  return None
-
157 
-
158  with open(fileName, 'r') as json_file:
-
159  self.materials = json.load(json_file)
-
160  for mat in self.materials:
-
161  self.materialNames.append(mat['name'])
-
162 
-
163  return self.materials
-
164 
+

Definition at line 148 of file physicallyBasedMaterialX.py.

+
148  def loadMaterialsFromFile(self, fileName) -> dict:
+
149  '''
+
150  @brief Load the Physically Based Materials from a JSON file
+
151  @param fileName The filename to load the JSON file from
+
152  @return The JSON object representing the Physically Based Materials
+
153  '''
+
154  self.materials = None
+
155  self.materialNames = []
+
156  if not os.path.exists(fileName):
+
157  self.logger.error(f'> File does not exist: {fileName}')
+
158  return None
+
159 
+
160  with open(fileName, 'r') as json_file:
+
161  self.materials = json.load(json_file)
+
162  for mat in self.materials:
+
163  self.materialNames.append(mat['name'])
+
164 
+
165  return self.materials
+
166 
@@ -856,21 +882,21 @@

Returns
The JSON object representing the Physically Based Materials
-

Definition at line 165 of file physicallyBasedMaterialX.py.

-
165  def loadMaterialsFromString(self, matString) -> dict:
-
166  '''
-
167  @brief Load the Physically Based Materials from a JSON string
-
168  @param matString The JSON string to load the Physically Based Materials from
-
169  @return The JSON object representing the Physically Based Materials
-
170  '''
-
171  self.materials = None
-
172  self.materialNames = []
-
173  self.materials = json.loads(matString)
-
174  for mat in self.materials:
-
175  self.materialNames.append(mat['name'])
-
176 
-
177  return self.materials
+

Definition at line 167 of file physicallyBasedMaterialX.py.

+
167  def loadMaterialsFromString(self, matString) -> dict:
+
168  '''
+
169  @brief Load the Physically Based Materials from a JSON string
+
170  @param matString The JSON string to load the Physically Based Materials from
+
171  @return The JSON object representing the Physically Based Materials
+
172  '''
+
173  self.materials = None
+
174  self.materialNames = []
+
175  self.materials = json.loads(matString)
+
176  for mat in self.materials:
+
177  self.materialNames.append(mat['name'])
178 
+
179  return self.materials
+
180 
@@ -893,19 +919,19 @@

Returns
None
-

Definition at line 204 of file physicallyBasedMaterialX.py.

-
204  def printMaterials(self):
-
205  '''
-
206  @brief Print the materials to the console
-
207  @return None
-
208  '''
-
209  for mat in self.materials:
-
210  self.logger.info('Material name: ' + mat['name'])
-
211  # Print out each key and value
-
212  for key, value in mat.items():
-
213  if (key != 'name' and value):
-
214  self.logger.info(f'> - {key}: {value}')
-
215 
+

Definition at line 206 of file physicallyBasedMaterialX.py.

+
206  def printMaterials(self):
+
207  '''
+
208  @brief Print the materials to the console
+
209  @return None
+
210  '''
+
211  for mat in self.materials:
+
212  self.logger.info('Material name: ' + mat['name'])
+
213  # Print out each key and value
+
214  for key, value in mat.items():
+
215  if (key != 'name' and value):
+
216  self.logger.info(f'> - {key}: {value}')
+
217 
@@ -986,14 +1012,14 @@

Returns
True if the element is not in a library, otherwise False.
-

Definition at line 233 of file physicallyBasedMaterialX.py.

-
233  def skipLibraryElement(elem) -> bool:
-
234  '''
-
235  @brief Utility to skip library elements when iterating over elements in a document.
-
236  @return True if the element is not in a library, otherwise False.
-
237  '''
-
238  return not elem.hasSourceUri()
-
239 
+

Definition at line 235 of file physicallyBasedMaterialX.py.

+
235  def skipLibraryElement(elem) -> bool:
+
236  '''
+
237  @brief Utility to skip library elements when iterating over elements in a document.
+
238  @return True if the element is not in a library, otherwise False.
+
239  '''
+
240  return not elem.hasSourceUri()
+
241 
@@ -1032,24 +1058,24 @@

Returns
A tuple of (valid, errors) where valid is True if the document is valid, and errors is a list of errors if the document is invalid.
-

Definition at line 246 of file physicallyBasedMaterialX.py.

-
246  def validateMaterialXDocument(self, doc):
-
247  '''
-
248  @brief Validate the MaterialX document
-
249  @param doc The MaterialX document to validate
-
250  @return A tuple of (valid, errors) where valid is True if the document is valid, and errors is a list of errors if the document is invalid.
-
251  '''
-
252  if not self.mx:
-
253  self.logger.critical(f'> {self._getMethodName()}: MaterialX module is required')
-
254  return False, ''
-
255 
-
256  if not doc:
-
257  self.logger.warning(f'> {self._getMethodName()}: MaterialX document is required')
-
258  return False, ''
-
259 
-
260  valid, errors = doc.validate()
-
261  return valid, errors
-
262 
+

Definition at line 248 of file physicallyBasedMaterialX.py.

+
248  def validateMaterialXDocument(self, doc):
+
249  '''
+
250  @brief Validate the MaterialX document
+
251  @param doc The MaterialX document to validate
+
252  @return A tuple of (valid, errors) where valid is True if the document is valid, and errors is a list of errors if the document is invalid.
+
253  '''
+
254  if not self.mx:
+
255  self.logger.critical(f'> {self._getMethodName()}: MaterialX module is required')
+
256  return False, ''
+
257 
+
258  if not doc:
+
259  self.logger.warning(f'> {self._getMethodName()}: MaterialX document is required')
+
260  return False, ''
+
261 
+
262  valid, errors = doc.validate()
+
263  return valid, errors
+
264 
@@ -1088,23 +1114,23 @@

Returns
True if the file was written successfully, otherwise False
-

Definition at line 216 of file physicallyBasedMaterialX.py.

-
216  def writeJSONToFile(self, filename):
-
217  '''
-
218  @brief Write the materials to a JSON file
-
219  @param filename The filename to write the JSON file to
-
220  @return True if the file was written successfully, otherwise False
-
221  '''
-
222  if not self.materials:
-
223  self.logger.warning('No materials to write')
-
224  return False
-
225 
-
226  with open(filename, 'w') as json_file:
-
227  json.dump(self.materials, json_file, indent=4)
-
228  return True
-
229 
-
230  return False
-
231 
+

Definition at line 218 of file physicallyBasedMaterialX.py.

+
218  def writeJSONToFile(self, filename):
+
219  '''
+
220  @brief Write the materials to a JSON file
+
221  @param filename The filename to write the JSON file to
+
222  @return True if the file was written successfully, otherwise False
+
223  '''
+
224  if not self.materials:
+
225  self.logger.warning('No materials to write')
+
226  return False
+
227 
+
228  with open(filename, 'w') as json_file:
+
229  json.dump(self.materials, json_file, indent=4)
+
230  return True
+
231 
+
232  return False
+
233 
@@ -1143,22 +1169,22 @@

Returns
None
-

Definition at line 364 of file physicallyBasedMaterialX.py.

-
364  def writeMaterialXToFile(self, filename):
-
365  '''
-
366  @brief Write the MaterialX document to disk
-
367  @param filename The filename to write the MaterialX document to
-
368  @return None
-
369  '''
-
370  if not self.mx:
-
371  self.logger.critical(f'> {self._getMethodName()}: MaterialX module is required')
-
372  return
-
373 
-
374  writeOptions = self.mx.XmlWriteOptions()
-
375  writeOptions.writeXIncludeEnable = False
-
376  writeOptions.elementPredicate = self.skipLibraryElement
-
377  self.mx.writeToXmlFile(self.doc, filename, writeOptions)
-
378 
+

Definition at line 390 of file physicallyBasedMaterialX.py.

+
390  def writeMaterialXToFile(self, filename):
+
391  '''
+
392  @brief Write the MaterialX document to disk
+
393  @param filename The filename to write the MaterialX document to
+
394  @return None
+
395  '''
+
396  if not self.mx:
+
397  self.logger.critical(f'> {self._getMethodName()}: MaterialX module is required')
+
398  return
+
399 
+
400  writeOptions = self.mx.XmlWriteOptions()
+
401  writeOptions.writeXIncludeEnable = False
+
402  writeOptions.elementPredicate = self.skipLibraryElement
+
403  self.mx.writeToXmlFile(self.doc, filename, writeOptions)
+
404 
diff --git a/documents/html/classmyserver_1_1_my_h_t_t_p_request_handler-members.html b/documents/html/classmyserver_1_1_my_h_t_t_p_request_handler-members.html index cb16657..91ec9a8 100644 --- a/documents/html/classmyserver_1_1_my_h_t_t_p_request_handler-members.html +++ b/documents/html/classmyserver_1_1_my_h_t_t_p_request_handler-members.html @@ -1,9 +1,9 @@ - + - - + + MaterialXMaterials: Member List @@ -24,10 +24,9 @@
- - + @@ -36,21 +35,22 @@
-
MaterialXMaterials -  0.0.1 +
+
MaterialXMaterials 0.0.1
Utilities for retrieving materials from remote servers
- + +/* @license-end */ +
@@ -64,7 +64,7 @@
@@ -78,14 +78,20 @@
- +
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
-
-
myserver.MyHTTPRequestHandler Member List
+
myserver.MyHTTPRequestHandler Member List
@@ -97,7 +103,7 @@ diff --git a/documents/html/classmyserver_1_1_my_h_t_t_p_request_handler.html b/documents/html/classmyserver_1_1_my_h_t_t_p_request_handler.html index 2a396e1..8d3531f 100644 --- a/documents/html/classmyserver_1_1_my_h_t_t_p_request_handler.html +++ b/documents/html/classmyserver_1_1_my_h_t_t_p_request_handler.html @@ -1,9 +1,9 @@ - + - - + + MaterialXMaterials: myserver.MyHTTPRequestHandler Class Reference @@ -24,10 +24,9 @@
- - + @@ -36,21 +35,22 @@
-
MaterialXMaterials -  0.0.1 +
+
MaterialXMaterials 0.0.1
Utilities for retrieving materials from remote servers
- + +/* @license-end */ +
@@ -64,7 +64,7 @@
@@ -78,17 +78,23 @@
- +
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
-
-
myserver.MyHTTPRequestHandler Class Reference
+
myserver.MyHTTPRequestHandler Class Reference
@@ -98,16 +104,42 @@
- - +

+

Public Member Functions

-def end_headers (self)
def end_headers (self)
 

Detailed Description

Definition at line 7 of file myserver.py.

-

The documentation for this class was generated from the following file:
    +

    Member Function Documentation

    + +

    ◆ end_headers()

    + +
    +
    + + + + + + + + +
    def myserver.MyHTTPRequestHandler.end_headers ( self)
    +
    + +

    Definition at line 8 of file myserver.py.

    +
    8 def end_headers(self):
    +
    9 self.send_header("Cache-Control", "no-cache, no-store, must-revalidate")
    +
    10 self.send_header("Pragma", "no-cache")
    +
    11 self.send_header("Expires", "0")
    +
    12 super().end_headers()
    +
    13
    +
    +
    +
    +
    The documentation for this class was generated from the following file: @@ -116,7 +148,7 @@ diff --git a/documents/html/classmyserver_1_1_my_h_t_t_p_request_handler.png b/documents/html/classmyserver_1_1_my_h_t_t_p_request_handler.png index fdd0259..453e2a2 100644 Binary files a/documents/html/classmyserver_1_1_my_h_t_t_p_request_handler.png and b/documents/html/classmyserver_1_1_my_h_t_t_p_request_handler.png differ diff --git a/documents/html/dir_0e7a2bf207642fde32bb2644c27b5ffb.js b/documents/html/dir_0e7a2bf207642fde32bb2644c27b5ffb.js new file mode 100644 index 0000000..e277716 --- /dev/null +++ b/documents/html/dir_0e7a2bf207642fde32bb2644c27b5ffb.js @@ -0,0 +1,4 @@ +var dir_0e7a2bf207642fde32bb2644c27b5ffb = +[ + [ "JsMaterialXPhysicallyBased.js", "_js_material_x_physically_based_8js_source.html", null ] +]; \ No newline at end of file diff --git a/documents/html/dir_68267d1309a1af8e8297ef4c3efbcdba.js b/documents/html/dir_68267d1309a1af8e8297ef4c3efbcdba.js new file mode 100644 index 0000000..34ca4df --- /dev/null +++ b/documents/html/dir_68267d1309a1af8e8297ef4c3efbcdba.js @@ -0,0 +1,4 @@ +var dir_68267d1309a1af8e8297ef4c3efbcdba = +[ + [ "materialxMaterials", "dir_ed2309c38062a0ffa21222134f4047e1.html", "dir_ed2309c38062a0ffa21222134f4047e1" ] +]; \ No newline at end of file diff --git a/documents/html/dir_ed2309c38062a0ffa21222134f4047e1.js b/documents/html/dir_ed2309c38062a0ffa21222134f4047e1.js new file mode 100644 index 0000000..5257a07 --- /dev/null +++ b/documents/html/dir_ed2309c38062a0ffa21222134f4047e1.js @@ -0,0 +1,9 @@ +var dir_ed2309c38062a0ffa21222134f4047e1 = +[ + [ "__init__.py", "____init_____8py_source.html", null ], + [ "__main__.py", "____main_____8py_source.html", null ], + [ "GPUOpenLoader.py", "_g_p_u_open_loader_8py_source.html", null ], + [ "GPUOpenLoaderCmd.py", "_g_p_u_open_loader_cmd_8py_source.html", null ], + [ "physicallyBasedMaterialX.py", "physically_based_material_x_8py_source.html", null ], + [ "physicallyBasedMaterialXCmd.py", "physically_based_material_x_cmd_8py_source.html", null ] +]; \ No newline at end of file diff --git a/documents/html/docd.png b/documents/html/docd.png new file mode 100644 index 0000000..d7c94fd Binary files /dev/null and b/documents/html/docd.png differ diff --git a/documents/html/files.html b/documents/html/files.html index 9393c09..ea301d1 100644 --- a/documents/html/files.html +++ b/documents/html/files.html @@ -94,8 +94,8 @@  __main__.py  GPUOpenLoader.py  GPUOpenLoaderCmd.py - JsMaterialXPhysicallyBased.js - myserver.py + JsGPUOpenLoader.js + JsMaterialXPhysicallyBased.js  physicallyBasedMaterialX.py  physicallyBasedMaterialXCmd.py diff --git a/documents/html/files_dup.js b/documents/html/files_dup.js index d704c23..ea7f2b3 100644 --- a/documents/html/files_dup.js +++ b/documents/html/files_dup.js @@ -4,8 +4,8 @@ var files_dup = [ "__main__.py", "____main_____8py_source.html", null ], [ "GPUOpenLoader.py", "_g_p_u_open_loader_8py_source.html", null ], [ "GPUOpenLoaderCmd.py", "_g_p_u_open_loader_cmd_8py_source.html", null ], + [ "JsGPUOpenLoader.js", "_js_g_p_u_open_loader_8js_source.html", null ], [ "JsMaterialXPhysicallyBased.js", "_js_material_x_physically_based_8js_source.html", null ], - [ "myserver.py", "myserver_8py_source.html", null ], [ "physicallyBasedMaterialX.py", "physically_based_material_x_8py_source.html", null ], [ "physicallyBasedMaterialXCmd.py", "physically_based_material_x_cmd_8py_source.html", null ] ]; \ No newline at end of file diff --git a/documents/html/hierarchy.html b/documents/html/hierarchy.html index 71d1185..f0d1bd3 100644 --- a/documents/html/hierarchy.html +++ b/documents/html/hierarchy.html @@ -1,9 +1,9 @@ - + - - + + MaterialXMaterials: Class Hierarchy @@ -24,10 +24,9 @@
    - - + @@ -36,21 +35,22 @@
    -
    MaterialXMaterials -  0.0.1 +
    +
    MaterialXMaterials 0.0.1
    Utilities for retrieving materials from remote servers
    - + +/* @license-end */ +
    @@ -64,7 +64,7 @@
    @@ -78,22 +78,28 @@
    - +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    -
    -
    Class Hierarchy
    +
    Class Hierarchy
    This inheritance list is sorted roughly, but not completely, alphabetically:
    [detail level 12]
    - + - +
     CmaterialxMaterials.GPUOpenLoader.GPUOpenMaterialLoaderThis class is used to load materials from the GPUOpen material database
     CJsPhysicallyBasedMaterialLoaderJavascript class for querying materials from the Physically Based database and creating MaterialX materials
     CJsPhysicallyBasedMaterialLoaderJavascript class for querying materials from the Physically Based database and creating MaterialX materials
     CmaterialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoaderClass to load Physically Based Materials from the PhysicallyBased site
     Chttp.server.SimpleHTTPRequestHandler
     Chttp.server.SimpleHTTPRequestHandler
     Cmyserver.MyHTTPRequestHandler
    @@ -102,7 +108,7 @@ diff --git a/documents/html/index.html b/documents/html/index.html index b0951b2..0e89fc8 100644 --- a/documents/html/index.html +++ b/documents/html/index.html @@ -99,6 +99,7 @@

    The Python utilities require:
    1. The MaterialX 1.39 or greater package for PhysicallyBased OpenPBR shader creation
    2. The requests package.
    3. +
    4. The pillow package for image handling for GPUOpen package handling

    Building

    The GitHub repository can be cloned and the package built using:
    pip install .
    diff --git a/documents/html/menudata.js b/documents/html/menudata.js index 9e7fb09..f3f143b 100644 --- a/documents/html/menudata.js +++ b/documents/html/menudata.js @@ -29,7 +29,6 @@ var menudata={children:[ {text:"Classes",url:"annotated.html",children:[ {text:"Class List",url:"annotated.html"}, {text:"Class Index",url:"classes.html"}, -{text:"Class Hierarchy",url:"hierarchy.html"}, {text:"Class Members",url:"functions.html",children:[ {text:"All",url:"functions.html",children:[ {text:"_",url:"functions.html#index__5F"}, diff --git a/documents/html/myserver_8py_source.html b/documents/html/myserver_8py_source.html index 070e2d8..212e243 100644 --- a/documents/html/myserver_8py_source.html +++ b/documents/html/myserver_8py_source.html @@ -1,9 +1,9 @@ - + - - + + MaterialXMaterials: myserver.py Source File @@ -24,10 +24,9 @@
    - - + @@ -36,21 +35,22 @@
    -
    MaterialXMaterials -  0.0.1 +
    +
    MaterialXMaterials 0.0.1
    Utilities for retrieving materials from remote servers
    - + +/* @license-end */ +
    @@ -64,7 +64,7 @@
    @@ -78,43 +78,49 @@
    - +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    -
    -
    myserver.py
    +
    myserver.py
    -
    1 import http.server
    -
    2 import socketserver
    -
    3 import signal
    -
    4 
    -
    5 PORT = 8000
    -
    6 
    -
    7 class MyHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
    -
    8  def end_headers(self):
    -
    9  self.send_header("Cache-Control", "no-cache, no-store, must-revalidate")
    -
    10  self.send_header("Pragma", "no-cache")
    -
    11  self.send_header("Expires", "0")
    -
    12  super().end_headers()
    -
    13 
    -
    14 def signal_handler(sig, frame):
    -
    15  print('Exiting server...')
    -
    16  httpd.server_close()
    -
    17  exit(0)
    -
    18 
    -
    19 signal.signal(signal.SIGINT, signal_handler)
    -
    20 
    -
    21 print("Serving at port: ", PORT)
    -
    22 with socketserver.TCPServer(("", PORT), MyHTTPRequestHandler) as httpd:
    -
    23  try:
    -
    24  httpd.serve_forever()
    -
    25  except KeyboardInterrupt:
    -
    26  pass
    -
    27  httpd.server_close()
    +
    1import http.server
    +
    2import socketserver
    +
    3import signal
    +
    4
    +
    5PORT = 8000
    +
    6
    +
    7class MyHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
    +
    8 def end_headers(self):
    +
    9 self.send_header("Cache-Control", "no-cache, no-store, must-revalidate")
    +
    10 self.send_header("Pragma", "no-cache")
    +
    11 self.send_header("Expires", "0")
    +
    12 super().end_headers()
    +
    13
    +
    14def signal_handler(sig, frame):
    +
    15 print('Exiting server...')
    +
    16 httpd.server_close()
    +
    17 exit(0)
    +
    18
    +
    19signal.signal(signal.SIGINT, signal_handler)
    +
    20
    +
    21print("Serving at port: ", PORT)
    +
    22with socketserver.TCPServer(("", PORT), MyHTTPRequestHandler) as httpd:
    +
    23 try:
    +
    24 httpd.serve_forever()
    +
    25 except KeyboardInterrupt:
    +
    26 pass
    +
    27 httpd.server_close()
    @@ -123,7 +129,7 @@ diff --git a/documents/html/namespaces.html b/documents/html/namespaces.html index b0f9175..182900e 100644 --- a/documents/html/namespaces.html +++ b/documents/html/namespaces.html @@ -98,8 +98,6 @@  NphysicallyBasedMaterialXClass to load Physically Based Materials from the PhysicallyBased site  CPhysicallyBasedMaterialLoaderClass to load Physically Based Materials from the PhysicallyBased site  NphysicallyBasedMaterialXCmd - Nmyserver - CMyHTTPRequestHandler
    diff --git a/documents/html/namespaces_dup.js b/documents/html/namespaces_dup.js index 269d7d4..8e94be5 100644 --- a/documents/html/namespaces_dup.js +++ b/documents/html/namespaces_dup.js @@ -13,10 +13,5 @@ var namespaces_dup = [ "physicallBasedMaterialXCmd", "physically_based_material_x_cmd_8py.html#a962926b309ce16afa06401e2549c4f77", null ] ] ], [ "__version__", "____init_____8py.html#a0a3e35178588ad1393c61d4b0b4952d3", null ] - ] ], - [ "myserver", null, [ - [ "MyHTTPRequestHandler", "classmyserver_1_1_my_h_t_t_p_request_handler.html", "classmyserver_1_1_my_h_t_t_p_request_handler" ], - [ "signal_handler", "myserver_8py.html#a191864830612a53884eaf67ea50f9358", null ], - [ "PORT", "myserver_8py.html#ae64865fb0c0c5b2daccffaa0caf57b0b", null ] ] ] ]; \ No newline at end of file diff --git a/documents/html/nav_fd.png b/documents/html/nav_fd.png new file mode 100644 index 0000000..032fbdd Binary files /dev/null and b/documents/html/nav_fd.png differ diff --git a/documents/html/nav_hd.png b/documents/html/nav_hd.png new file mode 100644 index 0000000..de80f18 Binary files /dev/null and b/documents/html/nav_hd.png differ diff --git a/documents/html/navtreedata.js b/documents/html/navtreedata.js index e99b441..cb7632e 100644 --- a/documents/html/navtreedata.js +++ b/documents/html/navtreedata.js @@ -31,7 +31,6 @@ var NAVTREE = [ "Classes", "annotated.html", [ [ "Class List", "annotated.html", "annotated_dup" ], [ "Class Index", "classes.html", null ], - [ "Class Hierarchy", "hierarchy.html", "hierarchy" ], [ "Class Members", "functions.html", [ [ "All", "functions.html", null ], [ "Functions", "functions_func.html", null ], @@ -46,7 +45,7 @@ var NAVTREE = var NAVTREEINDEX = [ -"____init_____8py.html#a0a3e35178588ad1393c61d4b0b4952d3" +"" ]; var SYNCONMSG = 'click to disable panel synchronisation'; diff --git a/documents/html/navtreeindex0.js b/documents/html/navtreeindex0.js index e87919e..476b959 100644 --- a/documents/html/navtreeindex0.js +++ b/documents/html/navtreeindex0.js @@ -1,5 +1,9 @@ var NAVTREEINDEX0 = { +"":[0,0,0], +"":[0,0,0,0], +"":[0,0,0,2], +"":[0,0,0,4], "____init_____8py.html#a0a3e35178588ad1393c61d4b0b4952d3":[0,0,0,5], "____init_____8py_source.html":[2,0,0], "____main_____8py.html#acd7f5fefcd7146c6dd868607d85c04f7":[0,0,0,0,0], @@ -7,8 +11,14 @@ var NAVTREEINDEX0 = "_g_p_u_open_loader_8py_source.html":[2,0,2], "_g_p_u_open_loader_cmd_8py.html#acba9ba30ffec65ce6e1120f01a32b4b1":[0,0,0,2,0], "_g_p_u_open_loader_cmd_8py_source.html":[2,0,3], -"_js_material_x_physically_based_8js_source.html":[2,0,4], +"_js_g_p_u_open_loader_8js_source.html":[2,0,4], +"_js_material_x_physically_based_8js_source.html":[2,0,5], "annotated.html":[1,0], +"class_g_p_u_open_material_loader.html":[1,0,1], +"class_g_p_u_open_material_loader.html#a4155c2fcf6b2c38088f85c63e933aef9":[1,0,1,0], +"class_g_p_u_open_material_loader.html#a44ccdf25c1654dd628e8351889298e83":[1,0,1,2], +"class_g_p_u_open_material_loader.html#aa20236461b74f2fd756649fa63757f05":[1,0,1,3], +"class_g_p_u_open_material_loader.html#ae420983c6072cceb216459ed5ab2a2aa":[1,0,1,1], "class_js_physically_based_material_loader.html":[1,0,2], "class_js_physically_based_material_loader.html#a0ff670b529d0d01fe96d6e7d656c8f2a":[1,0,2,12], "class_js_physically_based_material_loader.html#a19ba3f660663b91ec2be3fe81b45b2b4":[1,0,2,14], @@ -81,27 +91,16 @@ var NAVTREEINDEX0 = "classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#ae10fc6e2a8a66c4e09ad3f6b5dc320f3":[1,0,0,1,0,22], "classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#ae9e0898cb48b3c163eeea4e7c035cc92":[1,0,0,1,0,1], "classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#aec5e05618ea141395f94a2ecc897ab96":[1,0,0,1,0,15], -"classmyserver_1_1_my_h_t_t_p_request_handler.html":[1,0,1,0], -"classmyserver_1_1_my_h_t_t_p_request_handler.html#a2d03d79df5573d7b5948be8039e744b8":[1,0,1,0,0], "files.html":[2,0], -"functions.html":[1,3,0], -"functions_func.html":[1,3,1], -"functions_vars.html":[1,3,2], -"hierarchy.html":[1,2], +"functions.html":[1,2,0], +"functions_func.html":[1,2,1], +"functions_vars.html":[1,2,2], "index.html":[], -"myserver_8py.html#a191864830612a53884eaf67ea50f9358":[0,0,1,1], -"myserver_8py.html#ae64865fb0c0c5b2daccffaa0caf57b0b":[0,0,1,2], -"myserver_8py_source.html":[2,0,5], "namespacematerialx_materials_1_1_g_p_u_open_loader.html":[0,0,0,1], "namespacematerialx_materials_1_1physically_based_material_x.html":[0,0,0,3], "namespaces.html":[0,0], "pages.html":[], "physically_based_material_x_8py_source.html":[2,0,6], "physically_based_material_x_cmd_8py.html#a962926b309ce16afa06401e2549c4f77":[0,0,0,4,0], -"physically_based_material_x_cmd_8py_source.html":[2,0,7], -"":[0,0,1], -"":[0,0,0,0], -"":[0,0,0], -"":[0,0,0,4], -"":[0,0,0,2] +"physically_based_material_x_cmd_8py_source.html":[2,0,7] }; diff --git a/documents/html/physically_based_material_x_8py_source.html b/documents/html/physically_based_material_x_8py_source.html index 2a5f75f..3bb8652 100644 --- a/documents/html/physically_based_material_x_8py_source.html +++ b/documents/html/physically_based_material_x_8py_source.html @@ -182,333 +182,359 @@
    92  #'metalness': 'metalness',
    93  'ior': 'specular_IOR',
    94  #'transmission': 'transmission',
    -
    95  'thinFilmIor' : 'thin_film_IOR',
    -
    96  'thinFilmThickness' : 'thin_film_thickness',
    -
    97  'transmissionDispersion' : 'transmission_dispersion',
    -
    98  }
    -
    99  # Remap keys for OpenPBR shading model.
    -
    100  openpbr_remapKeys = {
    -
    101  'color': 'base_color',
    -
    102  'specularColor': 'specular_color',
    -
    103  'roughness': 'specular_roughness', # 'base_diffuse_roughness',
    -
    104  'metalness': 'base_metalness',
    -
    105  'ior': 'specular_ior',
    -
    106  'transmission': 'transmission_weight',
    -
    107  'subsurfaceRadius': 'subsurface_radius',
    -
    108  'thinFilmIor' : 'thinfilm_ior',
    -
    109  'thinFilmThickness' : 'thinfilm_thickness',
    -
    110  'transmissionDispersion' : 'transmission_dispersion_scale',
    -
    111  }
    -
    112  # Remap keys for Khronos glTF shading model.
    -
    113  gltf_remapKeys = {
    -
    114  'color': 'base_color',
    -
    115  'specularColor': 'specular_color',
    -
    116  'roughness': 'roughness',
    -
    117  'metalness': 'metallic',
    -
    118  #'ior': 'ior',
    -
    119  #'transmission': 'transmission',
    -
    120  }
    -
    121 
    -
    122  self.remapMapremapMap = {}
    -
    123  self.remapMapremapMap['standard_surface'] = standard_surface_remapKeys;
    -
    124  self.remapMapremapMap['gltf_pbr'] = gltf_remapKeys;
    -
    125  if self.support_openpbrsupport_openpbr:
    -
    126  self.remapMapremapMap['open_pbr_surface'] = openpbr_remapKeys;
    -
    127 
    -
    128  def getJSON(self) -> dict:
    -
    129  ''' Get the JSON object representing the Physically Based Materials '''
    -
    130  return self.materialsmaterials
    -
    131 
    -
    132  def getJSONMaterialNames(self) -> list:
    -
    133  '''
    -
    134  Get the list of material names from the JSON object
    -
    135  @return The list of material names
    -
    136  '''
    -
    137  return self.materialNamesmaterialNames
    -
    138 
    -
    139  def getMaterialXDocument(self) -> mx.Document:
    -
    140  '''
    -
    141  Get the MaterialX document
    -
    142  @return The MaterialX document
    -
    143  '''
    -
    144  return self.docdoc
    -
    145 
    -
    146  def loadMaterialsFromFile(self, fileName) -> dict:
    -
    147  '''
    -
    148  @brief Load the Physically Based Materials from a JSON file
    -
    149  @param fileName The filename to load the JSON file from
    -
    150  @return The JSON object representing the Physically Based Materials
    -
    151  '''
    -
    152  self.materialsmaterials = None
    -
    153  self.materialNamesmaterialNames = []
    -
    154  if not os.path.exists(fileName):
    -
    155  self.loggerlogger.error(f'> File does not exist: {fileName}')
    -
    156  return None
    -
    157 
    -
    158  with open(fileName, 'r') as json_file:
    -
    159  self.materialsmaterials = json.load(json_file)
    -
    160  for mat in self.materialsmaterials:
    -
    161  self.materialNamesmaterialNames.append(mat['name'])
    -
    162 
    -
    163  return self.materialsmaterials
    -
    164 
    -
    165  def loadMaterialsFromString(self, matString) -> dict:
    -
    166  '''
    -
    167  @brief Load the Physically Based Materials from a JSON string
    -
    168  @param matString The JSON string to load the Physically Based Materials from
    -
    169  @return The JSON object representing the Physically Based Materials
    -
    170  '''
    -
    171  self.materialsmaterials = None
    -
    172  self.materialNamesmaterialNames = []
    -
    173  self.materialsmaterials = json.loads(matString)
    -
    174  for mat in self.materialsmaterials:
    -
    175  self.materialNamesmaterialNames.append(mat['name'])
    -
    176 
    -
    177  return self.materialsmaterials
    +
    95  'transmission_color': 'transmission_color',
    +
    96  'thinFilmIor' : 'thin_film_IOR',
    +
    97  'thinFilmThickness' : 'thin_film_thickness',
    +
    98  'transmissionDispersion' : 'transmission_dispersion',
    +
    99  }
    +
    100  # Remap keys for OpenPBR shading model.
    +
    101  openpbr_remapKeys = {
    +
    102  'color': 'base_color',
    +
    103  'specularColor': 'specular_color',
    +
    104  'roughness': 'specular_roughness', # 'base_diffuse_roughness',
    +
    105  'metalness': 'base_metalness',
    +
    106  'ior': 'specular_ior',
    +
    107  'transmission': 'transmission_weight',
    +
    108  'transmission_color': 'transmission_color',
    +
    109  'subsurfaceRadius': 'subsurface_radius',
    +
    110  'thinFilmIor' : 'thinfilm_ior',
    +
    111  'thinFilmThickness' : 'thinfilm_thickness',
    +
    112  'transmissionDispersion' : 'transmission_dispersion_scale',
    +
    113  }
    +
    114  # Remap keys for Khronos glTF shading model.
    +
    115  gltf_remapKeys = {
    +
    116  'color': 'base_color',
    +
    117  'specularColor': 'specular_color',
    +
    118  'roughness': 'roughness',
    +
    119  'metalness': 'metallic',
    +
    120  #'ior': 'ior',
    +
    121  #'transmission': 'transmission',
    +
    122  }
    +
    123 
    +
    124  self.remapMapremapMap = {}
    +
    125  self.remapMapremapMap['standard_surface'] = standard_surface_remapKeys;
    +
    126  self.remapMapremapMap['gltf_pbr'] = gltf_remapKeys;
    +
    127  if self.support_openpbrsupport_openpbr:
    +
    128  self.remapMapremapMap['open_pbr_surface'] = openpbr_remapKeys;
    +
    129 
    +
    130  def getJSON(self) -> dict:
    +
    131  ''' Get the JSON object representing the Physically Based Materials '''
    +
    132  return self.materialsmaterials
    +
    133 
    +
    134  def getJSONMaterialNames(self) -> list:
    +
    135  '''
    +
    136  Get the list of material names from the JSON object
    +
    137  @return The list of material names
    +
    138  '''
    +
    139  return self.materialNamesmaterialNames
    +
    140 
    +
    141  def getMaterialXDocument(self) -> mx.Document:
    +
    142  '''
    +
    143  Get the MaterialX document
    +
    144  @return The MaterialX document
    +
    145  '''
    +
    146  return self.docdoc
    +
    147 
    +
    148  def loadMaterialsFromFile(self, fileName) -> dict:
    +
    149  '''
    +
    150  @brief Load the Physically Based Materials from a JSON file
    +
    151  @param fileName The filename to load the JSON file from
    +
    152  @return The JSON object representing the Physically Based Materials
    +
    153  '''
    +
    154  self.materialsmaterials = None
    +
    155  self.materialNamesmaterialNames = []
    +
    156  if not os.path.exists(fileName):
    +
    157  self.loggerlogger.error(f'> File does not exist: {fileName}')
    +
    158  return None
    +
    159 
    +
    160  with open(fileName, 'r') as json_file:
    +
    161  self.materialsmaterials = json.load(json_file)
    +
    162  for mat in self.materialsmaterials:
    +
    163  self.materialNamesmaterialNames.append(mat['name'])
    +
    164 
    +
    165  return self.materialsmaterials
    +
    166 
    +
    167  def loadMaterialsFromString(self, matString) -> dict:
    +
    168  '''
    +
    169  @brief Load the Physically Based Materials from a JSON string
    +
    170  @param matString The JSON string to load the Physically Based Materials from
    +
    171  @return The JSON object representing the Physically Based Materials
    +
    172  '''
    +
    173  self.materialsmaterials = None
    +
    174  self.materialNamesmaterialNames = []
    +
    175  self.materialsmaterials = json.loads(matString)
    +
    176  for mat in self.materialsmaterials:
    +
    177  self.materialNamesmaterialNames.append(mat['name'])
    178 
    -
    179  def getMaterialsFromURL(self) -> dict:
    -
    180  '''
    -
    181  @brief Get the Physically Based Materials from the PhysicallyBased site
    -
    182  @return The JSON object representing the Physically Based Materials
    -
    183  '''
    -
    184 
    -
    185  self.materialsmaterials = None
    -
    186  self.materialNamesmaterialNames = []
    -
    187  url = self.uriuri
    -
    188  headers = {
    -
    189  'Accept': 'application/json'
    -
    190  }
    -
    191 
    -
    192  response = requests.get(url, headers=headers)
    +
    179  return self.materialsmaterials
    +
    180 
    +
    181  def getMaterialsFromURL(self) -> dict:
    +
    182  '''
    +
    183  @brief Get the Physically Based Materials from the PhysicallyBased site
    +
    184  @return The JSON object representing the Physically Based Materials
    +
    185  '''
    +
    186 
    +
    187  self.materialsmaterials = None
    +
    188  self.materialNamesmaterialNames = []
    +
    189  url = self.uriuri
    +
    190  headers = {
    +
    191  'Accept': 'application/json'
    +
    192  }
    193 
    -
    194  if response.status_code == HTTPStatus.OK:
    -
    195  self.materialsmaterials = response.json()
    -
    196  for mat in self.materialsmaterials:
    -
    197  self.materialNamesmaterialNames.append(mat['name'])
    -
    198 
    -
    199  else:
    -
    200  self.loggerlogger.error(f'> Status: {response.status_code}, {response.text}')
    -
    201 
    -
    202  return self.materialsmaterials
    -
    203 
    -
    204  def printMaterials(self):
    -
    205  '''
    -
    206  @brief Print the materials to the console
    -
    207  @return None
    -
    208  '''
    -
    209  for mat in self.materialsmaterials:
    -
    210  self.loggerlogger.info('Material name: ' + mat['name'])
    -
    211  # Print out each key and value
    -
    212  for key, value in mat.items():
    -
    213  if (key != 'name' and value):
    -
    214  self.loggerlogger.info(f'> - {key}: {value}')
    -
    215 
    -
    216  def writeJSONToFile(self, filename):
    -
    217  '''
    -
    218  @brief Write the materials to a JSON file
    -
    219  @param filename The filename to write the JSON file to
    -
    220  @return True if the file was written successfully, otherwise False
    -
    221  '''
    -
    222  if not self.materialsmaterials:
    -
    223  self.loggerlogger.warning('No materials to write')
    -
    224  return False
    -
    225 
    -
    226  with open(filename, 'w') as json_file:
    -
    227  json.dump(self.materialsmaterials, json_file, indent=4)
    -
    228  return True
    -
    229 
    -
    230  return False
    -
    231 
    -
    232  @staticmethod
    -
    233  def skipLibraryElement(elem) -> bool:
    -
    234  '''
    -
    235  @brief Utility to skip library elements when iterating over elements in a document.
    -
    236  @return True if the element is not in a library, otherwise False.
    -
    237  '''
    -
    238  return not elem.hasSourceUri()
    -
    239 
    -
    240  def _getMethodName(self):
    -
    241  frame = inspect.currentframe().f_back
    -
    242  method_name = frame.f_code.co_name
    -
    243  return method_name
    -
    244  #return inspect.currentframe().f_code.co_name
    -
    245 
    - -
    247  '''
    -
    248  @brief Validate the MaterialX document
    -
    249  @param doc The MaterialX document to validate
    -
    250  @return A tuple of (valid, errors) where valid is True if the document is valid, and errors is a list of errors if the document is invalid.
    -
    251  '''
    -
    252  if not self.mxmx:
    -
    253  self.loggerlogger.critical(f'> {self._getMethodName()}: MaterialX module is required')
    -
    254  return False, ''
    -
    255 
    -
    256  if not doc:
    -
    257  self.loggerlogger.warning(f'> {self._getMethodName()}: MaterialX document is required')
    -
    258  return False, ''
    -
    259 
    -
    260  valid, errors = doc.validate()
    -
    261  return valid, errors
    -
    262 
    -
    263  def addComment(self, doc, commentString):
    -
    264  '''
    -
    265  @brief Add a comment to the MaterialX document
    -
    266  @param doc The MaterialX document to add the comment to
    -
    267  @param commentString The comment string to add
    -
    268  @return None
    -
    269  '''
    -
    270  comment = doc.addChildOfCategory('comment')
    -
    271  comment.setDocString(commentString)
    -
    272 
    -
    273  def convertToMaterialX(self, materialNames = [], shaderCategory='standard_surface',
    -
    274  remapKeys = {}, shaderPreFix ='') -> mx.Document:
    -
    275  '''
    -
    276  @brief Convert the Physically Based Materials to MaterialX format for a given target shading model.
    -
    277  @param materialNames The list of material names to convert. If empty, all materials will be converted.
    -
    278  @param shaderCategory The target shading model to convert to. Default is 'standard_surface'.
    -
    279  @param remapKeys The remapping keys for the target shading model. If empty, the default remapping keys will be used.
    -
    280  @param shaderPreFix The prefix to add to the shader name. Default is an empty string.
    -
    281  @return The MaterialX document
    -
    282  '''
    -
    283  if not self.mxmx:
    -
    284  self.loggerlogger.critical(f'> {self._getMethodName()}: MaterialX module is required')
    -
    285  return None
    -
    286 
    -
    287  if not self.support_openpbrsupport_openpbr and shaderCategory == 'open_pbr_surface':
    -
    288  self.loggerlogger.warning(f'> OpenPBR shading model not supported in MaterialX version {self.mx.getVersionString()}')
    -
    289  return None
    -
    290 
    -
    291  if not self.materialsmaterials:
    -
    292  self.loggerlogger.info('> No materials to convert')
    -
    293  return None
    -
    294 
    -
    295  if len(remapKeys) == 0:
    -
    296  remapKeys = self.getInputRemappinggetInputRemapping(shaderCategory)
    -
    297  if len(remapKeys) == 0:
    -
    298  self.loggerlogger.warning(f'> No remapping keys found for shading model: {shaderCategory}')
    -
    299 
    -
    300  # Create main document and import the library document
    -
    301  self.docdoc = self.mxmx.createDocument()
    -
    302  self.docdoc.importLibrary(self.stdlibstdlib)
    -
    303 
    -
    304  # Add header comments
    -
    305  self.addCommentaddComment(self.docdoc, 'Physically Based Materials from https://api.physicallybased.info ')
    -
    306  self.addCommentaddComment(self.docdoc, ' Processsed via API and converted to MaterialX ')
    -
    307  self.addCommentaddComment(self.docdoc, ' Target Shading Model: ' + shaderCategory)
    -
    308  self.addCommentaddComment(self.docdoc, ' Utility Author: Bernard Kwok. kwokcb@gmail.com ')
    -
    309 
    -
    310  # Add properties to the material
    -
    311  for mat in self.materialsmaterials:
    -
    312  matName = mat['name']
    -
    313 
    -
    314  # Filter by material name(s)
    -
    315  if len(materialNames) > 0 and matName not in materialNames:
    -
    316  #self.logger.debug('Skip material: ' + matName)
    -
    317  continue
    -
    318 
    -
    319  if (len(shaderPreFix) > 0):
    -
    320  matName = shaderPreFix + '_' + matName
    -
    321 
    -
    322  shaderName = self.docdoc.createValidChildName('SHD_PBM_' + matName)
    -
    323  self.addCommentaddComment(self.docdoc, ' Generated shader: ' + shaderName + ' ')
    -
    324  shaderNode = self.docdoc.addNode(shaderCategory, shaderName, self.mxmx.SURFACE_SHADER_TYPE_STRING)
    -
    325  docString = mat['description']
    -
    326  refString = mat['reference']
    -
    327  if len(refString) > 0:
    -
    328  if len(docString) > 0:
    -
    329  docString += '. '
    -
    330  docString += 'Reference: ' + refString[0]
    -
    331  if len(docString) > 0:
    -
    332  shaderNode.setDocString(docString)
    -
    333  #shaderNode.addInputsFromNodeDef()
    -
    334  #shaderNode.setAttribute(self.mx.InterfaceElement.NODE_DEF_ATTRIBUTE, nodedefString)
    -
    335 
    -
    336  # Create a new material
    -
    337  materialName = self.docdoc.createValidChildName('MAT_PBM_' + matName)
    -
    338  self.addCommentaddComment(self.docdoc, ' Generated material: ' + materialName + ' ')
    -
    339  materialNode = self.docdoc.addNode(self.mxmx.SURFACE_MATERIAL_NODE_STRING, materialName, self.mxmx.MATERIAL_TYPE_STRING)
    -
    340  shaderInput = materialNode.addInput(self.mxmx.SURFACE_SHADER_TYPE_STRING, self.mxmx.SURFACE_SHADER_TYPE_STRING)
    -
    341  shaderInput.setAttribute(self.MTLX_NODE_NAME_ATTRIBUTEMTLX_NODE_NAME_ATTRIBUTE, shaderNode.getName())
    -
    342 
    -
    343  # Keys to skip.
    -
    344  skipKeys = ['name', "density", "category", "description", "sources", "tags", "reference"]
    -
    345 
    -
    346  for key, value in mat.items():
    -
    347  if (key not in skipKeys):
    -
    348  if key in remapKeys:
    -
    349  key = remapKeys[key]
    -
    350  input = shaderNode.addInputFromNodeDef(key)
    -
    351  if input:
    -
    352  # Convert number vector to string
    -
    353  if isinstance(value, list):
    -
    354  value = ','.join([str(x) for x in value])
    -
    355  # Convert number to string:
    -
    356  elif isinstance(value, (int, float)):
    -
    357  value = str(value)
    -
    358  input.setValueString(value)
    -
    359  #else:
    -
    360  # self.logger.debug('Skip unsupported key: ' + key)
    -
    361 
    -
    362  return self.docdoc
    -
    363 
    -
    364  def writeMaterialXToFile(self, filename):
    -
    365  '''
    -
    366  @brief Write the MaterialX document to disk
    -
    367  @param filename The filename to write the MaterialX document to
    -
    368  @return None
    -
    369  '''
    -
    370  if not self.mxmx:
    -
    371  self.loggerlogger.critical(f'> {self._getMethodName()}: MaterialX module is required')
    -
    372  return
    -
    373 
    -
    374  writeOptions = self.mxmx.XmlWriteOptions()
    -
    375  writeOptions.writeXIncludeEnable = False
    -
    376  writeOptions.elementPredicate = self.skipLibraryElementskipLibraryElement
    -
    377  self.mxmx.writeToXmlFile(self.docdoc, filename, writeOptions)
    -
    378 
    - -
    380  '''
    -
    381  @brief Convert the MaterialX document to a string
    -
    382  @return The MaterialX document as a string
    -
    383  '''
    -
    384  if not self.mxmx:
    -
    385  self.loggerlogger.critical(f'> {self._getMethodName()}: MaterialX module is required')
    -
    386  return
    +
    194  response = requests.get(url, headers=headers)
    +
    195 
    +
    196  if response.status_code == HTTPStatus.OK:
    +
    197  self.materialsmaterials = response.json()
    +
    198  for mat in self.materialsmaterials:
    +
    199  self.materialNamesmaterialNames.append(mat['name'])
    +
    200 
    +
    201  else:
    +
    202  self.loggerlogger.error(f'> Status: {response.status_code}, {response.text}')
    +
    203 
    +
    204  return self.materialsmaterials
    +
    205 
    +
    206  def printMaterials(self):
    +
    207  '''
    +
    208  @brief Print the materials to the console
    +
    209  @return None
    +
    210  '''
    +
    211  for mat in self.materialsmaterials:
    +
    212  self.loggerlogger.info('Material name: ' + mat['name'])
    +
    213  # Print out each key and value
    +
    214  for key, value in mat.items():
    +
    215  if (key != 'name' and value):
    +
    216  self.loggerlogger.info(f'> - {key}: {value}')
    +
    217 
    +
    218  def writeJSONToFile(self, filename):
    +
    219  '''
    +
    220  @brief Write the materials to a JSON file
    +
    221  @param filename The filename to write the JSON file to
    +
    222  @return True if the file was written successfully, otherwise False
    +
    223  '''
    +
    224  if not self.materialsmaterials:
    +
    225  self.loggerlogger.warning('No materials to write')
    +
    226  return False
    +
    227 
    +
    228  with open(filename, 'w') as json_file:
    +
    229  json.dump(self.materialsmaterials, json_file, indent=4)
    +
    230  return True
    +
    231 
    +
    232  return False
    +
    233 
    +
    234  @staticmethod
    +
    235  def skipLibraryElement(elem) -> bool:
    +
    236  '''
    +
    237  @brief Utility to skip library elements when iterating over elements in a document.
    +
    238  @return True if the element is not in a library, otherwise False.
    +
    239  '''
    +
    240  return not elem.hasSourceUri()
    +
    241 
    +
    242  def _getMethodName(self):
    +
    243  frame = inspect.currentframe().f_back
    +
    244  method_name = frame.f_code.co_name
    +
    245  return method_name
    +
    246  #return inspect.currentframe().f_code.co_name
    +
    247 
    + +
    249  '''
    +
    250  @brief Validate the MaterialX document
    +
    251  @param doc The MaterialX document to validate
    +
    252  @return A tuple of (valid, errors) where valid is True if the document is valid, and errors is a list of errors if the document is invalid.
    +
    253  '''
    +
    254  if not self.mxmx:
    +
    255  self.loggerlogger.critical(f'> {self._getMethodName()}: MaterialX module is required')
    +
    256  return False, ''
    +
    257 
    +
    258  if not doc:
    +
    259  self.loggerlogger.warning(f'> {self._getMethodName()}: MaterialX document is required')
    +
    260  return False, ''
    +
    261 
    +
    262  valid, errors = doc.validate()
    +
    263  return valid, errors
    +
    264 
    +
    265  def addComment(self, doc, commentString):
    +
    266  '''
    +
    267  @brief Add a comment to the MaterialX document
    +
    268  @param doc The MaterialX document to add the comment to
    +
    269  @param commentString The comment string to add
    +
    270  @return None
    +
    271  '''
    +
    272  comment = doc.addChildOfCategory('comment')
    +
    273  comment.setDocString(commentString)
    +
    274 
    +
    275  def convertToMaterialX(self, materialNames = [], shaderCategory='standard_surface',
    +
    276  remapKeys = {}, shaderPreFix ='') -> mx.Document:
    +
    277  '''
    +
    278  @brief Convert the Physically Based Materials to MaterialX format for a given target shading model.
    +
    279  @param materialNames The list of material names to convert. If empty, all materials will be converted.
    +
    280  @param shaderCategory The target shading model to convert to. Default is 'standard_surface'.
    +
    281  @param remapKeys The remapping keys for the target shading model. If empty, the default remapping keys will be used.
    +
    282  @param shaderPreFix The prefix to add to the shader name. Default is an empty string.
    +
    283  @return The MaterialX document
    +
    284  '''
    +
    285  if not self.mxmx:
    +
    286  self.loggerlogger.critical(f'> {self._getMethodName()}: MaterialX module is required')
    +
    287  return None
    +
    288 
    +
    289  if not self.support_openpbrsupport_openpbr and shaderCategory == 'open_pbr_surface':
    +
    290  self.loggerlogger.warning(f'> OpenPBR shading model not supported in MaterialX version {self.mx.getVersionString()}')
    +
    291  return None
    +
    292 
    +
    293  if not self.materialsmaterials:
    +
    294  self.loggerlogger.info('> No materials to convert')
    +
    295  return None
    +
    296 
    +
    297  if len(remapKeys) == 0:
    +
    298  remapKeys = self.getInputRemappinggetInputRemapping(shaderCategory)
    +
    299  if len(remapKeys) == 0:
    +
    300  self.loggerlogger.warning(f'> No remapping keys found for shading model: {shaderCategory}')
    +
    301 
    +
    302  # Create main document and import the library document
    +
    303  self.docdoc = self.mxmx.createDocument()
    +
    304  self.docdoc.importLibrary(self.stdlibstdlib)
    +
    305 
    +
    306  # Add header comments
    +
    307  self.addCommentaddComment(self.docdoc, 'Physically Based Materials from https://api.physicallybased.info ')
    +
    308  self.addCommentaddComment(self.docdoc, ' Processsed via API and converted to MaterialX ')
    +
    309  self.addCommentaddComment(self.docdoc, ' Target Shading Model: ' + shaderCategory)
    +
    310  self.addCommentaddComment(self.docdoc, ' Utility Author: Bernard Kwok. kwokcb@gmail.com ')
    +
    311 
    +
    312  # Add properties to the material
    +
    313  for mat in self.materialsmaterials:
    +
    314  matName = mat['name']
    +
    315 
    +
    316  # Filter by material name(s)
    +
    317  if len(materialNames) > 0 and matName not in materialNames:
    +
    318  #self.logger.debug('Skip material: ' + matName)
    +
    319  continue
    +
    320 
    +
    321  if (len(shaderPreFix) > 0):
    +
    322  matName = matName + '_' + shaderPreFix
    +
    323 
    +
    324  shaderName = self.docdoc.createValidChildName(matName + '_SHD_PBM')
    +
    325  self.addCommentaddComment(self.docdoc, ' Generated shader: ' + shaderName + ' ')
    +
    326  shaderNode = self.docdoc.addNode(shaderCategory, shaderName, self.mxmx.SURFACE_SHADER_TYPE_STRING)
    +
    327  docString = mat['description']
    +
    328  refString = mat['reference']
    +
    329  if len(refString) > 0:
    +
    330  if len(docString) > 0:
    +
    331  docString += '. '
    +
    332  docString += 'Reference: ' + refString[0]
    +
    333  if len(docString) > 0:
    +
    334  shaderNode.setDocString(docString)
    +
    335  #shaderNode.addInputsFromNodeDef()
    +
    336  #shaderNode.setAttribute(self.mx.InterfaceElement.NODE_DEF_ATTRIBUTE, nodedefString)
    +
    337 
    +
    338  # Create a new material
    +
    339  materialName = self.docdoc.createValidChildName(matName + '_MAT_PBM')
    +
    340  self.addCommentaddComment(self.docdoc, ' Generated material: ' + materialName + ' ')
    +
    341  materialNode = self.docdoc.addNode(self.mxmx.SURFACE_MATERIAL_NODE_STRING, materialName, self.mxmx.MATERIAL_TYPE_STRING)
    +
    342  shaderInput = materialNode.addInput(self.mxmx.SURFACE_SHADER_TYPE_STRING, self.mxmx.SURFACE_SHADER_TYPE_STRING)
    +
    343  shaderInput.setAttribute(self.MTLX_NODE_NAME_ATTRIBUTEMTLX_NODE_NAME_ATTRIBUTE, shaderNode.getName())
    +
    344 
    +
    345  # Keys to skip.
    +
    346  skipKeys = ['name', "density", "category", "description", "sources", "tags", "reference"]
    +
    347 
    +
    348  metallness = None
    +
    349  roughness = None
    +
    350  color = None
    +
    351  transmission = None
    +
    352  for key, value in mat.items():
    +
    353 
    +
    354  if (key not in skipKeys):
    +
    355  if key == 'metalness':
    +
    356  metallness = value
    +
    357  if key == 'roughness':
    +
    358  roughness = value
    +
    359  if key == 'transmission':
    +
    360  transmission = value
    +
    361  if key == 'color':
    +
    362  color = value
    +
    363 
    +
    364  if key in remapKeys:
    +
    365  key = remapKeys[key]
    +
    366  input = shaderNode.addInputFromNodeDef(key)
    +
    367  if input:
    +
    368  # Convert number vector to string
    +
    369  if isinstance(value, list):
    +
    370  value = ','.join([str(x) for x in value])
    +
    371  # Convert number to string:
    +
    372  elif isinstance(value, (int, float)):
    +
    373  value = str(value)
    +
    374  input.setValueString(value)
    +
    375  #else:
    +
    376  # self.logger.debug('Skip unsupported key: ' + key)
    +
    377 
    +
    378  if (transmission != None) and (metallness != None) and (roughness != None) and (color != None):
    +
    379  if (metallness == 0) and (roughness == 0):
    +
    380  if 'transmission_color' in remapKeys:
    +
    381  key = remapKeys['transmission_color']
    +
    382  input = shaderNode.addInputFromNodeDef(key)
    +
    383  if input:
    +
    384  self.loggerlogger.debug(f'Set transmission color {key}: {color}')
    +
    385  value = ','.join([str(x) for x in color])
    +
    386  input.setValueString(value)
    387 
    -
    388  writeOptions = self.mxmx.XmlWriteOptions()
    -
    389  writeOptions.writeXIncludeEnable = False
    -
    390  writeOptions.elementPredicate = self.skipLibraryElementskipLibraryElement
    -
    391  mtlx = self.mxmx.writeToXmlString(self.docdoc, writeOptions)
    -
    392  return mtlx
    +
    388  return self.docdoc
    +
    389 
    +
    390  def writeMaterialXToFile(self, filename):
    +
    391  '''
    +
    392  @brief Write the MaterialX document to disk
    +
    393  @param filename The filename to write the MaterialX document to
    +
    394  @return None
    +
    395  '''
    +
    396  if not self.mxmx:
    +
    397  self.loggerlogger.critical(f'> {self._getMethodName()}: MaterialX module is required')
    +
    398  return
    +
    399 
    +
    400  writeOptions = self.mxmx.XmlWriteOptions()
    +
    401  writeOptions.writeXIncludeEnable = False
    +
    402  writeOptions.elementPredicate = self.skipLibraryElementskipLibraryElement
    +
    403  self.mxmx.writeToXmlFile(self.docdoc, filename, writeOptions)
    +
    404 
    + +
    406  '''
    +
    407  @brief Convert the MaterialX document to a string
    +
    408  @return The MaterialX document as a string
    +
    409  '''
    +
    410  if not self.mxmx:
    +
    411  self.loggerlogger.critical(f'> {self._getMethodName()}: MaterialX module is required')
    +
    412  return
    +
    413 
    +
    414  writeOptions = self.mxmx.XmlWriteOptions()
    +
    415  writeOptions.writeXIncludeEnable = False
    +
    416  writeOptions.elementPredicate = self.skipLibraryElementskipLibraryElement
    +
    417  mtlx = self.mxmx.writeToXmlString(self.docdoc, writeOptions)
    +
    418  return mtlx
    Class to load Physically Based Materials from the PhysicallyBased site.
    dict getInputRemapping(self, shadingModel)
    Get the remapping keys for a given shading model.
    - -
    list getJSONMaterialNames(self)
    Get the list of material names from the JSON object.
    -
    dict loadMaterialsFromString(self, matString)
    Load the Physically Based Materials from a JSON string.
    + +
    list getJSONMaterialNames(self)
    Get the list of material names from the JSON object.
    +
    dict loadMaterialsFromString(self, matString)
    Load the Physically Based Materials from a JSON string.
    -
    dict loadMaterialsFromFile(self, fileName)
    Load the Physically Based Materials from a JSON file.
    +
    dict loadMaterialsFromFile(self, fileName)
    Load the Physically Based Materials from a JSON file.
    def setDebugging(self, debug=True)
    Set the debugging level for the logger.
    def __init__(self, mx_module, mx.Document mx_stdlib=None)
    Constructor for the PhysicallyBasedMaterialLoader class.
    - -
    def convertToMaterialXString(self)
    Convert the MaterialX document to a string.
    - + +
    def convertToMaterialXString(self)
    Convert the MaterialX document to a string.
    + -
    dict getMaterialsFromURL(self)
    Get the Physically Based Materials from the PhysicallyBased site.
    +
    dict getMaterialsFromURL(self)
    Get the Physically Based Materials from the PhysicallyBased site.
    -
    dict getJSON(self)
    Get the JSON object representing the Physically Based Materials.
    - +
    dict getJSON(self)
    Get the JSON object representing the Physically Based Materials.
    +
    def initializeInputRemapping(self)
    Initialize remapping keys for different shading models.
    -
    bool skipLibraryElement(elem)
    Utility to skip library elements when iterating over elements in a document.
    -
    mx.Document convertToMaterialX(self, materialNames=[], shaderCategory='standard_surface', remapKeys={}, shaderPreFix='')
    Convert the Physically Based Materials to MaterialX format for a given target shading model.
    -
    def writeMaterialXToFile(self, filename)
    Write the MaterialX document to disk.
    +
    bool skipLibraryElement(elem)
    Utility to skip library elements when iterating over elements in a document.
    +
    mx.Document convertToMaterialX(self, materialNames=[], shaderCategory='standard_surface', remapKeys={}, shaderPreFix='')
    Convert the Physically Based Materials to MaterialX format for a given target shading model.
    +
    def writeMaterialXToFile(self, filename)
    Write the MaterialX document to disk.
    -
    def addComment(self, doc, commentString)
    Add a comment to the MaterialX document.
    -
    def writeJSONToFile(self, filename)
    Write the materials to a JSON file.
    +
    def addComment(self, doc, commentString)
    Add a comment to the MaterialX document.
    +
    def writeJSONToFile(self, filename)
    Write the materials to a JSON file.
    diff --git a/documents/html/search/all_10.js b/documents/html/search/all_10.js index 3934b81..aebbd2d 100644 --- a/documents/html/search/all_10.js +++ b/documents/html/search/all_10.js @@ -1,5 +1,5 @@ var searchData= [ - ['validatedocument_42',['validateDocument',['../class_js_physically_based_material_loader.html#af3a192ef1a27b937ab8d5b67eeebb808',1,'JsPhysicallyBasedMaterialLoader']]], - ['validatematerialxdocument_43',['validateMaterialXDocument',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a0e370e9ac4e8cefa9ab0136067ed55cf',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]] + ['validatedocument_41',['validateDocument',['../class_js_physically_based_material_loader.html#af3a192ef1a27b937ab8d5b67eeebb808',1,'JsPhysicallyBasedMaterialLoader']]], + ['validatematerialxdocument_42',['validateMaterialXDocument',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a0e370e9ac4e8cefa9ab0136067ed55cf',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]] ]; diff --git a/documents/html/search/all_11.js b/documents/html/search/all_11.js index e023942..563e654 100644 --- a/documents/html/search/all_11.js +++ b/documents/html/search/all_11.js @@ -1,8 +1,8 @@ var searchData= [ - ['writejsontofile_44',['writeJSONToFile',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#aec5e05618ea141395f94a2ecc897ab96',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]], - ['writematerialfiles_45',['writeMaterialFiles',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#a547938c19b0d7e814389a4f6e6da3b1d',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]], - ['writematerialnamestofile_46',['writeMaterialNamesToFile',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#ad058328e04f5400c5d33c93f4a116ea9',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]], - ['writematerialxtofile_47',['writeMaterialXToFile',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#adefb5c1b44257ae287109366909e914c',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]], - ['writepackagedatatofile_48',['writePackageDataToFile',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#a6e21d13a797c2291f867883624ec1e26',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]] + ['writejsontofile_43',['writeJSONToFile',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#aec5e05618ea141395f94a2ecc897ab96',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]], + ['writematerialfiles_44',['writeMaterialFiles',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#a547938c19b0d7e814389a4f6e6da3b1d',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]], + ['writematerialnamestofile_45',['writeMaterialNamesToFile',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#ad058328e04f5400c5d33c93f4a116ea9',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]], + ['writematerialxtofile_46',['writeMaterialXToFile',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#adefb5c1b44257ae287109366909e914c',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]], + ['writepackagedatatofile_47',['writePackageDataToFile',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#a6e21d13a797c2291f867883624ec1e26',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]] ]; diff --git a/documents/html/search/all_6.js b/documents/html/search/all_6.js index eeeceb3..e652191 100644 --- a/documents/html/search/all_6.js +++ b/documents/html/search/all_6.js @@ -10,5 +10,5 @@ var searchData= ['getmaterialxdocument_16',['getMaterialXDocument',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#ab5cb1ede45bf58bfeddb8948fde47a3e',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.getMaterialXDocument()'],['../class_js_physically_based_material_loader.html#a50d3f165475f4b6857db44f46b3e24b9',1,'JsPhysicallyBasedMaterialLoader::getMaterialXDocument()']]], ['getmaterialxstring_17',['getMaterialXString',['../class_js_physically_based_material_loader.html#a7dc871ee8d3fc8aa1f5cc1429f27bc7a',1,'JsPhysicallyBasedMaterialLoader']]], ['getphysicallybasedmaterials_18',['getPhysicallyBasedMaterials',['../class_js_physically_based_material_loader.html#a8faa3eec07fd099bb55a65187b07460d',1,'JsPhysicallyBasedMaterialLoader']]], - ['gpuopenmaterialloader_19',['GPUOpenMaterialLoader',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html',1,'materialxMaterials::GPUOpenLoader']]] + ['gpuopenmaterialloader_19',['GPUOpenMaterialLoader',['../class_g_p_u_open_material_loader.html',1,'GPUOpenMaterialLoader'],['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html',1,'materialxMaterials.GPUOpenLoader.GPUOpenMaterialLoader']]] ]; diff --git a/documents/html/search/all_b.js b/documents/html/search/all_b.js index 92ba7bd..2623af0 100644 --- a/documents/html/search/all_b.js +++ b/documents/html/search/all_b.js @@ -5,6 +5,5 @@ var searchData= ['materials_29',['materials',['../class_js_physically_based_material_loader.html#a57aeca3f4ef045e2f8d844495ea9bcf2',1,'JsPhysicallyBasedMaterialLoader']]], ['mx_30',['mx',['../class_js_physically_based_material_loader.html#aaa493b357111b16358c52bdcd99047b6',1,'JsPhysicallyBasedMaterialLoader']]], ['mxmaterialnames_31',['mxMaterialNames',['../class_js_physically_based_material_loader.html#ab5c494882c44f41a973cd826591c0497',1,'JsPhysicallyBasedMaterialLoader']]], - ['myhttprequesthandler_32',['MyHTTPRequestHandler',['../classmyserver_1_1_my_h_t_t_p_request_handler.html',1,'myserver']]], - ['physicallybasedmaterialx_33',['physicallyBasedMaterialX',['../namespacematerialx_materials_1_1physically_based_material_x.html',1,'materialxMaterials']]] + ['physicallybasedmaterialx_32',['physicallyBasedMaterialX',['../namespacematerialx_materials_1_1physically_based_material_x.html',1,'materialxMaterials']]] ]; diff --git a/documents/html/search/all_c.js b/documents/html/search/all_c.js index aa45625..c1ddae8 100644 --- a/documents/html/search/all_c.js +++ b/documents/html/search/all_c.js @@ -1,5 +1,5 @@ var searchData= [ - ['physicallybasedmaterialloader_34',['PhysicallyBasedMaterialLoader',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html',1,'materialxMaterials::physicallyBasedMaterialX']]], - ['printmaterials_35',['printMaterials',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a836f19e92aeee30884613e4d9e2c4698',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]] + ['physicallybasedmaterialloader_33',['PhysicallyBasedMaterialLoader',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html',1,'materialxMaterials::physicallyBasedMaterialX']]], + ['printmaterials_34',['printMaterials',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a836f19e92aeee30884613e4d9e2c4698',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]] ]; diff --git a/documents/html/search/all_d.js b/documents/html/search/all_d.js index 0821ec9..9d2a76a 100644 --- a/documents/html/search/all_d.js +++ b/documents/html/search/all_d.js @@ -1,5 +1,5 @@ var searchData= [ - ['readmaterialfiles_36',['readMaterialFiles',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#aea6443970a62b7e354441e331e99d962',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]], - ['remapmap_37',['remapMap',['../class_js_physically_based_material_loader.html#a547c339e2799cf483f11af5c1883a5ac',1,'JsPhysicallyBasedMaterialLoader']]] + ['readmaterialfiles_35',['readMaterialFiles',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#aea6443970a62b7e354441e331e99d962',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]], + ['remapmap_36',['remapMap',['../class_js_physically_based_material_loader.html#a547c339e2799cf483f11af5c1883a5ac',1,'JsPhysicallyBasedMaterialLoader']]] ]; diff --git a/documents/html/search/all_e.js b/documents/html/search/all_e.js index 2c9944e..1d0f288 100644 --- a/documents/html/search/all_e.js +++ b/documents/html/search/all_e.js @@ -1,6 +1,6 @@ var searchData= [ - ['setdebugging_38',['setDebugging',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a55f6fd9b37754a25499353a360f7c85c',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]], - ['skiplibraryelement_39',['skipLibraryElement',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#ad188128fa3e0493c5dcb6bf0a139329f',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.skipLibraryElement()'],['../class_js_physically_based_material_loader.html#a0ff670b529d0d01fe96d6e7d656c8f2a',1,'JsPhysicallyBasedMaterialLoader::skipLibraryElement(element)']]], - ['stdlib_40',['stdlib',['../class_js_physically_based_material_loader.html#ac5ea5952dab870a8e936f1974b34a8a6',1,'JsPhysicallyBasedMaterialLoader']]] + ['setdebugging_37',['setDebugging',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a55f6fd9b37754a25499353a360f7c85c',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]], + ['skiplibraryelement_38',['skipLibraryElement',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#ad188128fa3e0493c5dcb6bf0a139329f',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.skipLibraryElement()'],['../class_js_physically_based_material_loader.html#a0ff670b529d0d01fe96d6e7d656c8f2a',1,'JsPhysicallyBasedMaterialLoader::skipLibraryElement(element)']]], + ['stdlib_39',['stdlib',['../class_js_physically_based_material_loader.html#ac5ea5952dab870a8e936f1974b34a8a6',1,'JsPhysicallyBasedMaterialLoader']]] ]; diff --git a/documents/html/search/all_f.js b/documents/html/search/all_f.js index 6938319..c9f4e22 100644 --- a/documents/html/search/all_f.js +++ b/documents/html/search/all_f.js @@ -1,4 +1,4 @@ var searchData= [ - ['url_41',['url',['../class_js_physically_based_material_loader.html#abd951385181b05d2e82d28a0d6fe4918',1,'JsPhysicallyBasedMaterialLoader']]] + ['url_40',['url',['../class_js_physically_based_material_loader.html#abd951385181b05d2e82d28a0d6fe4918',1,'JsPhysicallyBasedMaterialLoader']]] ]; diff --git a/documents/html/search/classes_0.js b/documents/html/search/classes_0.js index 39f8af5..23dd6ce 100644 --- a/documents/html/search/classes_0.js +++ b/documents/html/search/classes_0.js @@ -1,4 +1,4 @@ var searchData= [ - ['gpuopenmaterialloader_49',['GPUOpenMaterialLoader',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html',1,'materialxMaterials::GPUOpenLoader']]] + ['gpuopenmaterialloader_48',['GPUOpenMaterialLoader',['../class_g_p_u_open_material_loader.html',1,'GPUOpenMaterialLoader'],['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html',1,'materialxMaterials.GPUOpenLoader.GPUOpenMaterialLoader']]] ]; diff --git a/documents/html/search/classes_1.js b/documents/html/search/classes_1.js index 0e9345c..974f4d9 100644 --- a/documents/html/search/classes_1.js +++ b/documents/html/search/classes_1.js @@ -1,4 +1,4 @@ var searchData= [ - ['jsphysicallybasedmaterialloader_50',['JsPhysicallyBasedMaterialLoader',['../class_js_physically_based_material_loader.html',1,'']]] + ['jsphysicallybasedmaterialloader_49',['JsPhysicallyBasedMaterialLoader',['../class_js_physically_based_material_loader.html',1,'']]] ]; diff --git a/documents/html/search/classes_2.js b/documents/html/search/classes_2.js index 1656c62..d2a25ad 100644 --- a/documents/html/search/classes_2.js +++ b/documents/html/search/classes_2.js @@ -1,4 +1,4 @@ var searchData= [ - ['myhttprequesthandler_51',['MyHTTPRequestHandler',['../classmyserver_1_1_my_h_t_t_p_request_handler.html',1,'myserver']]] + ['physicallybasedmaterialloader_50',['PhysicallyBasedMaterialLoader',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html',1,'materialxMaterials::physicallyBasedMaterialX']]] ]; diff --git a/documents/html/search/classes_3.js b/documents/html/search/classes_3.js index cf5b1c9..301d59d 100644 --- a/documents/html/search/classes_3.js +++ b/documents/html/search/classes_3.js @@ -1,4 +1,4 @@ var searchData= [ - ['physicallybasedmaterialloader_52',['PhysicallyBasedMaterialLoader',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html',1,'materialxMaterials::physicallyBasedMaterialX']]] + ['physicallybasedmaterialloader_0',['PhysicallyBasedMaterialLoader',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html',1,'materialxMaterials::physicallyBasedMaterialX']]] ]; diff --git a/documents/html/search/functions_0.js b/documents/html/search/functions_0.js index 8f63b8d..0673abd 100644 --- a/documents/html/search/functions_0.js +++ b/documents/html/search/functions_0.js @@ -1,4 +1,4 @@ var searchData= [ - ['_5f_5finit_5f_5f_55',['__init__',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a562aa01290163eac86d6b7a2a8cb7382',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]] + ['_5f_5finit_5f_5f_53',['__init__',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a562aa01290163eac86d6b7a2a8cb7382',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]] ]; diff --git a/documents/html/search/functions_1.js b/documents/html/search/functions_1.js index dd8872e..a6588cb 100644 --- a/documents/html/search/functions_1.js +++ b/documents/html/search/functions_1.js @@ -1,4 +1,4 @@ var searchData= [ - ['addcomment_56',['addComment',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#ae9e0898cb48b3c163eeea4e7c035cc92',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.addComment()'],['../class_js_physically_based_material_loader.html#aedfda1b37416f4385f4c29f6671ad5a7',1,'JsPhysicallyBasedMaterialLoader::addComment()']]] + ['addcomment_54',['addComment',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#ae9e0898cb48b3c163eeea4e7c035cc92',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.addComment()'],['../class_js_physically_based_material_loader.html#aedfda1b37416f4385f4c29f6671ad5a7',1,'JsPhysicallyBasedMaterialLoader::addComment()']]] ]; diff --git a/documents/html/search/functions_2.js b/documents/html/search/functions_2.js index 57e9c71..be67b66 100644 --- a/documents/html/search/functions_2.js +++ b/documents/html/search/functions_2.js @@ -1,6 +1,6 @@ var searchData= [ - ['constructor_57',['constructor',['../class_js_physically_based_material_loader.html#a5f0042da938b9c18e1906422a61962cb',1,'JsPhysicallyBasedMaterialLoader']]], - ['converttomaterialx_58',['convertToMaterialX',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#ad568a7f8abedc69fb614271dd3faff2a',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.convertToMaterialX()'],['../class_js_physically_based_material_loader.html#ae1e44b5689e8a3d9b434ea9828c9ae9d',1,'JsPhysicallyBasedMaterialLoader::convertToMaterialX()']]], - ['converttomaterialxstring_59',['convertToMaterialXString',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a7935dfb3fc52dfa51d4ddef5016d28f7',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]] + ['constructor_55',['constructor',['../class_js_physically_based_material_loader.html#a5f0042da938b9c18e1906422a61962cb',1,'JsPhysicallyBasedMaterialLoader']]], + ['converttomaterialx_56',['convertToMaterialX',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#ad568a7f8abedc69fb614271dd3faff2a',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.convertToMaterialX()'],['../class_js_physically_based_material_loader.html#ae1e44b5689e8a3d9b434ea9828c9ae9d',1,'JsPhysicallyBasedMaterialLoader::convertToMaterialX()']]], + ['converttomaterialxstring_57',['convertToMaterialXString',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a7935dfb3fc52dfa51d4ddef5016d28f7',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]] ]; diff --git a/documents/html/search/functions_3.js b/documents/html/search/functions_3.js index 7aa9827..8b20a17 100644 --- a/documents/html/search/functions_3.js +++ b/documents/html/search/functions_3.js @@ -1,4 +1,4 @@ var searchData= [ - ['downloadpackage_60',['downloadPackage',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#a4f093fe70aa6759e2a137fbff2591c6c',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]] + ['downloadpackage_58',['downloadPackage',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#a4f093fe70aa6759e2a137fbff2591c6c',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]] ]; diff --git a/documents/html/search/functions_4.js b/documents/html/search/functions_4.js index e4b49ae..6c07a2e 100644 --- a/documents/html/search/functions_4.js +++ b/documents/html/search/functions_4.js @@ -1,4 +1,4 @@ var searchData= [ - ['extractpackagedata_61',['extractPackageData',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#accf473c9f3b11dfe6184228bb45c1234',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]] + ['extractpackagedata_59',['extractPackageData',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#accf473c9f3b11dfe6184228bb45c1234',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]] ]; diff --git a/documents/html/search/functions_5.js b/documents/html/search/functions_5.js index 48d9afa..c635f86 100644 --- a/documents/html/search/functions_5.js +++ b/documents/html/search/functions_5.js @@ -1,4 +1,4 @@ var searchData= [ - ['findmaterialsbyname_62',['findMaterialsByName',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#a761935f0293fab3ffb6b852ecf543c64',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]] + ['findmaterialsbyname_60',['findMaterialsByName',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#a761935f0293fab3ffb6b852ecf543c64',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]] ]; diff --git a/documents/html/search/functions_6.js b/documents/html/search/functions_6.js index e119e19..365ecd2 100644 --- a/documents/html/search/functions_6.js +++ b/documents/html/search/functions_6.js @@ -1,13 +1,13 @@ var searchData= [ - ['getinputremapping_63',['getInputRemapping',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a00df7f744ae51556d8f63db4360eef43',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.getInputRemapping()'],['../class_js_physically_based_material_loader.html#a4cb1672349161e2f5b4f7f282814e491',1,'JsPhysicallyBasedMaterialLoader::getInputRemapping()']]], - ['getjson_64',['getJSON',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#aae3e6a57ee0e7f49e394a172d87dc410',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.getJSON()'],['../class_js_physically_based_material_loader.html#a4eec8fc92b4eec481aaf47dc4a8c19f8',1,'JsPhysicallyBasedMaterialLoader::getJSON()']]], - ['getjsonmaterialnames_65',['getJSONMaterialNames',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a0fac543d80540406546451822598309e',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.getJSONMaterialNames()'],['../class_js_physically_based_material_loader.html#a2920d468eb277062a3be0c9b5a149876',1,'JsPhysicallyBasedMaterialLoader::getJSONMaterialNames()']]], - ['getmaterialnames_66',['getMaterialNames',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#adacaa6cff169e56b7df3ddb761ffcde0',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]], - ['getmaterials_67',['getMaterials',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#a19a2e9d18f0191f9576f384d4f3ee4d9',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]], - ['getmaterialsasjsonstring_68',['getMaterialsAsJsonString',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#a9f18efa789dd3a63ef8cd1abdcd38224',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]], - ['getmaterialsfromurl_69',['getMaterialsFromURL',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#aa38eb83c67b0f4c139f523450e1de525',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]], - ['getmaterialxdocument_70',['getMaterialXDocument',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#ab5cb1ede45bf58bfeddb8948fde47a3e',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.getMaterialXDocument()'],['../class_js_physically_based_material_loader.html#a50d3f165475f4b6857db44f46b3e24b9',1,'JsPhysicallyBasedMaterialLoader::getMaterialXDocument()']]], - ['getmaterialxstring_71',['getMaterialXString',['../class_js_physically_based_material_loader.html#a7dc871ee8d3fc8aa1f5cc1429f27bc7a',1,'JsPhysicallyBasedMaterialLoader']]], - ['getphysicallybasedmaterials_72',['getPhysicallyBasedMaterials',['../class_js_physically_based_material_loader.html#a8faa3eec07fd099bb55a65187b07460d',1,'JsPhysicallyBasedMaterialLoader']]] + ['getinputremapping_61',['getInputRemapping',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a00df7f744ae51556d8f63db4360eef43',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.getInputRemapping()'],['../class_js_physically_based_material_loader.html#a4cb1672349161e2f5b4f7f282814e491',1,'JsPhysicallyBasedMaterialLoader::getInputRemapping()']]], + ['getjson_62',['getJSON',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#aae3e6a57ee0e7f49e394a172d87dc410',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.getJSON()'],['../class_js_physically_based_material_loader.html#a4eec8fc92b4eec481aaf47dc4a8c19f8',1,'JsPhysicallyBasedMaterialLoader::getJSON()']]], + ['getjsonmaterialnames_63',['getJSONMaterialNames',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a0fac543d80540406546451822598309e',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.getJSONMaterialNames()'],['../class_js_physically_based_material_loader.html#a2920d468eb277062a3be0c9b5a149876',1,'JsPhysicallyBasedMaterialLoader::getJSONMaterialNames()']]], + ['getmaterialnames_64',['getMaterialNames',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#adacaa6cff169e56b7df3ddb761ffcde0',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]], + ['getmaterials_65',['getMaterials',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#a19a2e9d18f0191f9576f384d4f3ee4d9',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]], + ['getmaterialsasjsonstring_66',['getMaterialsAsJsonString',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#a9f18efa789dd3a63ef8cd1abdcd38224',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]], + ['getmaterialsfromurl_67',['getMaterialsFromURL',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#aa38eb83c67b0f4c139f523450e1de525',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]], + ['getmaterialxdocument_68',['getMaterialXDocument',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#ab5cb1ede45bf58bfeddb8948fde47a3e',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.getMaterialXDocument()'],['../class_js_physically_based_material_loader.html#a50d3f165475f4b6857db44f46b3e24b9',1,'JsPhysicallyBasedMaterialLoader::getMaterialXDocument()']]], + ['getmaterialxstring_69',['getMaterialXString',['../class_js_physically_based_material_loader.html#a7dc871ee8d3fc8aa1f5cc1429f27bc7a',1,'JsPhysicallyBasedMaterialLoader']]], + ['getphysicallybasedmaterials_70',['getPhysicallyBasedMaterials',['../class_js_physically_based_material_loader.html#a8faa3eec07fd099bb55a65187b07460d',1,'JsPhysicallyBasedMaterialLoader']]] ]; diff --git a/documents/html/search/functions_7.js b/documents/html/search/functions_7.js index b17b888..b01bf5f 100644 --- a/documents/html/search/functions_7.js +++ b/documents/html/search/functions_7.js @@ -1,4 +1,4 @@ var searchData= [ - ['initializeinputremapping_73',['initializeInputRemapping',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#abd638d0f058fc0c5b15858c28c759df3',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.initializeInputRemapping()'],['../class_js_physically_based_material_loader.html#a35561414959983ac09c200bd74bacc9a',1,'JsPhysicallyBasedMaterialLoader::initializeInputRemapping()']]] + ['initializeinputremapping_71',['initializeInputRemapping',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#abd638d0f058fc0c5b15858c28c759df3',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.initializeInputRemapping()'],['../class_js_physically_based_material_loader.html#a35561414959983ac09c200bd74bacc9a',1,'JsPhysicallyBasedMaterialLoader::initializeInputRemapping()']]] ]; diff --git a/documents/html/search/functions_8.js b/documents/html/search/functions_8.js index b0e9619..a0f0516 100644 --- a/documents/html/search/functions_8.js +++ b/documents/html/search/functions_8.js @@ -1,7 +1,7 @@ var searchData= [ - ['loadmaterialsfromfile_74',['loadMaterialsFromFile',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a1695a75528ef0135abd02f6aab93d2c9',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]], - ['loadmaterialsfromstring_75',['loadMaterialsFromString',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a14c9374702631d0c03e305fb57b0c45c',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]], - ['loadmaterialx_76',['loadMaterialX',['../class_js_physically_based_material_loader.html#a61db9877dc4783b689e4091cebcc8de8',1,'JsPhysicallyBasedMaterialLoader']]], - ['loadstandardlibraries_77',['loadStandardLibraries',['../class_js_physically_based_material_loader.html#a5a31fc8486c2df7204263a0ca9af9410',1,'JsPhysicallyBasedMaterialLoader']]] + ['loadmaterialsfromfile_72',['loadMaterialsFromFile',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a1695a75528ef0135abd02f6aab93d2c9',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]], + ['loadmaterialsfromstring_73',['loadMaterialsFromString',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a14c9374702631d0c03e305fb57b0c45c',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]], + ['loadmaterialx_74',['loadMaterialX',['../class_js_physically_based_material_loader.html#a61db9877dc4783b689e4091cebcc8de8',1,'JsPhysicallyBasedMaterialLoader']]], + ['loadstandardlibraries_75',['loadStandardLibraries',['../class_js_physically_based_material_loader.html#a5a31fc8486c2df7204263a0ca9af9410',1,'JsPhysicallyBasedMaterialLoader']]] ]; diff --git a/documents/html/search/functions_9.js b/documents/html/search/functions_9.js index 0021ee5..6a58b45 100644 --- a/documents/html/search/functions_9.js +++ b/documents/html/search/functions_9.js @@ -1,4 +1,4 @@ var searchData= [ - ['printmaterials_78',['printMaterials',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a836f19e92aeee30884613e4d9e2c4698',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]] + ['printmaterials_76',['printMaterials',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a836f19e92aeee30884613e4d9e2c4698',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]] ]; diff --git a/documents/html/search/functions_a.js b/documents/html/search/functions_a.js index 8d8469d..21b7502 100644 --- a/documents/html/search/functions_a.js +++ b/documents/html/search/functions_a.js @@ -1,4 +1,4 @@ var searchData= [ - ['readmaterialfiles_79',['readMaterialFiles',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#aea6443970a62b7e354441e331e99d962',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]] + ['readmaterialfiles_77',['readMaterialFiles',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#aea6443970a62b7e354441e331e99d962',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]] ]; diff --git a/documents/html/search/functions_b.js b/documents/html/search/functions_b.js index 3e48cdc..1e9713c 100644 --- a/documents/html/search/functions_b.js +++ b/documents/html/search/functions_b.js @@ -1,5 +1,5 @@ var searchData= [ - ['setdebugging_80',['setDebugging',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a55f6fd9b37754a25499353a360f7c85c',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]], - ['skiplibraryelement_81',['skipLibraryElement',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#ad188128fa3e0493c5dcb6bf0a139329f',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.skipLibraryElement()'],['../class_js_physically_based_material_loader.html#a0ff670b529d0d01fe96d6e7d656c8f2a',1,'JsPhysicallyBasedMaterialLoader::skipLibraryElement()']]] + ['setdebugging_78',['setDebugging',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a55f6fd9b37754a25499353a360f7c85c',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]], + ['skiplibraryelement_79',['skipLibraryElement',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#ad188128fa3e0493c5dcb6bf0a139329f',1,'materialxMaterials.physicallyBasedMaterialX.PhysicallyBasedMaterialLoader.skipLibraryElement()'],['../class_js_physically_based_material_loader.html#a0ff670b529d0d01fe96d6e7d656c8f2a',1,'JsPhysicallyBasedMaterialLoader::skipLibraryElement()']]] ]; diff --git a/documents/html/search/functions_c.js b/documents/html/search/functions_c.js index 6269e7e..8ce3b76 100644 --- a/documents/html/search/functions_c.js +++ b/documents/html/search/functions_c.js @@ -1,5 +1,5 @@ var searchData= [ - ['validatedocument_82',['validateDocument',['../class_js_physically_based_material_loader.html#af3a192ef1a27b937ab8d5b67eeebb808',1,'JsPhysicallyBasedMaterialLoader']]], - ['validatematerialxdocument_83',['validateMaterialXDocument',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a0e370e9ac4e8cefa9ab0136067ed55cf',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]] + ['validatedocument_80',['validateDocument',['../class_js_physically_based_material_loader.html#af3a192ef1a27b937ab8d5b67eeebb808',1,'JsPhysicallyBasedMaterialLoader']]], + ['validatematerialxdocument_81',['validateMaterialXDocument',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#a0e370e9ac4e8cefa9ab0136067ed55cf',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]] ]; diff --git a/documents/html/search/functions_d.js b/documents/html/search/functions_d.js index 2976d95..9469e80 100644 --- a/documents/html/search/functions_d.js +++ b/documents/html/search/functions_d.js @@ -1,8 +1,8 @@ var searchData= [ - ['writejsontofile_84',['writeJSONToFile',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#aec5e05618ea141395f94a2ecc897ab96',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]], - ['writematerialfiles_85',['writeMaterialFiles',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#a547938c19b0d7e814389a4f6e6da3b1d',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]], - ['writematerialnamestofile_86',['writeMaterialNamesToFile',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#ad058328e04f5400c5d33c93f4a116ea9',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]], - ['writematerialxtofile_87',['writeMaterialXToFile',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#adefb5c1b44257ae287109366909e914c',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]], - ['writepackagedatatofile_88',['writePackageDataToFile',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#a6e21d13a797c2291f867883624ec1e26',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]] + ['writejsontofile_82',['writeJSONToFile',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#aec5e05618ea141395f94a2ecc897ab96',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]], + ['writematerialfiles_83',['writeMaterialFiles',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#a547938c19b0d7e814389a4f6e6da3b1d',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]], + ['writematerialnamestofile_84',['writeMaterialNamesToFile',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#ad058328e04f5400c5d33c93f4a116ea9',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]], + ['writematerialxtofile_85',['writeMaterialXToFile',['../classmaterialx_materials_1_1physically_based_material_x_1_1_physically_based_material_loader.html#adefb5c1b44257ae287109366909e914c',1,'materialxMaterials::physicallyBasedMaterialX::PhysicallyBasedMaterialLoader']]], + ['writepackagedatatofile_86',['writePackageDataToFile',['../classmaterialx_materials_1_1_g_p_u_open_loader_1_1_g_p_u_open_material_loader.html#a6e21d13a797c2291f867883624ec1e26',1,'materialxMaterials::GPUOpenLoader::GPUOpenMaterialLoader']]] ]; diff --git a/documents/html/search/mag.svg b/documents/html/search/mag.svg new file mode 100644 index 0000000..9f46b30 --- /dev/null +++ b/documents/html/search/mag.svg @@ -0,0 +1,37 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/documents/html/search/mag_d.svg b/documents/html/search/mag_d.svg new file mode 100644 index 0000000..b9a814c --- /dev/null +++ b/documents/html/search/mag_d.svg @@ -0,0 +1,37 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/documents/html/search/mag_seld.svg b/documents/html/search/mag_seld.svg new file mode 100644 index 0000000..6e720dc --- /dev/null +++ b/documents/html/search/mag_seld.svg @@ -0,0 +1,74 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/documents/html/search/namespaces_0.js b/documents/html/search/namespaces_0.js index 978ab54..16333d3 100644 --- a/documents/html/search/namespaces_0.js +++ b/documents/html/search/namespaces_0.js @@ -1,5 +1,5 @@ var searchData= [ - ['gpuopenloader_53',['GPUOpenLoader',['../namespacematerialx_materials_1_1_g_p_u_open_loader.html',1,'materialxMaterials']]], - ['physicallybasedmaterialx_54',['physicallyBasedMaterialX',['../namespacematerialx_materials_1_1physically_based_material_x.html',1,'materialxMaterials']]] + ['gpuopenloader_51',['GPUOpenLoader',['../namespacematerialx_materials_1_1_g_p_u_open_loader.html',1,'materialxMaterials']]], + ['physicallybasedmaterialx_52',['physicallyBasedMaterialX',['../namespacematerialx_materials_1_1physically_based_material_x.html',1,'materialxMaterials']]] ]; diff --git a/documents/html/search/pages_0.js b/documents/html/search/pages_0.js new file mode 100644 index 0000000..900c3be --- /dev/null +++ b/documents/html/search/pages_0.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['materialxmaterials_0',['MaterialXMaterials',['../index.html',1,'']]] +]; diff --git a/documents/html/search/searchdata.js b/documents/html/search/searchdata.js index 6399bfc..fb8c62b 100644 --- a/documents/html/search/searchdata.js +++ b/documents/html/search/searchdata.js @@ -1,7 +1,7 @@ var indexSectionsWithContent = { 0: "_acdefghijlmprsuvw", - 1: "gjmp", + 1: "gjp", 2: "m", 3: "_acdefgilprsvw", 4: "dhmrsu" diff --git a/documents/html/search/variables_0.js b/documents/html/search/variables_0.js index 16811ed..193ce1a 100644 --- a/documents/html/search/variables_0.js +++ b/documents/html/search/variables_0.js @@ -1,4 +1,4 @@ var searchData= [ - ['doc_89',['doc',['../class_js_physically_based_material_loader.html#a19ba3f660663b91ec2be3fe81b45b2b4',1,'JsPhysicallyBasedMaterialLoader']]] + ['doc_87',['doc',['../class_js_physically_based_material_loader.html#a19ba3f660663b91ec2be3fe81b45b2b4',1,'JsPhysicallyBasedMaterialLoader']]] ]; diff --git a/documents/html/search/variables_1.js b/documents/html/search/variables_1.js index 19c5a4c..6666b4f 100644 --- a/documents/html/search/variables_1.js +++ b/documents/html/search/variables_1.js @@ -1,4 +1,4 @@ var searchData= [ - ['headers_90',['headers',['../class_js_physically_based_material_loader.html#ab92e487175c47f2d8f2c9ce2f8500765',1,'JsPhysicallyBasedMaterialLoader']]] + ['headers_88',['headers',['../class_js_physically_based_material_loader.html#ab92e487175c47f2d8f2c9ce2f8500765',1,'JsPhysicallyBasedMaterialLoader']]] ]; diff --git a/documents/html/search/variables_2.js b/documents/html/search/variables_2.js index aa7b16a..f3bcdcc 100644 --- a/documents/html/search/variables_2.js +++ b/documents/html/search/variables_2.js @@ -1,7 +1,7 @@ var searchData= [ - ['materialnames_91',['materialNames',['../class_js_physically_based_material_loader.html#a928e3076af0dcaf80dd46476c854a574',1,'JsPhysicallyBasedMaterialLoader']]], - ['materials_92',['materials',['../class_js_physically_based_material_loader.html#a57aeca3f4ef045e2f8d844495ea9bcf2',1,'JsPhysicallyBasedMaterialLoader']]], - ['mx_93',['mx',['../class_js_physically_based_material_loader.html#aaa493b357111b16358c52bdcd99047b6',1,'JsPhysicallyBasedMaterialLoader']]], - ['mxmaterialnames_94',['mxMaterialNames',['../class_js_physically_based_material_loader.html#ab5c494882c44f41a973cd826591c0497',1,'JsPhysicallyBasedMaterialLoader']]] + ['materialnames_89',['materialNames',['../class_js_physically_based_material_loader.html#a928e3076af0dcaf80dd46476c854a574',1,'JsPhysicallyBasedMaterialLoader']]], + ['materials_90',['materials',['../class_js_physically_based_material_loader.html#a57aeca3f4ef045e2f8d844495ea9bcf2',1,'JsPhysicallyBasedMaterialLoader']]], + ['mx_91',['mx',['../class_js_physically_based_material_loader.html#aaa493b357111b16358c52bdcd99047b6',1,'JsPhysicallyBasedMaterialLoader']]], + ['mxmaterialnames_92',['mxMaterialNames',['../class_js_physically_based_material_loader.html#ab5c494882c44f41a973cd826591c0497',1,'JsPhysicallyBasedMaterialLoader']]] ]; diff --git a/documents/html/search/variables_3.js b/documents/html/search/variables_3.js index de463de..96c71d8 100644 --- a/documents/html/search/variables_3.js +++ b/documents/html/search/variables_3.js @@ -1,4 +1,4 @@ var searchData= [ - ['remapmap_95',['remapMap',['../class_js_physically_based_material_loader.html#a547c339e2799cf483f11af5c1883a5ac',1,'JsPhysicallyBasedMaterialLoader']]] + ['remapmap_93',['remapMap',['../class_js_physically_based_material_loader.html#a547c339e2799cf483f11af5c1883a5ac',1,'JsPhysicallyBasedMaterialLoader']]] ]; diff --git a/documents/html/search/variables_4.js b/documents/html/search/variables_4.js index 5411b91..4cdcae9 100644 --- a/documents/html/search/variables_4.js +++ b/documents/html/search/variables_4.js @@ -1,4 +1,4 @@ var searchData= [ - ['stdlib_96',['stdlib',['../class_js_physically_based_material_loader.html#ac5ea5952dab870a8e936f1974b34a8a6',1,'JsPhysicallyBasedMaterialLoader']]] + ['stdlib_94',['stdlib',['../class_js_physically_based_material_loader.html#ac5ea5952dab870a8e936f1974b34a8a6',1,'JsPhysicallyBasedMaterialLoader']]] ]; diff --git a/documents/html/search/variables_5.js b/documents/html/search/variables_5.js index 50b2eb3..684b6a5 100644 --- a/documents/html/search/variables_5.js +++ b/documents/html/search/variables_5.js @@ -1,4 +1,4 @@ var searchData= [ - ['url_97',['url',['../class_js_physically_based_material_loader.html#abd951385181b05d2e82d28a0d6fe4918',1,'JsPhysicallyBasedMaterialLoader']]] + ['url_95',['url',['../class_js_physically_based_material_loader.html#abd951385181b05d2e82d28a0d6fe4918',1,'JsPhysicallyBasedMaterialLoader']]] ]; diff --git a/documents/html/splitbard.png b/documents/html/splitbard.png new file mode 100644 index 0000000..8367416 Binary files /dev/null and b/documents/html/splitbard.png differ diff --git a/documents/html/tab_ad.png b/documents/html/tab_ad.png new file mode 100644 index 0000000..e34850a Binary files /dev/null and b/documents/html/tab_ad.png differ diff --git a/documents/html/tab_bd.png b/documents/html/tab_bd.png new file mode 100644 index 0000000..91c2524 Binary files /dev/null and b/documents/html/tab_bd.png differ diff --git a/documents/html/tab_hd.png b/documents/html/tab_hd.png new file mode 100644 index 0000000..2489273 Binary files /dev/null and b/documents/html/tab_hd.png differ diff --git a/documents/html/tab_sd.png b/documents/html/tab_sd.png new file mode 100644 index 0000000..757a565 Binary files /dev/null and b/documents/html/tab_sd.png differ diff --git a/index.html b/index.html index 022db82..739c510 100644 --- a/index.html +++ b/index.html @@ -89,6 +89,7 @@

    Dependencies

    1. The MaterialX 1.39 or greater package for PhysicallyBased OpenPBR shader creation
    2. The requests package.
    3. +
    4. The pillow package for image handling for GPUOpen package handling

    Building

    The GitHub repository can be cloned and the package built using:

    diff --git a/javascript/JsMaterialXPhysicallyBased.js b/javascript/JsMaterialXPhysicallyBased.js index 22e0a53..fe50ec0 100644 --- a/javascript/JsMaterialXPhysicallyBased.js +++ b/javascript/JsMaterialXPhysicallyBased.js @@ -149,6 +149,7 @@ class JsPhysicallyBasedMaterialLoader { //'metalness': 'metalness', 'ior': 'specular_IOR', //'transmission': 'transmission', + 'transmission_color': 'transmission_color', 'thinFilmIor': 'thin_film_IOR', 'thinFilmThickness': 'thin_film_thickness', 'transmissionDispersion': 'transmission_dispersion', @@ -161,6 +162,7 @@ class JsPhysicallyBasedMaterialLoader { 'metalness': 'base_metalness', 'ior': 'specular_ior', 'transmission': 'transmission_weight', + 'transmission_color': 'transmission_color', 'subsurfaceRadius': 'subsurface_radius', 'thinFilmIor': 'thinfilm_ior', 'thinFilmThickness': 'thinfilm_thickness', @@ -381,8 +383,31 @@ class JsPhysicallyBasedMaterialLoader { // to Autodesk Standard Surface shader inputs const skipKeys = ['name', "density", "category", "description", "sources", "tags", "reference"]; + let metallness = null; + let roughness = null; + let transmission_color = null; + let transmission = null; Object.entries(mat).forEach(([key, value]) => { + if (!skipKeys.includes(key)) { + + if (key == 'metalness') { + metallness = value; + //console.log('Metalness:', metallness); + } + if (key == 'roughness') { + roughness = value; + //console.log('Roughness:', roughness); + } + if (key == 'transmission') { + transmission = value; + //console.log('Transmission:', transmission); + } + if (key == 'color') { + transmission_color = value; + //console.log('Color:', color); + } + if (remapKeys[key]) { key = remapKeys[key]; } @@ -413,6 +438,22 @@ class JsPhysicallyBasedMaterialLoader { } } }); + + if (transmission !== null && metallness !== null && roughness !== null && transmission_color !== null) + { + if (metallness == 0 && roughness == 0) + { + if (remapKeys['transmission_color']) { + let inputName = remapKeys['transmission_color']; + let input = shaderNode.addInput(inputName); + if (input) { + let value = transmission_color.join(','); + console.log(`Add "${inputName}": "${value}"`); + input.setValueString(value, 'color3'); + } + } + } + }; } return true; } diff --git a/pyproject.toml b/pyproject.toml index 74cb85a..7c2aadf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,7 @@ classifiers = [ dependencies = [ "materialx>=1.39", "requests", + "pillow" ] [tool.setuptools.packages.find] diff --git a/src/materialxMaterials.egg-info/PKG-INFO b/src/materialxMaterials.egg-info/PKG-INFO index e2248a4..e25b42d 100644 --- a/src/materialxMaterials.egg-info/PKG-INFO +++ b/src/materialxMaterials.egg-info/PKG-INFO @@ -219,6 +219,7 @@ Description-Content-Type: text/markdown License-File: LICENSE Requires-Dist: materialx>=1.39 Requires-Dist: requests +Requires-Dist: pillow diff --git a/src/materialxMaterials.egg-info/requires.txt b/src/materialxMaterials.egg-info/requires.txt index 35a101b..cc2aa67 100644 --- a/src/materialxMaterials.egg-info/requires.txt +++ b/src/materialxMaterials.egg-info/requires.txt @@ -1,2 +1,3 @@ materialx>=1.39 requests +pillow diff --git a/src/materialxMaterials/data/PhysicallyBasedMaterialX/PhysicallyBasedMaterialX_OPBR.mtlx b/src/materialxMaterials/data/PhysicallyBasedMaterialX/PhysicallyBasedMaterialX_OPBR.mtlx index 2055caa..aec0fcf 100644 --- a/src/materialxMaterials/data/PhysicallyBasedMaterialX/PhysicallyBasedMaterialX_OPBR.mtlx +++ b/src/materialxMaterials/data/PhysicallyBasedMaterialX/PhysicallyBasedMaterialX_OPBR.mtlx @@ -45,6 +45,7 @@ + @@ -171,6 +172,7 @@ + @@ -196,6 +198,7 @@ + @@ -219,6 +222,7 @@ + @@ -231,6 +235,7 @@ + @@ -254,6 +259,7 @@ + @@ -267,6 +273,7 @@ + @@ -302,6 +309,7 @@ + @@ -457,6 +465,7 @@ + @@ -469,6 +478,7 @@ + @@ -481,6 +491,7 @@ + @@ -493,6 +504,7 @@ + @@ -505,6 +517,7 @@ + @@ -529,6 +542,7 @@ + @@ -565,6 +579,7 @@ + @@ -683,6 +698,7 @@ + @@ -743,6 +759,7 @@ + diff --git a/src/materialxMaterials/data/PhysicallyBasedMaterialX/PhysicallyBasedMaterialX_SS.mtlx b/src/materialxMaterials/data/PhysicallyBasedMaterialX/PhysicallyBasedMaterialX_SS.mtlx index fadec96..765989e 100644 --- a/src/materialxMaterials/data/PhysicallyBasedMaterialX/PhysicallyBasedMaterialX_SS.mtlx +++ b/src/materialxMaterials/data/PhysicallyBasedMaterialX/PhysicallyBasedMaterialX_SS.mtlx @@ -45,6 +45,7 @@ + @@ -170,6 +171,7 @@ + @@ -195,6 +197,7 @@ + @@ -218,6 +221,7 @@ + @@ -230,6 +234,7 @@ + @@ -253,6 +258,7 @@ + @@ -266,6 +272,7 @@ + @@ -301,6 +308,7 @@ + @@ -453,6 +461,7 @@ + @@ -465,6 +474,7 @@ + @@ -477,6 +487,7 @@ + @@ -489,6 +500,7 @@ + @@ -501,6 +513,7 @@ + @@ -525,6 +538,7 @@ + @@ -561,6 +575,7 @@ + @@ -675,6 +690,7 @@ + @@ -735,6 +751,7 @@ + diff --git a/src/materialxMaterials/physicallyBasedMaterialX.py b/src/materialxMaterials/physicallyBasedMaterialX.py index 8b62e38..8fce013 100644 --- a/src/materialxMaterials/physicallyBasedMaterialX.py +++ b/src/materialxMaterials/physicallyBasedMaterialX.py @@ -92,6 +92,7 @@ def initializeInputRemapping(self): #'metalness': 'metalness', 'ior': 'specular_IOR', #'transmission': 'transmission', + 'transmission_color': 'transmission_color', 'thinFilmIor' : 'thin_film_IOR', 'thinFilmThickness' : 'thin_film_thickness', 'transmissionDispersion' : 'transmission_dispersion', @@ -104,6 +105,7 @@ def initializeInputRemapping(self): 'metalness': 'base_metalness', 'ior': 'specular_ior', 'transmission': 'transmission_weight', + 'transmission_color': 'transmission_color', 'subsurfaceRadius': 'subsurface_radius', 'thinFilmIor' : 'thinfilm_ior', 'thinFilmThickness' : 'thinfilm_thickness', @@ -343,8 +345,22 @@ def convertToMaterialX(self, materialNames = [], shaderCategory='standard_surfac # Keys to skip. skipKeys = ['name', "density", "category", "description", "sources", "tags", "reference"] + metallness = None + roughness = None + color = None + transmission = None for key, value in mat.items(): + if (key not in skipKeys): + if key == 'metalness': + metallness = value + if key == 'roughness': + roughness = value + if key == 'transmission': + transmission = value + if key == 'color': + color = value + if key in remapKeys: key = remapKeys[key] input = shaderNode.addInputFromNodeDef(key) @@ -359,6 +375,16 @@ def convertToMaterialX(self, materialNames = [], shaderCategory='standard_surfac #else: # self.logger.debug('Skip unsupported key: ' + key) + if (transmission != None) and (metallness != None) and (roughness != None) and (color != None): + if (metallness == 0) and (roughness == 0): + if 'transmission_color' in remapKeys: + key = remapKeys['transmission_color'] + input = shaderNode.addInputFromNodeDef(key) + if input: + self.logger.debug(f'Set transmission color {key}: {color}') + value = ','.join([str(x) for x in color]) + input.setValueString(value) + return self.doc def writeMaterialXToFile(self, filename): diff --git a/myserver.py b/utilities/myserver.py similarity index 100% rename from myserver.py rename to utilities/myserver.py