Files
UsdLayerManager/cmake/modules/FindImguiNodeEditor.cmake
T
indigo 09819091c4 Add Hypershade-style Material Editor with node graph and shader-ball preview
Browser column lists all scene materials plus a searchable create-node
list; Show Graph (or double-click) loads a material into the node-graph
work area. The graph shows the entire network including MaterialX
(.mtlx) node graphs, resolving connections through NodeGraph boundaries
via UsdShadeUtils::GetValueProducingAttributes, with layered auto-layout
for nodes lacking authored uiPosition. Canvas navigates viewport-style
(Alt+MMB pan / Alt+RMB zoom) and TAB opens a Nuke-style search popup.
Selecting a node shows a typed property editor (live-apply, one undo
command per edit) and previews that node's output on the shader ball.

The preview renders through its own Hydra engine into a scratch stage
that composes the material via a reference to the source root layer (so
referenced .mtlx materials work), re-renders until progressive delegates
(Arnold/Cycles/Embree) converge, and lights with HDR dome presets
(External/Room/Interior/Sunset; CC0 Poly Haven EXRs fetched at CMake
configure). texture:format is authored latlong explicitly - left
automatic, hdArnold falls back to Arnold's angular fisheye default -
and hdCycles gets a -90 X pole rotation to match Storm's +Y-pole
sampling.

Mutations go through new ICommand subclasses (create shader node,
connect/disconnect attrs). imgui-node-editor is vendored (gitignored)
with a local one-line patch: c_ScrollButtonIndex 1->2 for MMB pan.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-04 20:44:54 +08:00

83 lines
3.4 KiB
CMake

# FindImguiNodeEditor.cmake - Find or configure thedmd/imgui-node-editor
#
# This module looks for imgui-node-editor in the third_party/imgui-node-editor
# directory (vendored, docking branch) and compiles its sources directly
# against this project's own Imgui::Imgui target so it shares the exact same
# ImGui headers/defines (no second copy of ImGui is pulled in).
#
# Inputs:
# IMGUI_NODE_EDITOR_DIR - Path to imgui-node-editor/NodeEditor root
#
# Outputs:
# ImguiNodeEditor_FOUND
# ImguiNodeEditor::ImguiNodeEditor (imported STATIC target)
if(NOT IMGUI_NODE_EDITOR_DIR)
set(IMGUI_NODE_EDITOR_DIR "${CMAKE_SOURCE_DIR}/third_party/imgui-node-editor/NodeEditor")
endif()
if(NOT IMGUI_NODE_EDITOR_BLUEPRINT_UTILITIES_DIR)
set(IMGUI_NODE_EDITOR_BLUEPRINT_UTILITIES_DIR
"${CMAKE_SOURCE_DIR}/third_party/imgui-node-editor/Examples/Common/BlueprintUtilities")
endif()
find_path(ImguiNodeEditor_INCLUDE_DIR
NAMES imgui_node_editor.h
PATHS "${IMGUI_NODE_EDITOR_DIR}/Include"
NO_DEFAULT_PATH
)
set(ImguiNodeEditor_SOURCES
"${IMGUI_NODE_EDITOR_DIR}/Source/crude_json.cpp"
"${IMGUI_NODE_EDITOR_DIR}/Source/imgui_canvas.cpp"
"${IMGUI_NODE_EDITOR_DIR}/Source/imgui_node_editor_api.cpp"
"${IMGUI_NODE_EDITOR_DIR}/Source/imgui_node_editor.cpp"
# Blueprint pin-icon widgets (Widgets/Drawing only — Builders.cpp is
# intentionally excluded, it needs Spring()/BeginHorizontal()/BeginVertical()
# from thedmd's own ImGui fork, which this project's vanilla ImGui lacks).
"${IMGUI_NODE_EDITOR_BLUEPRINT_UTILITIES_DIR}/Source/ax/Drawing.cpp"
"${IMGUI_NODE_EDITOR_BLUEPRINT_UTILITIES_DIR}/Source/ax/Widgets.cpp"
)
foreach(_src ${ImguiNodeEditor_SOURCES})
if(NOT EXISTS "${_src}")
set(ImguiNodeEditor_SOURCES_MISSING TRUE)
endif()
endforeach()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ImguiNodeEditor
REQUIRED_VARS ImguiNodeEditor_INCLUDE_DIR
FAIL_MESSAGE "imgui-node-editor not found — expected it vendored at third_party/imgui-node-editor/NodeEditor"
)
if(ImguiNodeEditor_FOUND AND ImguiNodeEditor_SOURCES_MISSING)
message(FATAL_ERROR "imgui-node-editor sources missing under ${IMGUI_NODE_EDITOR_DIR}/Source")
endif()
if(ImguiNodeEditor_FOUND AND NOT TARGET ImguiNodeEditor::ImguiNodeEditor)
add_library(imgui_node_editor_impl STATIC ${ImguiNodeEditor_SOURCES})
target_include_directories(imgui_node_editor_impl
PUBLIC "${ImguiNodeEditor_INCLUDE_DIR}"
"${IMGUI_NODE_EDITOR_BLUEPRINT_UTILITIES_DIR}/Include"
PRIVATE "${IMGUI_NODE_EDITOR_DIR}/Source"
"${IMGUI_NODE_EDITOR_BLUEPRINT_UTILITIES_DIR}/Source"
)
# Must be defined before the first #include <imgui.h> in every translation
# unit (imgui_internal.h hard-errors otherwise) — a command-line define
# guarantees that ordering regardless of vendored include order.
target_compile_definitions(imgui_node_editor_impl PRIVATE IMGUI_DEFINE_MATH_OPERATORS)
# Must share this project's own ImGui build (same headers/defines) rather
# than pulling in a second ImGui — imgui-node-editor only needs the public
# API plus ImRect/ImFloor from imgui_internal.h.
target_link_libraries(imgui_node_editor_impl PUBLIC Imgui::Imgui)
add_library(ImguiNodeEditor::ImguiNodeEditor ALIAS imgui_node_editor_impl)
message(STATUS "imgui-node-editor found: ${ImguiNodeEditor_INCLUDE_DIR}")
endif()
mark_as_advanced(ImguiNodeEditor_INCLUDE_DIR)