Home Coding, Scripting, Shaders

Unreal Python: How to access material expressions inside NamedReroute (and MaterialFunctions)

Hi ppl ,

I would like to write a python tool that does something with all material expressions inside of a given material.
I have some issues with two material expressions:

  1. Named Reroutes
  2. Material Functions

Named Reroutes are particular annoying, because the team is using them a lot.
My script currently runs recursively over all expressions, starting from the material inputs, but I cannot find a way to access the Named Reroute Declaration- from a given Named Reroute Usage Expression, so I cannot proceed if I stumble upon a Reroute Usage Exression.

I also seem to have no option to get just every single expression that is available in a material graph even if not connected to the material.

What are my options to support Named Reroute Expressions in my tool?

Sample Code: recursively check material expressions
Sample Material: material with reroute expressions 

Thanks, Micha

Replies

  • poopipe
    Options
    Offline / Send Message
    poopipe grand marshal polycounter
    I think you're screwed without poking at c++ 

    I've not checked with python because I have PTSD but the same bits are generally available from editor blueprint so I poked at it there and then when that failed i looked at the code. 


    The named reroute declaration is held in a public UProperty in UMaterialExpressionNamedRerouteUsage  - which you'll find in Engine\Source\Runtime\Engine\Classes\Materials\MaterialExpressionNamedReroute.h 
    On the face of it I can't see why exposing to BP/Python would cause any problems (disclaimer: not a real programmer) 

    I dont have a source built project at the moment to test it but iirc you expose UProperties to python and BP in the same way so it "should" be relatively straightforward to make the engine change required 
    (a quick google found this https://forums.unrealengine.com/t/handling-properties-unexposed-to-bp-python/1203715) 



Sign In or Register to comment.