prman-pixar / RenderManForBlender

RenderMan for Blender render addon
MIT License
808 stars 133 forks source link

Cannot create shader node groups with Pxr inputs/outputs #690

Closed erjiang closed 12 months ago

erjiang commented 1 year ago

In Blender, complex shader utilities are often put into groups to be reused elsewhere. The group can take custom inputs and outputs such as color, float, etc. The Pxr data types are not supported, however.

Blender 3.6.2 RenderMan for Blender 25.2.0 Linux

To reproduce:

  1. Create a new material with RenderMan node tree.
  2. Add a PxrBlend node.
  3. Right click the PxrBlend node and choose Make Group (Ctrl G)
  4. Connect the Top Color input from the PxrBlend to the blank output of Group Input.

Expected:

Group input is shown as Pxr color, and Pxr color can be input to the group.

Selection_004

Actual:

Node inputs/outputs are of unknown type and Blender defaults to float. Node group is not usable as a result.

Selection_003

prman-pixar commented 1 year ago

@erjiang

Can you see if this helps?

  1. Unzip the attached ZIP file
  2. Put rman_socket_utils.py in RenderManForBlender/rfb_utils
  3. Put rman_bl_nodes_sockets.py in RenderManForBlender/rman_bl_nodes

patch.zip

erjiang commented 1 year ago

With this change, color inputs don't seem to work anymore. As shown in the screenshot in #691, the color inputs have become Blender colors (dark yellow) and I'm not able to do something as simple as create a PxrConstant shader and change the emitColor.

prman-pixar commented 1 year ago

(Just copying what I wrote in #689 regarding this issue)

Unfortunately, this seems to be a limitation of Blender.

We're using a custom class for our node sockets. There doesn't seem to be any way to change the socket's type property when using a custom class. Custom node sockets all get set as 'VALUE' for its type. The group node seems to use this property to figure out what kind of socket it should add for its input/output. If you try to explicitly set the type property, the socket reverts back to the base NodeSocketFloat class, and we lose our custom properties.

We cannot use the base Blender node socket classes, because we want to be able to add our own properties, and override the draw methods for the class. The only thing I can think of that might fix this is to create our own custom group node, but that would be a significant change, and I'm not sure if that will fully solve this.

prman-pixar commented 12 months ago

Gonna close this one. Blender 4.0 has made changes to the way sockets are created for group nodes, and this seems to work now as expected in my testing, after updating our code.