Nuke: Creating paintings

My new Nuke tool: RandomTile.

Tile a given image at random positions, sizes and rotations, filling the project format.

This new tool of mine was more of a test to see how far I can push Nuke. When it didn’t explode and take the computer with it, I added more and more features and to my surprise Nuke took it on the chin. It turns out that there’s seemingly no limit to the amount of nodes in a script, so long as you put them in a group.

RandomTile can be used in many ways including:

1) Splatter a shape or image randomly over the screen at varying sizes and rotations. Useful if you want to quickly create a larger texture or repeating pattern to wrap onto some geometry, for example. This is why I initially made the tool; the existing Tile node just repeats the image in a uniform grid. Even using several Tile nodes and rotating them and moving them around on top of each other still produces obvious repeating lines. Here’s an example plugging the standard ColorWheel into RandomTile:

colorWheel

2) Make simple 2D particles by plugging in an animated shape. It will randomly offset the time for each tile. Take the above ColorWheel and put a transform after it, animating it back and forth, up and down, doesn’t matter if it goes way off screen, then make a RandomTile with a time variation of 50 frames, Scale variation and Rotation Variation of 1. As each tile has its own scale, rotation and time offset, they will all appear to be moving around independently. If your global range is 1-100, extend the animation at least 50 frames beyond each end of the timeline to get the best result. For quick results, use my gizmo WaveMaker to generate a continuous animation curve. With a noise wave you could easily make a bunch of wobbling bacteria or buzzing insects. A slow meandering animation and you could perhaps make snow or dust particles without going into 3D.

To give the illusion of distance, you have the option to ‘stack’ the tiles with the smallest at the back and larger ones in front (closer to the camera, as it were). You also have the option to generate a depth matte, based on the size variation, so you can add a ZBlur at the end to introduce depth of field, or use it to grade smaller/larger ones differently. Here’s an example of a simple buttlerfly image using those options:

butterfilesTile

…and here’s a look at another example of the depth matte created:

depth

3) Make a random stylised version of a second image using embossed tile shapes. It also gives you the option to plug in a second ‘Source’ image and instead of using the tile’s original colour, each tile takes its colour from the average colour at that position on the second image. The result is, when each tile is put together, it builds the second image, in a pixellised/mosaic kind of way. You also have the option to emboss each tile to give it more texture. Here’s an example using the colourwheel and a photo:

Original PhototiddlyWinks

4) Create a ‘painted’ version of a second image by using various brush shapes as tiles. Circles are one thing, but if you grab a brush stroke image from somewhere and use the above method, with some playing around and choosing different sizes and options you can create coloured brush strokes to make up the second picture. The best thing is, as RandomTile preserves the alpha of each tile, you can make several RandomTile nodes using the same Source image, but different brush shaped tiles, and merge them over each other. There is also the option to provide a Distortion Map, which distorts each tile before the colour is applied to it. So, give it a lumakey of the photo and the brush strokes will be persuaded to shape themselves to the photo more. Here’s a quick example I did using the above photo:

broadStrokes

First, use broad strokes for the base.

largeDabs

Then block in the main areas with some large dabs of paint.

mediumStrokes

Now some medium sized strokes to bring in more detail. With a little embossing.

thinStrokes

Now some thin horizontal strokes.

wispyStrokes

And finally some wispy strokes for good measure.

painting

Slap them all together, and you get a painting.

This is a quick example I put together, there are no doubt many ways to do this.

There is another very handy option which I didn’t use in this example: provide a Weighting Map; either some kind of lumakey, or hand drawn with rotoshapes. You then have the option to recalculate the position of all tiles and have more of them cluster around the white areas of your Weighting Map than the darker areas. So, if you wanted to concentrate the smaller detail strokes in the centre of the screen, perhaps where a person is, you just draw a white shape there and press the Adjust For Weighting button.

