MaterialX icon indicating copy to clipboard operation
MaterialX copied to clipboard

Graph Editor - UI support for enum

Open inter-sakot4 opened this issue 6 months ago • 4 comments

Description In this PR, UI support for enumerator types are added to GraphEditor.

Some assumptions are made to execute this task:

  • Fix the issue for only GraphEditor , though similar issue exist also in MaterialXView ( NanoGUI )
  • Generalize the solution to int, bool, string, float, double, Vector2, Vector3, Vector4, Color3, Color4, Matrix types

With the above assumptions, scope of this task is limited only to GraphEditor ( IMGUI )

Solution

  • renderEnumInput<input_type>(input, uiProperties, temp) is a template function that does the rendering of enumerator input types.

Following edge cases are handled:

  • ui.enumerationValues and ui.ui.enumeration are not always populated ( See /MaterialXRender/Util.cpp ). In such cases, the enum and enumvalues are parsed directly from the attribute values to render the enumerators.
  • Its common to have string input with enum fields only , but no enumvalues

How to test?

Slightly modified standard_surface_jade.mtlx can be used like below.

<?xml version="1.0"?>
<materialx version="1.39" colorspace="lin_rec709">
  <standard_surface name="SR_jade" type="surfaceshader">
    <input name="base" type="float" value="0.5" />
    <input name="base_color" type="color3" value="0.0603,0.4398,0.1916" />
    <input name="specular_roughness" type="float" value="0.25" enum="0.0, 0.25, 0.5, 0.75" enumvalues="0.0,0.25,0.5,0.75"/>
    <input name="specular_IOR" type="float" value="2.418" />
    <input name="specular_anisotropy" type="float" value="0.5" />
    <input name="subsurface" type="float" value="0.4" enum="0.0,0.4,0.5,0.6,0.7" enumvalues="0.0,0.4,0.5,0.6,0.7" />
    <input name="subsurface_color" type="color3" value="0.0603, 0.4398, 0.1916" enum="DEFAULT_GREEN, RED" enumvalues="0.0603,0.4398,0.1916,0.8,0.04398,0.01916" />
  </standard_surface>
  <surfacematerial name="Jade" type="material">
    <input name="surfaceshader" type="surfaceshader" nodename="SR_jade" />
  </surfacematerial>
</materialx>

Expected Result

image

inter-sakot4 avatar May 16 '25 11:05 inter-sakot4

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: inter-sakot4 / name: Sathish Kottravel (d87fcb20449423960c1a321ba07095912e34d220, d74e1a10811557372fc30bb9ceaf29f38202698e, 34acd1504eee47f776ea5dca0f858659f6816648, 303be86572ee518d7008470298a8f5d8a9d02c26, 3eba34799562c019e8f0cf88c4a4503bb76bb772, 71406652a3861d59822e98b02567a798de77c4d9)
  • :white_check_mark: login: jstone-lucasfilm / name: Jonathan Stone (82453d16af91731b1f7f2f28ccea4066c0f46ff8, 9c12b05cf7f8886f48e927f4c9a45d0cd3f63f88)

Thanks @inter-sakot4, and I'll link this to GitHub Issue https://github.com/AcademySoftwareFoundation/MaterialX/issues/2366.

jstone-lucasfilm avatar May 17 '25 16:05 jstone-lucasfilm

I closed my related PR #2438 because yours looks much more complete, but my test file does not actually show a dropdown UI when I build from this PR @inter-sakot4.

Here's the test file that doesn't bring up a dropdown: MyKeywordGraph.mtlx.zip

Should look like this: image

hybridherbst avatar Jun 04 '25 21:06 hybridherbst

@inter-sakot4 Just following up on this PR, to see if you might have a chance to address the issue brought up by @hybridherbst above!

jstone-lucasfilm avatar Jul 13 '25 17:07 jstone-lucasfilm