I was looking and studying some old examples of Softimage ICE legacy on how they use nodes to do things. ICE is mildly similar to Sverchok inside Blender. I think Sverchok is just slightly friendlier in my opinion.
For example, in this one blog post, it was shown how we could create some connected STRANDS between 2 different mesh using ICE network:
http://caffeineabuse.blogspot.com.au/2013/01/creating-strands-between-two-different.html
I was also observing this Maya's classic preset Lightning effect. Which basically connect between 2 or more objects creating connected lighting. There is an interesting "SPREAD" parameter here which controls the spreading of noise.
I thought that THIS is going to be quite an interesting exercise to test inside Sverchok, let's do some эксперимент (experiment in Russian).
A SINGLE STRAND
Before we start with many strands between 2 mesh, how about we try to create a line with 2 x Empty positions? Ok, let's do that first.Create 2 x Empty objects in the scene. I called them Liang and Zhu from Chinese Love story about two butterfly lovers connected with red thread. Feel free to call them Romeo and Juliet.
Jump into Sverchok and bring in those 2 Empty with OBJECT IN. We know that with Empty, we DO NOT have Mesh data, however we DO have the Matrix data and we can extract the POSITIONAL data.
So, it is quite easy and logical to connect the two in many different ways:
USING LIST JOINING (the long winded way):
USING LINE TOPOLOGY (slightly more clever):
USING LINES CONNECTION NODE (the easiest):
Luckily, we have this handy Lines Connection node. It makes everything simpler and quite logical.
THREAD WITH BROKEN LINES
Now a single line is straight forward, however maybe we want lines with DIVISIONS. For that we can take advantage of RANGE node and EVALUATE VECTOR, which creates some intermediate points values which we can connect together.Connecting the dots:
DRAMATIC LINES
All good and nice, next, probably we can "roughen" the line connection a bit. To add a bit of DRAMA.What would you think to add roughness? Vector Random? Vector Noise? Sine wave? All those can actually work and I think you should try it.
I usually like to use VECTOR MOVE node to disturb point positions. The VECTOR MATH ADD is also good and maybe more preferrable to add Vector together in many situation.
NOTE:
With VECTOR MOVE, the order of port INPUT actually matters. Just like FORMULA node, we need to always pipe in the MAIN VERTICES on top, followed by the VECTOR that will disturb the original VERTICES.
RANDOM VECTOR is easy and simple. As we know that with RANDOM we can play with the SEED and making some interesting random values changing, the effect is more chaotic.
While, NOISE can produce a more elegant flowing movement. Especially when you "move" the noise using another value, like FRAME such as below:
RANDOM VECTOR is JUMPY from one value to the next value. While NOISE is more SMOOTH.
UN-CONNECTED FIRST AND LAST
If you notice something, we seems to have an issue. The Liang and the Zhu are no longer connected. The FIRST and LAST of POINTS thread that are connecting them are now moving around (because of NOISE and VECTOR) and this is clearly is not right.We must do something.
Luckily, there are few useful nodes that allowing us to SLICE, JOIN, and found the FIRST and LAST, they are named exactly those! How handy!
- LIST SLICE
- LIST JOIN
- LIST FIRST & LAST
I use VIEWER TEXT often and I keep watching the DATA being passed on and make sure the DATA FLOW is okey.
This is simple after you understand it.
Basically, this is kind of if we have STACK OF CARDS and we want to SHUFFLE whatever cards in between, however, the magician is clever decided to keep the first and last card in the same position.
By doing so, in the case of inseparable lover LIANG-ZHU, we can keep them connected.
LIANG-ZHU NOISE
LIANG-ZHU RANDOM
I think I will use RANDOM VECTOR movement for now. It is more electric and actually simpler for our purpose. NOISE is of course can be more interesting. By multiplying lots of noise, we can get TURBULANCE motion.
Anyways, our NODE TREE so far:
When we are setting up with thought, and if everything works as planned, we could go back and trace and see which PARAMETERS we can play around with:
- The number of divisions of the lines (INT divisions)
- How strong is the Random move (FLOAT multiply value)
PIGGY BACK THE EFFECTS
At this point, you are free to continue LAYERING the effects. Things like Vector Move can be piggy back and the effect can be interesting.This is probably something you like to add later. Because this is really adding DETAILS. With details, things might get complicated and out of hand.
Start SIMPLE:
- Small Numbers
- Small Data
Later on you can add complexity, ensure that you can control it:
- More Large Data
- More Layered Effects
FADING IN - FADING OUT THE EFFECTS
What would be nice is to add FADING IN and FADING OUT to the effects (of Random or Noise). There is probably a nicer way to think and apply this fading in-out thing.We could probably do this by creating a setup where the LIST VALUES is MULTIPLIED to make the value goes from ZERO, to certain LEVEL, remain STEADY and back to ZERO at the end.
From top of my head, there is a way we can control this using DISTANCE and NORMALIZE.
<< ADD MORE INFORMATION HERE >>
CASE OF MULTIPLE THREADS
Above, we have solved the simple segmented lines connection between 2 points in 3D space.How do go about and making it so that we can have THREADS of lines between 2 mesh? To keep it simple, we will ensure that both Mesh actually have the same total number of POINTS.
For this I first replace the 2 x Empty with 2 x simple Planes, each have 4 Vertex points.
We are still using the Matrix position, but we know that we want to use VERTEX POINTS with APPLIED MATRIX (applied transform).
So, let's do that.
The rest of connection is unchanged. |
Immediately, we started to see the Strands. However, this actually have FEW ISSUES to fix.
Currently the lines is all connected from beginning point to the last point.
TASK: SKIP EVERY N EDGE
We actually want it so that LINES are only connecting every PAIR of POINTS of the mesh. Another word to say is that we want to SKIP A LINE, we do not want to connect all of them.
We can do that using LIST MASK and simple MODULUS MATH for the EDGE TOPOLOGY. Just tell Sverchok to SKIP every N points.
If we have 4 points pair, the points connected will be something like this:
1-4
5-8
9-12
13-16
We could break the edges between points when required just by masking the edge every N.
In Sverchok, using FORMULA2 node, we can do TRUE or FALSE, and for TRUE or FALSE and certain Pattern we can use MODULUS. Something like below.
x % n[0] == (n[0]-1)
n[0] = NUMBER EVERY N TO SKIP
Whenever we see PAIR that repeats (pattern), we can definitely do things like this.
1, 1, 1 1, 0, 1, 1, 1,1, 0, 1, 1, 1, 1, 0, ... and so on.
The Zero there is the SKIP.
LIST REPEAT can also be used, but you might need to rewire and rethink the node tree. This way is probably more preferable, cleaner, easier to understand.
For now, however, let see if we can push what we have and see if we can GET LUCKY.
I am using INDEX VIEWER node here to observe the pattern of VERTICES and EDGES. The vertices is kind of right. It is the edges that we need to check whether we are connecting the right edges.
OUR NODE TREE SO FAR...
Interestingly, seems like what we are doing is to create BRIDGE between points. Something to keep in mind. Maybe THIS is how we make Bridge Connect Vertices or Face.
Continue on.
Apparently if I increase the Random or Noise, I am getting the same issue where the Lines just get separated.
It is as if, would be nice if we can SKIP every number of vertices. Sounds familiar? Modulus Pattern.
Instead of thinking about filtering out the START and END of points, we now have to think about SKIPPING EVERY N.
TASK: Do not disturb (random or noise) vertices every N.
However, further observation, our pattern here is slightly different and we cannot use the MODULUS like above.Our pattern now is more like:
1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,and so on.
The ZEROES is dependent on the the number of DIVISIONS. These are the Vector values we like to disturb. While the 1 is the vector that we like to keep.
Let's have a bit a break....
BIT PATTERN is an interesting problem. Just like BEAT in MUSIC.
I think, I was over complicating some parts of this matter. Maybe I could use REPEAT LIST PATTERN to simplify the situations.
However, I think we still learned something from above.
We just need a pattern. Doing it fully with Math and formula is not necessary. Let's doing it Sverchok style, we can easily create any kind of pattern using LIST JOIN, LIST REPEAT.
BIT PATTERN, no problem:
That above giving us LIST DATA like this:
=0= (8)
1
0
0
0
0
0
0
1
The ZEROES need to be flexible and really depends on the length of our Lines Divisions, minus the First and Last index.
Now, it is just a matter of piping the data, filtering which one to MOVE and DISTURB and which one that shall STAY THE SAME.
With that VECTOR PATTERN IN MIND, for our Random Vector, instead of generating all very long Random Vector DATA, we want to create it like pieces of string.
And we like to make it so that for each line, it will be the same (at first):
=0= (8)
(0,0,0)
random vectors
random vectors
random vectors
random vectors
random vectors
random vectors
(0,0,0)
Ok, so we have now Connected Threads that is the same. This is actually more manageable and also expandable.
If we want a MORE RANDOM THREAD, perhaps, we can use the VECTORIZED INPUT, aka the LIST INPUT node.
However, I realized that if I plug in the VECTORIZED INPUT into the Random Vector, we kind of lose the pattern.
INSTEAD OF:
0, random, random, random, 0, 0, random, random, random, 0, 0, random, random, random, 0....
WE ARE GETTING
0, random1, random1, random1, random2, random2, random2, random3, random3, random3, 0, ...
WHAT I THINK WE NEED:
0, rand1, rand1, rand1, 0, 0, rand2, rand2, rand2, 0, 0, rand3, rand3, rand3, 0,0, ....
This is certainly leading to another interesting problem!
UPDATE 1: Afternoon
Ok, I think I found one solution. Let's SIMPLIFY some problems.We just need a pattern. Doing it fully with Math and formula is not necessary. Let's doing it Sverchok style, we can easily create any kind of pattern using LIST JOIN, LIST REPEAT.
BIT PATTERN, no problem:
That above giving us LIST DATA like this:
=0= (8)
1
0
0
0
0
0
0
1
The ZEROES need to be flexible and really depends on the length of our Lines Divisions, minus the First and Last index.
Now, it is just a matter of piping the data, filtering which one to MOVE and DISTURB and which one that shall STAY THE SAME.
With that VECTOR PATTERN IN MIND, for our Random Vector, instead of generating all very long Random Vector DATA, we want to create it like pieces of string.
And we like to make it so that for each line, it will be the same (at first):
=0= (8)
(0,0,0)
random vectors
random vectors
random vectors
random vectors
random vectors
random vectors
(0,0,0)
BIG MAP BREAK POINT
Ok, so we have now Connected Threads that is the same. This is actually more manageable and also expandable.
If we want a MORE RANDOM THREAD, perhaps, we can use the VECTORIZED INPUT, aka the LIST INPUT node.
However, I realized that if I plug in the VECTORIZED INPUT into the Random Vector, we kind of lose the pattern.
INSTEAD OF:
0, random, random, random, 0, 0, random, random, random, 0, 0, random, random, random, 0....
WE ARE GETTING
0, random1, random1, random1, random2, random2, random2, random3, random3, random3, 0, ...
WHAT I THINK WE NEED:
0, rand1, rand1, rand1, 0, 0, rand2, rand2, rand2, 0, 0, rand3, rand3, rand3, 0,0, ....
This is certainly leading to another interesting problem!
<<< I AM STUCK HERE >>>
HOW ABOUT A DIFFERENT SOLUTION?
Well, actually few days ago before writing this, I was doing similar thing to create Multiple Thread Strands between 2 meshes.
As below you see that I am using the CENTER POLYGON vectors and I push them a little bit out so that I can see the NORMAL from each FACE.
As below you see that I am using the CENTER POLYGON vectors and I push them a little bit out so that I can see the NORMAL from each FACE.
I think below is quite nice as well.
The issue will be the SKIPPING of FIRST and LAST Edges, the lines itself is not very connected to the original POINTS.
However, below everything is working nicely, parametrically.
I could increase the Mesh Count and still getting predictable result. The Lighting Strands are also animatable and I have full control over the number of strand points in between.
It does look a bit like THE FORCE LIGHTNING |
Strand Lightning Effect. |
The next "problem" is to make this work if the 2 x MESH does not have the same number of points. We could probably use something like LIST MATCH.
KDTREE NODES FOR STRANDS
Using Kdtree nodes are also something that is interesting to try on. I think this is some kind of Algorithm used by Spiderman or spiders in general.ANOTHER SOLUTION? Update 2014.05.17
Mr Ko at Blender Artist posted something about replacing Edge with "Interpolated Edge", using Adaptive Edges. And suddenly I realized that we can use that Adaptive Edges node for our setup.
I came up with this Sverchok Node Tree that is I think quite elegant.
The idea is still similar. I would love to go through the above step by step, however, that would take too long, I will give you the BLEND for your own study below:
BLEND:
Basically what is happening is like this:
1. We have 2 objects Mesh coming in. We need to care about how many faces both Mesh have. For now, let's assume that we keep both Face Count the same.
2. Like before, I like to have more control over BEGINNING and ENDING POINTS.
3. I use the Face Normal and the position of points emiting from the Face Normal and connect it as Edges.
4. Edges can be replaced with "Interpolated Edges" using Adaptive Edges node. I like this method a lot. Thanks Ko for mentioning.
5. Next, we could easily randomize the Interpolated Edges Vector with NOISE or VECTOR RANDOM.
5. Finally, it is just a matter of using Math to find the BEGINNING and ENDING POINTS.
6. Connect all the edges needed and we have this final result.
I also figure out that:
LIST MASK x % n[0] == (n[0] - 1) is the opposite of LIST MASK x % n[0] > 0
In Procedural Workflow, there is NO SINGLE ANSWER for A PROBLEM. There are many. Some are more efficient, more complex, some are simpler, we call it "hack way" but it does the job, maybe not too perfect, but it works for now.
Now, the setup above is just a bit slow, it is running around 1 FPS at some point, maybe there was some complex calculations. Hopefully Sverchok speed will improve overtime.
NOTE: Performance test is showing that the culprit of slowness is how I use Formula2 node. Maybe the comparison to get True False list is too slow to calculate now. Will post a different alternative that is faster when I found one.
Post a Comment