adding new nodes to the scheme
Hi John!
I have an idea to create an animation of a chaotic swarm of mosquitoes using a program. I managed to make the circuit partially. I am not an advanced user and have no idea how to add additional nodes to the circuit when there is no place where I can include them. Can you please help me find a way out and implement the idea using a nodebox?
How to do it?
1. add "speed" to the scheme. where and how can it be inserted to regulate the speed of the swarm?
2. how to add rotation to each mosquito around its axis so that the animation is more lively?
3. want to add more zoom (increase/decrease each dot) for the effect of several mosquitoes approaching the viewer?
As I understand, I cant get the movie without a background. It turns out you need to export the PNG frame by frame and glue it together, right? there was another option to overlay a video with black mosquitoes on another video in the after using multiplay. Вut what if you need colored mosquitoes - it's not clear.
I would appreciate help and advice. Thank you!
- komariki.rar 5.58 KB
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by indefiniteness on 19 Jun, 2023 09:00 AM
I'll look at this for you if John doesn't beat me to it!
Support Staff 2 Posted by john on 24 Jun, 2023 08:56 AM
Masha,
My apologies. I normally get email notifications when anyone posts to the forum but for some reason that stopped working last week, so I am only now seeing your note.
Even worse, I cannot open your attached file. I see that it has a ndbx file and an svg file, but I get a message that the files are corrupt and cannot be extracted.
Could you please try sending those file again? If possible, try sending them as ZIP files instead of RAR files.
I will be able to give you specific help once I can see your files. In the meantime, though, I can give you some general answers to your questions.
Question 1. Speed...
Animations in Nodebox are created by feeding the output of the frame node into the rest of your network. This produces one frame for each value in the range you specify when you export a movie.
An easy way to speed up or slow down your movie is to multiply or divide the output of the frame node. Just add a multiply node to the output of your frame node and feed the output of the multiply node to the rest of your network. If value2 of the multiply node is set to 1, the movie will play at normal speed. If value 2 is set to 2, Nodebox will export every other frame, which will make the movie seem to run twice as fast. If you set value 2 to, say, .25, the movie will produce four times as many frames, making it seem to play four times more slowly.
Question 2. Rotate each mosquito
This is done with the rotate node. Feed the shape corresponding to each mosquito into a rotate node before combining it into the final output. To control the speed of rotation, feed your frame+multiply node into a convert range node so that incoming frame values are converted to angles. For a hundred frame movie if you convert source values of 0 to 100 to target values of 0 to 360, each mosquito will do a complete clockwise rotation during the course of the movie. If you set target values to 0 to 720, it will do two full rotations. 0 to -360 will do a counterclockwise rotation. And so forth.
When using the rotation node it is very important to also set the origin parameter. You will need to compute the current location of each mosquito (with the centroid node if you don't already have it) and feed that into the origin port of the rotation node.
You can randomize the speed and direction of each mosquito's rotation by adding random values to the target end port of your convert range node (generate a list of random numbers equal to the number of mosquitoes).
Question 3. Zooming
You can make individual mosquitoes appear closer or farther away by using the scale node. Set the scale value to less than 100 to shrink the mosquito (making it seem farther away) of to more than 100 to enlarge it and make it seem closer. You can generate random scale values for each mosquito to shrink or enlarge each one separately.
To make this effect seem realistic, you will want to slowly increase and decrease scale values over time, not jump around from one frame to the next. This can be done using the wave node to generate sine waves for each mosquito and feeding the frame into the wave offset to retrieve rising and falling values to feed into the scale node. This is a bit tricky so will require some experimentation to get the effect you want.
As for exporting movies with transparent backgrounds and combining that with other video clips to produce overlays, that is something I've never tried. The Export Movie option produces an MP4 output which probably does provide a solid background even if you don't provide one.
As you suggested, it might be possible Export Range instead of Export movie and output individual frames. The PNG format does support transparency. So one thing to try would be to combine your final output with a rect equal to the canvas size inserted underneath the rest of your content. Colorize that rect with a fill set to alpha 0. I don't know if that will work, but it's worth a try.
I realize these suggestions may be a bit confusing. If I can get ahold of the files you originally tried to attach, I could provide you with an example of these techniques to get you started. So please resend.
Also, if you do try my overlay idea and it works with whatever video app you are using, could you please a note describing what you did? I'm sure other Nodebox movie makers would appreciate learning how to do overlays.
John
P.S. Thanks, edgeofinnerspace, for offering to help. Please feel free to jump in at any time.
3 Posted by Masha on 24 Jun, 2023 10:55 AM
John, thank you for the reply. I upload files:
https://drive.google.com/drive/folders/1OUlRSbotzyL9GvIXdVu5mk4GL2uUE5Tf?usp=drive_link
Support Staff 4 Posted by john on 24 Jun, 2023 11:17 AM
Masha,
Thank you. I was able to retrieve your files.
It's now 4 AM where I am, so I am heading to bed. But tomorrow I will make you a quick swarm movie to show you the basic technique.
Would you like your swarm of mosquitoes to fly across the screen from left to right or fly around in circles?
Stay tuned!
John
5 Posted by masha on 24 Jun, 2023 11:46 AM
John, thank you. Also I need time to understand what you write to me, cause I use google translate to understand english texts more correctly)
6 Posted by Masha on 24 Jun, 2023 02:07 PM
the idea is to make points go around like in real life, when you see the cloud of mosquitoes
https://www.shutterstock.com/ru/video/clip-10062206-4k-swarm-mosquitoes-buzzing-nature-sunset-summer
Support Staff 7 Posted by john on 24 Jun, 2023 11:01 PM
Masha,
Attached is a demo of a rudimentary mosquito swarm maker. Open the ndbx file and render different nodes to see how it works.
The basic idea is to create N mosquito paths and move each mosquito along its path. In my example I set N (the HOW_MANY node) to 200, but you can change this to 3 to see more clearly how everything works.
To keep things simple I just used circles for each path. I varied the size randomly from 200 to 800 and used a scatter node to position each circle randomly across a 1000 x 1000 canvas.
You can then use the point_on_path node to move each mosquito along its path using a T value that varies from 0 to 100 (where T = the percentage of the way around the circle).
But it won't look natural if all the mosquitos are moving in unison, so you want to offset each mosquito differently. I do this by adding a random value to each mosquito's T and using mod 100 to make sure the T value wraps around (change 123 to 23, etc,). I also randomly flip the sign of the T value to make some mosquitos fly clockwise and others fly counterclockwise.
The final step is to zoom the mosquitos in and out using the scale node. As I described in my previous note, I do this using a sine wave function so that the zoom factor gradually increases and decreases instead of wildly jumping around. I also use another random offset so that the mosquitoes are not all growing and shrinking at the same time.
On the wave function, set the min value to the smallest size you want (I chose 75%), max for the largest size (I chose 200%), and set the period to the length of the movie (in this case 100 frames). I tied everything to 100 frames so that all the positions and zooms return to their starting position (frame 0 is identical to frame 100). That way, if you set the video to loop, it will run seamlessly.
You asked about rotating the mosquitoes, but I noticed that in the film you provided the mosquitoes don't seem to rotate as they fly; they need to stay horizontal in order to hover. When seen in three dimensions they do look a little different, though, because they are being viewed from different angles.
My crude compromise was simply to rotate each mosquito randomly, but keep that rotation fixed as it flies along its path. I think it looks OK. But if you want I can show you how to make the mosquitoes rotate AS they fly.
Your final question was how to create a transparent background so that you could overlay the mosquitoes onto another video. I did some research and it looks like mp4s do not support transparent backgrounds. The most common technique is to film your actors (your mosquitoes) against a green screen and use any number of different video apps to replace the green pixels with a transparent background.
So in my sample app I use a combine node to place the mosquitos against our 1000 x 1000 canvas rectangle filled with a pure green color.
The attached video shows what the swarm looks like without the green screen. Set it to loop and watch it for as long as you want. Given how simple this approach is, I think it works surprisingly well.
There's much room for improvement. Instead of perfect circles, you could make each mosquito fly along a randomly rotated oval, or better yet, a zig-zag polygonal path. You could make the mosquitos fly at varying speeds or even have some of them pause occasionally to hover in place. You could color the mosquitoes slightly differently (using any color except pure green if you want to use a green screen). If you want to try any of these improvements and get stuck, let me know.
Also, if you do decide to use the green screen and succeed in overlaying your mosquitoes against a different video, could you please write back and tell us what app you used and exactly how you did it? I think everyone would appreciate learning how to do that.
Thanks for an interesting challenge!
John