So anyway, a photoshop-style painting effect using nothing but standard nuke nodes. You will need a pretty powerful machine though if you want to use many thousands of tiles. The above was fairly taxing on the high spec linux box I used, but it wasn’t that slow considering there are about 5000 tiles in total (approx 50,000 nodes internally, all linked up in a complex script with expressions and everything). The creation of a RandomTile node takes a little while, but the above frame only took a few seconds to render. This tool is free to use at your own risk; if your machine starts to smoke as a result of using it, I take no responsibility ;) I’ve tried it on my 3-year-old iMac at home and it runs fine, but is noticeably slower than the production linux box when you start using more than 1000 tiles.

What does a complex script with 50,000 nodes in it look like? Well, I can’t tell you, because Nuke allows you to generate insane scripts inside a group using python, but woe betide anyone who tries to open the group to have a look inside. But, as I can just put all the controls on the outside, there’s never any need to open the magic box.

5) Create a moving ‘painting’ by also providing distortion and ripple maps based on the plate. Now, a pretty painting effect is fine, but applying it to a moving image is probably what you want. I’ll be frank, it’s hard to achieve decent results because if the tiles were somehow regenerated on every frame, you’d get horrible flickering and it’d be a mess. If they don’t move at all (the default for RandomTile), it’s better, but the image would seem to move behind the strokes, like looking through a stained glass window. I have come up a couple of solutions that are somewhere in between: Provide a lumakey or roto of the plate as a Distortion Map as mentioned above. This way, when things move behind the strokes, the strokes themselves get smooshed around a bit. Combine that with the further option of providing a Ripple Map and with some playing around you might get something that works. The Ripple Map is again perhaps just a high contrast luma key of the plate. When a tile is over a white pixel it moves up and right a set amount, when it’s over a black one, it’s back to the original position. As a gradient moves behind it, it will move more as it gets brighter. The upshot is, as a bright object moves around underneath, a ripple is sent through the tiles as it passes beneath them. Will need experimentation, but I had a play around and it gave an interesting result.

Get RandomTile here. The zip file contains the .py file containing all the functions, the icon and an example menu.py file showing you how to set up a button in the toolbar. If you find it useful or fun, let me know. I’m sure people can come up some inventive ways to use it.

PodPlayer app released

Quick shameless plug for my new app:

PodPlayer is an alternative to the iPhone’s iPod player and is tailored to playing back podcasts back-to-back in the order you wish to hear them. It also gives you a lot more control over playback:

  1. Skip forward or back by a custom amount
  2. Use your headphone remote to skip forward by custom amount (skip past adverts or boring bits)
  3. Enter a list of start offsets for podcasts with long intros, so you get right to the content.
  4. Mark a podcast as played (skips to the last second, triggering the playcount increment).

So, the upshot is you no longer need to get the phone out of your pocket on a crowded train to select the next podcast or skip past over-long adverts.

Also features built in Sleep Timer which allows you to set the phone on your bedside table and control with the remote. When Sleep Mode is on, playback will always stop after a set time. If you are still awake, just press play on the remote and playback will resume AND the timer will begin again. This repeats until you are asleep.

I use it every day, hope others find it useful too. Get it here.

Nuke wave expressions to copy and paste

Using waves to drive animation in Nuke

Creating repeating or random patterns in the curve editor can often be made easier by using expressions that describe a curve. Sine, noise and random functions are very useful, but forcing them into the exact shape you want can be a little time-consuming. So, following my previous post talking about my gizmo WaveMaker, I thought I’d share some handy expressions it uses which you can copy and paste straight from this blog when you need them, rather than installing the gizmo itself.

Click on any value in any node, press ‘=’ and type an expression. Right click and choose ‘Curve Editor…’ to view the curve.

These expressions give you full control over the width, height and position of the wave. Either replace the following variables with your actual values, or add your own sliders to the node so you can adjust them on the fly (see below for how to do that).

waveLength (how many frames between peaks of the wave)
minVal (the wave will never go below this value)
maxVal (the wave will never go above this value)
offset (shift the wave back and forth in time)

Edit on 15/01/12: I have also provided simple versions that will work immediately once you paste them in. They will just produce a wave between 0 and 1 but that may be all you need.

Some useful wave expressions:

Sine

(((sin(((frame*(pi*2/(waveLength/2))/2)+offset))+1)/2) * (maxVal-minVal) ) + minVal

Simple version:  (sin(frame/5)/2)+0.5  (Wave between 0 and 1, replace the ’5′ to adjust speed) 

Square

((((sin(((frame*(pi*2/(waveLength/2))/2)+offset))+1)/2) * (maxVal-minVal) ) + minVal) > ((maxVal/2)+(minVal/2)) ? maxVal : minVal

Simple version:  (sin(frame/5)/2)+0.5 > 0.5 ? 1 : 0  (Wave between 0 and 1, replace the ’5′ to adjust speed)

Triangle

(((((2*asin(sin(2*pi*(frame/waveLength)+offset)))/pi) / 2)+0.5) * (maxVal-minVal) ) + minVal

Simple version:  (((2*asin(sin(2*pi*(frame/30))))/pi) / 2)+0.5  (Wave between 0 and 1, replace the ’30′ to adjust speed)

Sawtooth

((1/waveLength)*(((frame-1)+offset) % waveLength) * (maxVal-minVal) ) + minVal

Simple version:  ( 1 / 30 )*( (frame-1) % 30)  (Wave between 0 and 1, replace the two ’30′s to adjust speed)

Random

((random((frame/waveLength)+offset)) * (maxVal-minVal) ) + minVal

Simple version:  random(frame/5)  (Wave between 0 and 1, replace the ’5′ to adjust speed)

Noise

(((1*(noise((frame/waveLength)+offset))+1 ) /2 ) * (maxVal-minVal) ) + minVal

Simple version:  (noise(frame/5)/2)+0.5  (Wave between 0 and 1, replace the ’5′ to adjust speed)

Bounce

((sin(((frame/waveLength)*pi)+offset)>0?sin(((frame/waveLength)*pi)+offset):cos((((frame/waveLength)*pi)+offset)+(pi/2))) * (maxVal-minVal) ) + minVal

Simple version:  sin(((frame/10)*pi)) > 0 ? sin(((frame/10)*pi)) : cos(((frame/10)*pi)+(pi/2))  (Wave between 0 and 1, replace the ’10′s to adjust speed)

Sawtooth (parabolic)

((sin((1/(pi/2))*(((frame-1)+offset)/(waveLength/2.46666666)) % (pi/2)))>0.99999? 1 : (sin((1/(pi/2))*(((frame-1)+offset)/(waveLength/2.46666666)) % (pi/2))) * (maxVal-minVal) ) + minVal

Sawtooth (parabolic, reversed)

((cos((1/(pi/2))*(((frame-1)+offset)/(waveLength/2.46666666)) % (pi/2)))>0.99999? 1 : (cos((1/(pi/2))*(((frame-1)+offset)/(waveLength/2.46666666)) % (pi/2))) * (maxVal-minVal) ) + minVal

Sawtooth (exponential)

((((((exp((1/(pi/2))*(((frame-1)+offset)/(waveLength/4.934802)) % pi*2)))/534.5)) – 0.00186741)>0.999987? 1 : (((((exp((1/(pi/2))*(((frame-1)+offset)/(waveLength/4.934802)) % pi*2)))/534.5)) – 0.00186741) * (maxVal-minVal) ) + minVal

*Note: the waveLength value doesn’t really correspond to the peaks in Random or Noise waves, so you will probably need a smaller wavelength value for those.

To add your own sliders:

  1. Right click your node, choose ‘Manage User Knobs…’
  2. Click ‘Add…’ and choose ‘Floating Point Slider…’
  3. Type ‘waveLength’ into its name and label boxes. Give it a max and min value of 0 and 100.
  4. Repeat with each of the four variable names (above).

These  four sliders will appear in the ‘User’ tab of the node. You may find it better to create a ‘NoOp’ node, add the above sliders, but also add several extra floating-point sliders called ‘Wave1′, ‘Wave2′, ‘Wave3′ etc. This way you can use the same sliders to control several different expressions, then you can use any one of them to drive animations in your script.

It’s worth noting many of these wave shapes can be created using a few keyframes and telling nuke to ‘loop’ that section. But using expressions with a few sliders you can mess around with them a lot easier. Besides, maths is fun.

One more thing:

To describe a CIRCLE, put this in the X: 

(((sin(((frame*(pi*2/(waveLength/2))/2)+offset))+1)/2) * (maxVal-minVal) ) + minVal

and this in Y:

(((cos(((frame*(pi*2/(waveLength/2))/2)+offset))+1)/2) * (maxVal-minVal) ) + minVal

Simple version (X): sin(frame/5)*300

Simple version (Y): cos(frame/5)*300

(replace the ’5′ to adjust speed, replace the ’300′ to change the circle size)

Tip: put it in the X and Z in a TransformGeo after a Card to make a carousel type animation.

WaveMaker v3

I’ve added a few more gizmos and python functions to davidemeny.com, feel free to use them as you wish.

One of which helps you generate waves in the curve editor:

WaveMaker v3

Animating flickering lights or continuous movement is a doddle in Nuke if you know how to generate sine waves, noise waves etc in the expression editor.

For example: a simple sine wave ranging from 0 to 1 with a wavelength of n frames would be “=sin((frame/(n/2))*pi)/2+0.5″. For the maths geeks, whipping up expressions is second nature, but for many of us it’s a hassle to remember all the various combinations when we just want a thing that goes up and down in a repetitive or random way.

WaveMaker gives you a choice of a variety of handy wave shapes, lets you put in a minimum and maximum number, gives you a ‘Speed’ slider, an ‘Offset’ slider and then you just press ‘Generate’ to write out whatever complex expression you need to make that wave. Just link the ‘Result’ value to whatever you want to control and you’re away.

It also lets you use a second, slower wave to affect the other wave. For example, you have a high frequency pulsing noise wave but you want it to fade up and down in intensity over time. Just use a slow sine wave and tick the ‘use modulator wave’.

With version 3, I have now added a ‘squarify’ tick box, which converts any wave you come up with into a square wave version. I have also added loads more wave types, including TRIANGLE and SAWTOOTH.

Have a play around, you can make some pretty weird looking waves. This isn’t a gizmo you will use all the time, but when you do, it’ll save you a lot of time writing long expressions or creating lots of keyframes.

Night shifts: our possible future?

After re-watching the movie Inception, I had a thought: what if we could work in our dreams?

Mind Interface

Many predict that some time in the future we will dispense with keyboards, mice, wacoms and even our voices to interface with our computers, and solely use our minds. It’s hard to imagine it yet but give it thirty years and I’m sure technology would be there. If software was advanced enough to allow us to control a cursor and type words just by thought alone, then it follows that more complex operations could be possible: writing software, editing movies, animation, visual effects compositing….

Time perception

Now, according to Inception, and many of our own experiences, dreams appear to take place at an accelerated rate; one can nod off for ten minutes but experience a dream that seemed hours long. There is a documentary on the Inception Blu-ray talking about lucid dreams and the ability to step back from your dream, become aware of it and then control it. So if in the future techniques develop where lucid dreaming can be induced and controlled, similar to the movie, then this opens up many possibilites for exploring created worlds and effectively extending one’s lifespan by living in that accelerated time frame. Much like Picard did in that episode involving the space probe and the piccolo.

High speed computing

Now, take the above two possibilites and combine them. If we could induce a controlled dream state, where the person is existing in the accelerated time frame of the dream, yet is fully aware, then if we could suggest to them the idea of sitting at a computer desk and persuade them to use their mind to control the machine – and at the same time have one of our new-fangled mind-interface computers on a table next to their sleeping body, linked to their brain – then the sleeping person would operate the computer in their dream, but actually be operating the computer in real life. But at twice or ten times the speed.

Dreamworks

So, my prediction for the future is this: rows and rows of beds filled with visual effects artists, animators, or programmers, all hooked up to their personal dream machine and workstation. Their workstations a-blur with activity as they work through the night at stupendous speeds. The company is very happy, they can pay them a daily rate, but receive a week’s worth of work in just a single night.

No labour laws are broken. Hollywood smiles.

 

 

Which Way Back? 1.1 released

Hello app fans,

Just quick plug to say I have updated my latest iPhone app, so check it out if you haven’t already.

