AcademySoftwareFoundation / AcademySoftwareFoundation/MaterialX

Slight inconsistency in the Input::setValue method

Open
#764 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.3k
Forks
451
Avg merge
6d 6h
Merged PRs (30d)
5

Description

Hi,

See: https://github.com/materialx/MaterialX/blob/9935a83a618e27ee320c68374176008acdd3eb72/source/MaterialXCore/Element.h#L978

The way it's implemented, if you have an input of type `filename` (for instance the `file` input of tiled images) and call `setValue` with a string, it will overwrite the type to `string`. And this in turn will make shader generation fail with a quite obscure message (I think because the input's type no longer match the one of the nodedef, but I didn't check)

I "fixed" this in my codebase by always forwarding the type of the input (something like: `input->setValue(the_value, input->getType())` but this feels weird, and I think most of the time `setValue` is called, it's to change the value, not the type. I think the linked line could (should?) be replaced by something like this:
```cpp
if (!type.empty())
setType(type);
```
Or maybe something a bit more complicated where you check if the current input's type is "compatible" with `T`, and only mutate the input's type if it's not compatible or the type was explicitly passed.

Contributor guide

Open the contributing guide

Research direction

Start at source/MaterialXCore/Element.h around line 978 and inspect Input::setValue, then trace how filename inputs such as tiled-image file inputs are used during shader generation. Confirm the current type-changing behavior and define what should happen when a string value is assigned without an explicit type; done means preserving valid input types and avoiding the reported shader-generation failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.