Categories
Journals RYGCBMK◯ Stuff I made

Sine functions to the left of me, matrices to the right..

It’s been 2 to 8 April 2017. I got a new semi-modular synthesiser this week so I lost a couple of evenings to playing with the new toy adding to the RYG-O soundtrack.

Music is never as exciting to look at, is it?

For this week’s shots I moved away from procedural meshes and back to working with lots of duplicated objects. I made a spiral galaxy, swarms of weird little swimming eggs, swarms of psychedelic kidneys and swarms of little balls having arguments with one another.

They are strangely individual swarms of balls.

One of the useful discoveries I made this week was figuring out that I could parent objects to other objects as part of Animation Nodes. The node setup for parenting is even pretty simple.

It’s as easy as setting “parent” in the Object Attribute Output node.

I used parenting to create the galaxy shot. I started with a spiral-making loop I made on Sunday. I created three sets of spiral objects with different colours of spiral and different sizes of blob. I parented each spiral to a different empty and set the empties spinning, then parented those empties to a master empty which moved them across the screen. Initially all three spiral bits were parented to one empty, but everything rotating at the same rate was dull to look at. It helped a lot to experiment with the rotation using empties as a guide instead of having to maths it.

It’s been too long between OpenGL renders…

Also this week I found out that constant updating can be switched off. This is useful when working with thousands of duplicated objects at once. The spiral was slowing my computer down pretty badly.

Over to the swimmy eggs now. Each of the eggs swims towards the top of the screen at a randomised rate which is peculiar to that egg. Of course, when certain aquatic animals like jellyfish or octopodes propel themselves through the water, there’s a push forward then a lag as the “water” absorbs its momentum.

This is an early version of the eggs which looked a little too much like an LSD hallucination of a thousand screaming mouths.

To mimic this, I added a couple of sine functions to make things more interesting – one controls the compression and expansion of the eggs’ shape, and the other offsets to the position to make the motion speed up and slow down. The two sine functions are out of phase – they both have a period of 12 frames, but they reach their respective extremes at different points. The actual node structure that makes this possible is a bit hard to follow, but this is the node setup I used to figure out how to tweak it so that it not only fit the swimming action but the beat of the soundtrack.

This is me hiding my mess.

Here the complexity of the maths and node tree is kept away from where I have to think about it, and that’s how it should be.

Good factoring also means putting messes in their own separate node tree to make it easy to reuse them in another file.

The psychedelic kidney swarm was made possible thanks to Omar Ahmad’s excellent write-up on transformation matrices in AN. I’d wanted to get the eggs swimming in different directions, and that meant having them turn to whichever direction they were headed in. I was getting nowhere with that on Thursday night, but finding Omar’s tutorials inspired me to give it another try on Friday night. Even though I couldn’t get the kidneys to change rotation/direction mid-swim, I did manage to get them turned to face the direction that they’re swimming in a straight line.

At least they’re not screaming mouths.

Here’s a more presentable version of the swimming trick, where timeOffset (can be positive or negative) is added to the Time input of “Animate Vector” to move the kidney from A to B.

Sinewaves – is there anything they can’t do?

Finally a word about materials! I have been using randomised colours a lot in RYG-O and that means using the Object Info node’s Random output a lot. The problem is that Random only outputs a single random number and I need three (hue, saturation and value) to make an entire colour.

To turn a random number into an entire random vector, I follow the Random output with multiply, modulo and add nodes before they hit Combine HSV. Multiply stretches the incoming range by an arbitrary amount to introduce a little bit more randomness. Modulo clamps the output of multiply to a particular upper limit, effectively setting a range from 0 to the modulo amount. Add offsets that output upward and sets a minimum.

For instance, in the following node setup, my random colours will have saturation between 0.6 (add 0.6) and 0.8 (modulo 0.2 + add 0.6), and values between 0.5 (add 0.5) and 0.8 (modulo 0.3 + add 0.5).

Three random numbers from one – bargain!

The quantiseHue group does a modulo, multiply, round and divide operation to quantise any random number input to 0.0 (red), 0.166 (yellow), 0.333 (green), 0.5 (cyan), 0.667 (blue), 0.833 (magenta) or 1 (red again). That’s how I’m sticking to my assigned colours. 🙂

That’s all for this week. See you at Easter!

By quollism

A creator of quollity stuff.

One reply on “Sine functions to the left of me, matrices to the right..”

Leave a Reply