PrismPipeline / QuiltiX

QuiltiX is a graphical node editor to edit, and author MaterialX based materials of 3D assets
https://pypi.org/project/QuiltiX
Apache License 2.0
259 stars 27 forks source link

Update of vector2 types does not work #52

Closed kwokcb closed 7 months ago

kwokcb commented 7 months ago

Issue

The code which handles updates of vectors does not handle vector2 type. e.g. if you update uvtiling on an tiled_image node you get this:

DEBUG:QuiltiX.qx_nodegraph:property changed uvtiling - [2.0, 1.0]
Traceback (most recent call last):
  File "C:\Users\home\AppData\Local\Programs\Python\Python310\lib\site-packages\QuiltiX\usd_stage.py", line 202, in update_parameter
    usdinput.GetAttr().Set(property_value)
pxr.Tf.ErrorException:
        Error in 'pxrInternal_v0_23__pxrReserved__::UsdStage::_SetValueImpl' at line 6697 in file W:\257786efc4f464db\USD\pxr\usd\usd\stage.cpp : 'Type mismatch for </MaterialX/NodeGraphs/NG_main/Tiledimage.inputs:uvtiling>: expected 'GfVec2f', got 'vector<VtValue,allocator<VtValue> >''

Proposed Fix

Add in vector2 handling into update_parameter on MxStageController.

Example test file:

<?xml version="1.0"?>
<materialx version="1.38">
  <nodegraph name="NG_main">
    <tiledimage name="Tiledimage" type="float" xpos="0.47671583577553067" ypos="2.023793642443287">
      <input name="file" type="filename" />
      <input name="default" type="float" value="0" />
      <input name="texcoord" type="vector2" value="0, 0" />
      <input name="uvtiling" type="vector2" value="2, 1" />
      <input name="uvoffset" type="vector2" value="0, 0" />
      <input name="realworldimagesize" type="vector2" value="1, 1" />
      <input name="realworldtilesize" type="vector2" value="1, 1" />
      <input name="filtertype" type="string" value="linear" />
      <input name="framerange" type="string" value="" />
      <input name="frameoffset" type="integer" value="0" />
      <input name="frameendaction" type="string" value="constant" />
    </tiledimage>
    <output name="output_Tiledimage_out" type="float" nodename="Tiledimage" />
  </nodegraph>
  <surfacematerial name="USD_Default" type="material" xpos="8.315040402794196" ypos="1.6460188291872069">
    <input name="surfaceshader" type="surfaceshader" nodename="Gltf_pbr" />
  </surfacematerial>
  <gltf_pbr name="Gltf_pbr" type="surfaceshader" xpos="4.85710474186389" ypos="1.8169169589935277">
    <input name="base_color" type="color3" value="1, 1, 1" />
    <input name="metallic" type="float" value="1" nodegraph="NG_main" output="output_Tiledimage_out" />
    <input name="roughness" type="float" value="0.18" />
    <input name="normal" type="vector3" value="0, 0, 0" />
    <input name="tangent" type="vector3" value="0, 0, 0" />
    <input name="occlusion" type="float" value="1" />
    <input name="transmission" type="float" value="0" />
    <input name="specular" type="float" value="1" />
    <input name="specular_color" type="color3" value="1, 1, 1" />
    <input name="ior" type="float" value="1.5" />
    <input name="alpha" type="float" value="1" />
    <input name="alpha_mode" type="integer" value="0" />
    <input name="alpha_cutoff" type="float" value="0.5" />
    <input name="iridescence" type="float" value="0" />
    <input name="iridescence_ior" type="float" value="1.3" />
    <input name="iridescence_thickness" type="float" value="100" />
    <input name="sheen_color" type="color3" value="0, 0, 0" />
    <input name="sheen_roughness" type="float" value="0" />
    <input name="clearcoat" type="float" value="0" />
    <input name="clearcoat_roughness" type="float" value="0" />
    <input name="clearcoat_normal" type="vector3" value="0, 0, 0" />
    <input name="emissive" type="color3" value="0, 0, 0" />
    <input name="emissive_strength" type="float" value="1" />
    <input name="thickness" type="float" value="0" />
    <input name="attenuation_distance" type="float" value="0" />
    <input name="attenuation_color" type="color3" value="1, 1, 1" />
  </gltf_pbr>
</materialx>
RichardFrangenberg commented 7 months ago

fixed, thanks to your pull request.