Which Way Back? on the appstore

Which Way Back?

Nuke: Reconverge, Anaglyph and Proxies

OverallStereoA quick one this:

If you’re using the Anaglyph node to preview your stereo comp, you might find unpredictable results when using the Reconverge node. If you’re viewing at full-res, no problem, but put it in proxy mode and the anaglyph separation will mess up.

As it’s useful to put a Reconverge node at the end of the script to bring the overall stereo separation into a comfortable place (at least for viewing dailies), this causes some annoyance. Much better to throw in a simple transform node with the translate-x split into left and right, and something like -10 in one and 10 in the other. To adjust this on the fly, you can put an expression from one to the other and hold the alt key to scrub left and right.

But I found I was doing this on nearly every shot; often having to push the whole scene back into positive space, so I threw it into a gizmo with an easy slider control.

Download it here.

Nuke: 2D to 3D

Despite every ounce of me being against cheap 2D to 3D conversions, working with a lot of stereo shots recently has led to me tinkering around with it. Shame on me.

Even though I am working on ‘proper’ stereo, shot with two cameras, a couple of shots required exaggerating the stereo in certain areas for effect. I used a similar method used in my previous post to distort the image differently in each eye to lessen/greaten the disparity in the chosen area.

I decided to make a quick gizmo to do that and in doing so, realised I could just as easily use the same method to ‘dimensionalise’ a non-stereo image, just by knocking up a depth matte and feeding that in. I’m pretty sure this is nothing new to most people and there may be much more elegant and complex ways out there, but thought I’d share it anyway.

As an example, I took this image:
example image

Then made up a quick depth matte with rotoshapes and ramps, so that far areas were dark, closer areas were white and shades of grey in between. I plugged that in to my gizmo and put an anaglyph node under that to see the result with red/cyan glasses. I did this very hurriedly so it’s not great stereo, but this gives you the idea:

example stereo image

So here is my new gizmo: Depth2Stereo, feel free to use it as you wish, but please use it for good and not for evil.

Here’s an example script using the macro:

 

If you don’t want to use the gizmo, here is an explanation of how to make your own:

  1. Set your project up with stereo views.
  2. Take the depth matte (if you’ve painted up your matte in rgb or alpha, use a Shuffle node to put it into the depth channel) then copy that into the ‘forward’ motion channel below the image. You could in fact skip using the depth channel altogether and just shuffle your matte into the forward channel. I decided to use the depth channel first because we’re feeding it something that looks and feels like a depth matte.
  3. Make a ‘Split and Join’ and put an iDistort on each eye. In each, set the UV channels to motion and untick the ‘v’. Set the UV scale in one to something like 15 and make an expression in the other one to ‘minus [the other one]‘…so you’d get -15. This will control the depth.
  4. Put an anaglyph node underneath, put your glasses on and play around until it looks right.
  5. If you are doing something that is set back into the screen, with your depth matte defining an area that bulges towards us, try setting an overall depth by putting a transform node on one side after the iDistort and moving it in the x direction to add disparity to the entire image. My gizmo has all that built in with handy sliders.

Nuke: Making Stereo Noise

After seeing the Foundry tweeted a tutorial on converting a 2D image of fire into a stereo image today, I wondered if you could use a similar method to generate stereo noise clouds within nuke.

Here’s a script I knocked up this evening very quickly to demonstrate the idea, please feel free to expand and improve on this!

stereo_noise_grab

Download the example script

  1. Set your new project to have stereo views (in the Project Settings).
  2. Make a Noise node. By default it generates a nice cloudy texture.
  3. Split off the alpha channel, invert it, then copy it back into the forward.u channel
  4. Make an iDistort node, set the channels to RGB, the UV channels to motion (and just check the u box), set the UV scale to 15 or so.
  5. Make a JoinViews and plug the iDistort into the left side and the original Noise into the right
  6. Stick an Anaglyph node under that and put on your red/cyan glasses to view your noise cloud in wonderful stereo.

