mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Shader Nodes: add better string socket support and string nodes
This adds improved support for string sockets in shader nodes. Before, strings were in a bit of a weird state: two nodes (Principled Volume and Raycast) have string inputs but string sockets were not even allowed based on `shader_node_tree_socket_type_valid`. I wanted to try to add string sockets there in #118984 but it didn't really work well back then. Now, with the shader nodes inlining, we can more easily support string sockets because their evaluation is entirely handled at the inliner level. The final strings just end up in the string inputs of the two mentioned nodes (and maybe more in the future). Improved string socket support also helps with the expression node (#149091) since expressions are strings too. This patch also makes various string nodes from Geometry Nodes and the Compositor available in shader nodes to: Find in String, Format String, Special Characters, Input String, Match String, Replace String, Reverse String, Set String Case, Slice String, String Length, String to value, Trim String, Value to String. This is basically the same set as was added in #155864 to the compositor + nodes that were added since then. There are not that many use-cases for strings in shader nodes yet, but the unification is nice and will probably become more useful over time. The most difficult challenge here was dealing with `should_preserve_repeat_zone_node`. The old logic just based on the socket types was not enough anymore when there are nodes which only the inliner can evaluate but not the renderers. The tricky thing is that it seems hard to impossible to 100% accurately detect whether a repeat zone can be preserved without trying (especially when nested bundles/closures are passed into the repeat zone to be expanded inside of it). The best solution I came up with so far is attempting to preserve the repeat zone first and then having the option to backtrack that decision and to end up inlining it when preserving it failed. Pull Request: https://projects.blender.org/blender/blender/pulls/162643
This commit is contained in:
parent
9054b90d70
commit
4fed7c4a27
24 changed files with 284 additions and 63 deletions
|
|
@ -445,7 +445,7 @@ class ShaderNodeGroupInterfaceTest(AbstractNodeGroupInterfaceTest, NodeGroupInte
|
|||
self.do_test_invalid_socket_type("NodeSocketObject")
|
||||
self.do_test_invalid_socket_type("NodeSocketRotation")
|
||||
self.do_test_socket_type("NodeSocketShader")
|
||||
self.do_test_invalid_socket_type("NodeSocketString")
|
||||
self.do_test_socket_type("NodeSocketString")
|
||||
self.do_test_invalid_socket_type("NodeSocketTexture")
|
||||
self.do_test_socket_type("NodeSocketVector")
|
||||
self.do_test_socket_type("NodeSocketVector", dimensions=2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue