Function System

Please don’t take me wrong :slight_smile: you know I only want the best for this, I’m amazed with what you are doing here and I just want to understand :slight_smile:

Thanks! I suspected that but I wanted a confirmation from you to understand where are we heading, this is going to be awesome :slight_smile:

Keep in mind that we were talking about a simple operation, if we consider complex operations, like a custom physics solver made with function nodes, there we could expect a much slower performance, hence I’m not worried about that specific situation but a more production realistic situation with much more complex functions.

Also we don’t use 2 billion, but we need around 100 million particles to properly simulate a small square of deep sand, so being able to handle quite a few millions is very important, the same goes with water foam, to have proper foam we need a few millions.

And anyways the idea is to have the maximum possible performance to avoid having to create custom code that has to be compiled within Blender to generate custom solvers for example, this will simplify part of the Fracture Modifier implementation :slight_smile:

6 Likes

Reading the document, I’ve got the impression that the functions will be saved in the blend file…

Would it be possible to extract them from the blend file so that we can make independent libraries of functions? I’m just thinking that the users may want to re-use their functions in other projects or share them. Functions could have their own file format. One function or multiple functions could be contained in one file to form a module as in python.

That might be related to the asset manager; cause you could also want to make an external library of animations, with one file per animation, or bundles of animations…

I would assume that it would work like any other blender data. IE shaders- if a user creates a super cool shader and want to reuse it, they save it to a blend file and append it in any other scene that needs it.

Can function system have conditions?

data = fuctnion1(input)
if False:
    data = function2(data)
data = function3(data)
output = data

@Nodragem Node trees that define functions will be stored in the .blend file and can be linked/appended to other .blend files. However, it is unlikely that you will be able to use those functions outside of Blender. At least in the current design.

@Random There is a switch node that selects one of two inputs based on some condition. Currently, this case is not optimized (so both inputs will always be evaluated). I’m aware of two different optimizations I can implement later.

1 Like

@jacqueslucke Do you mean something like this:

data = fuctnion1(input)
data2 = function2(data)
data = function3(data if True else data2)
output = data

And optimization will be: not to call function2 if it does not any effect?

1 Like

@Random That’s correct.

1 Like

@jacqueslucke What about loops? Would it be possible to use something like loop For? Like this:

output = 0
for i in range(10):
    output += power(i)

Or loop while:

output = 2
while output < 100:
    output += power(output)

and nested loops:

output = 0
for i in range(10):
    for ni in range(i):
        output += power(ni)

I did a mock-up for a proposed iterative node group over on Right Click Select – this is for material nodes, but it might offer some insight into how to design the UI.

1 Like

The system only handles data flow for now, no control flow. So, loops are not possible yet. I can make it possible in the future for sure though.

@Josephbburg Thanks for the mockup. For Animation Nodes I also thought about how loops can be represented with Blender’s node system.

1 Like

It’s not quite clear if the proposed system can extend (or replace?) existing shader node system.
Seems like it’s totally impossible without rewriting half of blender core and cycles.

Replacing the shader node system for Cycles and Eevee is not a target.

I would love to see the ability to have node-trees interact with unlike types of node-trees. For example, maybe in the future, if there are rigging nodes we’d want them to have access to everything, for the purpose of control. This is one of the few features I really like about Maya-- being able to connect any two nodes in a variety of ways.

@jacqueslucke Did you ever make a mockup of how loops could look for Animation Nodes? Have any feedback about the mockup I made?

1 Like

I’m not perfectly sure, but I think that loops (of non-static length) require some state in one form or another. And the state is not expressable in stateless dataflow. It’s just on another level of computational complexity. Combined with ‘switch’ node it becomes possible to implement full FSM.

How do Maya or Houdini address this issue?

There are no loops in Maya, and simulations are run inside black boxes (one single big node). Houdini has a special kind of node called solver in which you can dive and access previous frame information, bit I haven’t used it a lot, I couldn’t elaborate.

Here is the documentation for how loops work in Animation Nodes: https://animation-nodes-manual.readthedocs.io/en/latest/user_guide/subprograms/loop.html.
Afaik, other node systems (e.g. Sverchok and Sorcar) also have some way to represent loops. I could not find any documentation though.

Your proposal is missing a lot of details that are important. For example, how does the loop know which nodes represent the iteration rule? Is it all based on names of nodes and frames?
Furthermore, loops add a lot of complexity to a node system and I’m not sure if it is worth it to add this functionality to Cycles nodes. Loops with an undetermined iteration count could also make it much harder to run them on the GPU. Lastly, this topic is not about Cycles nodes, so let’s stay on topic, please.

1 Like

The idea I had was that there would be new node-types that are similar to node groups - the iteration rule would be a group with the current iteration as a single input, and the result of the iteration rule as an output. The Current iteration would be a group, too, taking the iteration and any constant parameters as an input. Then the combination rule would also be a group that is optional, for combining the results of various iterations. I think this UI might be approachable in any node-tree, but of course it still needs some work.

I wasn’t trying to go off topic-- of course this isn’t the place to talk about Cycles! I just wanted to offer a UI suggestion, although it looks like you’ve already put quite some thought into this! Thanks :smiley:

As for this comment:

I would love to see the ability to have node-trees interact with unlike types of node-trees.

I was just thinking of a far away future, after Modelling and Particle Nodes are already implemented.

Hey @jacqueslucke I have some questions regarding the particle roadmap ⚓ T73324 Particles Nodes

I can’t find anything related to instancing objects to particle positions/rotations, except at milestone 2
(Use cases are supported (particle scattering, weathering, …).)

Will we have instancing of objects at the earliest at milestone 2, or will basic instancing be implemented in milestone 1 already.

I’m wondering because I think the Functions system is already pretty capable to be used for a lot of motion graphics stuff, we would normally do in animation nodes. When it is not to much work to implement, groups for manipulating instances could be build and tested already.

So when milestone 2 would be active, there could be already a lot of group nodes ready for shipping with blender or at least some tests could be made in advance. Personally I would love to rebuild the feature set of c4d mograph effectors and it’s cloners, also to learn how these systems work :slight_smile:

Anyway, do you have already plans or technical details on how such instancing could be implemented in a good performant way? Will there be a new type of system which draws the instances nested, or will they be shown in the outliner, like it is with animation nodes at the moment? (Which would be not that good of a performance I quess.)

Please ignore if you already answered this questions ^^

2 Likes

Pretty late to the party here, but I would like to add that Houdini has a “For each” node. Actually there are 6 of them:
-For Each Connected Piece
-For Each Named Primitive
-For Each Number
-For Each Point
-For Each Primitive
-For Loop with Feedback


It creates a beginning and and end node, with a special backdrop for the stuff in between. So that is one loop method.

Another is simply putting down a Wrangle node where you can just type your own vexcode and make your own loops manually.

2 Likes

Having a sort of language like vex one could use along with nodes would be very nice indeed… And I find the loop interface very well thought, it’s completely clear what it does and where it starts and ends. All very good examples.

1 Like