Page MenuHome

Fix T37334: Better "internal links" function for muting and node disconnect.
ClosedPublic

Authored by Lukas Tönne (lukastoenne) on Feb 26 2014, 12:31 PM.

Details

Summary

Implements a more flexible internal connect function for standard nodes
(compositor, shader, texture). Allow feasible datatype connections by
priority.

The priorities for common datatypes in compositor, shader and texture
nodes are encoded in a simple function. Certain impossible connections
(e.g. color -> cycles shader) are excluded by giving them -1 priority.

Priority overrides link status: If a higher priority input can be found,
this will be used regardless of link status. Link status only comes into
play for inputs with same priority.

Diff Detail

Event Timeline

Brecht Van Lommel (brecht) requested changes to this revision.Feb 26 2014, 4:04 PM

I can't think of a case where you want to link vectors to RGBA automatically. With RGBA <=> scalar or vector <=> scalar it's basically unknown, it may be useful or it may not, but with vectors and RGBA you know they are semantically different, so I would not link them.

For example texture nodes in Cycles now link the vector input to the RGBA color, or the Normal Map node would like strength or color to the normal output, which doesn't make much sense. Otherwise this seems ok to me.

I didn't check all nodes, but perhaps it would be good to go over them and see if there are any nodes where it is making non-sensible connections, and if you find any add some flag to disable creating links.

Alright, that's a simple matter of removing some of the priority cases. Should we disallow all scalar <-> vector/rgba connections as well or just the rgba <-> vector cases?

For more complex nodes we can extend the system a bit if necessary, there are a few things we could do:

  • Add flags to input sockets that should never be used for muting ("SOCK_NO_MUTE" or something)
  • Add explicit lists of inputs that are allowed to be used for a specific output

If all else fails we can still write custom callbacks for individual nodes.

I've tested most nodes that have given trouble in past bug reports, they seem to work reasonably well.

For scalar <-> vector/rgba connections I don't know what the best default would be, sometimes they make sense but other times not.

For example none of the Wave Texture scalar inputs make sense to connect to the color output. However in a ColorRamp node it makes sense. So perhaps it's most convenient to connect them by default and then have socket flags to disallow connections in this case.

Lukas Tönne (lukastoenne) updated this revision to Unknown Object (????).Feb 26 2014, 7:38 PM
  • Removed rgba <-> vector connections from the internal links.
Lukas Tönne (lukastoenne) updated this revision to Unknown Object (????).Feb 27 2014, 11:13 AM

Extension for node socket templates to specify allowed input links.

This uses an optional list of booleans for outputs based on input index.
Only inputs with a true entry in this list will be considered for
internal links of that output socket. This should give enough
flexibility while keeping additional complexity in C node definitions at
a minimum.

Only the wave texture shader node uses this atm, will add this to other
nodes if the general approach is approved.

@Brecht Van Lommel (brecht): I've tried the input flag approach, but this adds a lot more noise in C socket templates (we usually have only 1 or 2 outputs in nodes but quite a few more inputs in the relevant nodes). Flagging inputs is also more limiting because it disables that input for all output connections, while we may want to allow different links for different outputs.

Maybe add a flag to output sockets then? In all the cases I can think of you would end up disabling the output sockets for muting with {0, 0, ...}.

Lukas Tönne (lukastoenne) updated this revision to Unknown Object (????).Mar 1 2014, 6:40 PM

Reverted the previous boolean lists and replaced them by a simpler flag
for sockets.

This socket can be used for both inputs and outputs.

@Brecht Van Lommel (brecht): Agree this is easier and should work sufficiently for all our
problematic cases.

Ok, this looks good to me.

Lukas Tönne (lukastoenne) updated this revision to Unknown Object (????).Mar 2 2014, 8:23 AM

Disable internal links for shader texture node outputs.

Some texture nodes have color inputs (checker, brick), which still allow
meaningful default colors if muted.

Just a side note: I'd like to eventually make use of the internal links for inserting nodes into links as well. Currently this uses its own method of defining "best match" for socket connections.
https://developer.blender.org/diffusion/B/browse/master/source/blender/editors/space_node/node_relationships.c;e60fb0fd294577948f8ce0f07817b98d1b3024fe$1276

Using the internal links could make this more consistent and avoid useless connections which then need to be tweaked manually.

But this is a different issue and out of scope here ...