This uses the motion channel values to distort the image horizontally; the black (0) areas have no effect, and the white (1) areas distort fully, and all shades in between. So that has the effect of pushing the white ‘peaks’ to the left, while keeping the black ‘valleys’ where they are. Giving the illusion of depth when viewed in stereo.

It’s not really like smoke, because you can’t see the other side, but perhaps a combination of several of these could simulate it better? Suggestions welcome.

If the noise isn’t animating, and you use the translate tab to move the noise around, you get the illusion of looking down onto a bumpy landscape with peaks and valleys. Could be useful.

Will play with this more, it may not be of much use but feels like there’s potential there for generating stereo elements to put onto stereo live action (if you can’t get hold of real elements, of course).

Teleportation and the Soul

Science Fiction is full of examples of teleportation as a means of transportation, most famously in the Star Trek franchise. But something that’s always bugged me is that using such a machine could very likely be wiping oneself out of existence. The more I’ve thought about this over the years it raises the bigger question of where consciousness resides and also whether immortality through technology can exist.

Transporters, or Death Machines?

teleporterOf course, transportation technology doesn’t yet exist so all of this is hypothetical, but science fiction is often a herald of what is to come, so in the unlikely event it happens in my lifetime I want to be sure I’m not stepping into a suicide booth, blissfully thinking I’m on the way to Tenerife for my hols.

So what makes me wary? Uncertainty. The traveller’s body is analysed, broken down atom by atom, stored as data in buffers, then reassembled again in their chosen destination. But assembling atoms in exactly the same configuration in another place is not transportation, it’s replication. Whether the result is perfect down to the atom and sub-atomic particle is beside the point; you have created an identical copy in another location. So where’s the original?

And here’s where the problem is: perhaps creating an identical copy of a person is enough for the rest of the world to perceive they are looking at their friend/sister/commanding officer, and if every atom and particle is the same, it follows that the brain would be an exact replica; all characteristics and memories would be there so the replicant themselves believes they are themselves. They not only believe that, as far as they’re concerned it’s as if no time has passed since they left their original location. So the world goes on as normal, but what happened to the original copy?

Did they cease to exist the moment of transportation? We’d never know, because the new copy would have all the memories of the original and their consciousness continues on. Maybe it’s safe, maybe not, but if I’m right, that means a person literally dies and is replaced by a doppelgänger each time they transport. Even if the particles were somehow being converted into exotic sub-particles that could jump through space and reconverted back again, there is still no way of knowing what happened to the original during the ordeal. It’s still the same person, but is it the same consciousness? The only person who knows that is the person themselves, there’s no point asking the person at the new destination.

Brain Dump = Immortality?

artifical brainSo it all comes down to where your consciousness is stored and whether it can be moved. Science fiction also suggests the idea of replacing all our body parts with bionic ones, and perhaps then replacing our brains with something artificial. In this way it seems we can live forever, as a machine brain won’t die and you could just upgrade your brain when newer technology comes along. But what is stored in there? Memories? Certainly. A perfect representation of the individual’s characteristics and personality? No doubt. But when the transfer happens, the old brain must switch off and the new machine brain be turned on. The new brain will think it’s the old brain and live happily ever after, but the old brain, and the actual consciousness of the person, has been turned off. Does anyone care? Of course not, this new doppelgänger is very convincing, as he/she believes they are the original.

Conscious in two places at the same time?

doppelgangerThe thing that underpins all this is the possibility of overlap. The body is dematerialized, fed into the transporter system buffers and that pattern is regenerated elsewhere – the brain is backed up, turned off, fed into a robot brain and booted up. This sequence gives credence to the belief that one thing is being transferred to another place; it was here, now it’s there. But this order of events is arbitrary. What if the copy was materialised or turned on while the original was still hanging around? You would have two identical beings, each with an identical consciousness, both quite rightly convinced they are the original. The conciousness has indeed been transferred elsewhere but unless the original is now seeing out of two sets of eyes, hearing from two sets of ears and can feel themselves standing on four feet, they are most definitely inside the first body. If we continue the normal sequence at this point, this is where they get obliterated.

But that’s fine, there’s a perfect copy who believes they’re the original just over there. Flick the switch.

Follow

Get every new post delivered to your Inbox.