To Shuffle Colour
The idea that put me on this journey of coding in Nuke.
While working on a team project at university, I needed to find a way to change up the outfits of the actor who was walking back and forth. The basics of the script was two plates of the same actor walking back and forth, which I then isolated to make each walk cycle a looped clip. As the actor is the same in each loop, I needed a way change the guys outfit.
The things to keep in mind is that each walk cycle has a different frame count.
At first I tried to use expressions as I had used for the Hologram Dancer asset (check it out here), but I was unable to figure out the maths to make the colours change at the start of each loop. So because I couldn’t get the expressions to work and couldn’t find any nodes that randomised values, I did what anyone would do. I taught my self Python.
It took a few weeks, a lot of professionals were contacted, everyone at my university that even had a moment of experience was contacted for assistance, and of course, ChatGPT got used. Even then it took a while. Not one source of information, advice or experience could answer the problem I had given my self. Every piece of information was absorbed processed and duct taped together by my self to make this node work.
What I Wanted?
I wanted a node that would randomise the red, green, blue gain values, when ever the frame number is a multiplier of the loop count of each cycle.
What Changed?
Originally the plan was to modify a grade node and give it the randomising function, however I couldn’t get it sorted and decided to split up the tasks. So a new node was made, the colour shuffle. With this node, it had variables to keep track of the frame count, the amount of changes, when a change should happen, as well as a variable to show the value of the red, green and blue gain, with user defined variables for the user to define the amount of frames the loop has.
Then I had to get the functions working. Initially just to randomise the values but I to get it working on every frame, I tried making a function that allows the node to run on every frame. Now that didn’t work and had to change it a few times to other similar functions, none of them really worked reliable.
What does it Look Like Now?
the Colour Shuffle node is now it’s own node that has it’s rgb gains values linked to the grade node that controls the colour change of the input image.
So to make it all work, I made a gizmo that holds the colour shuffle node as well as the node sub-assembly that isolates the alpha for the change. Though I initially wanted the gizmo to be one node, the gizmo works pretty well, with the colour shuffle node being triggered by a python button that pre-renders the entre colour randomisation process. Though I did discover that it wouldn’t wipe the previous key frames when I re-ran the pre-render button, so I made a python button that removed all the keyframes, so I could reuse the node for the other walk cycles.
Are there any next Steps?
This gizmo/node is no where near done, it just works enough for the current project.
There a few things I want to change, I want to include a dropdown menu that selects the interpolation as it defaults to linear, so I currently need to manually change the key frames to constant so it sticks for the duration. The other change would be to let the user control the minimum and maximum values of the randomisation, as the current range is built in (0.1 to 4.0). I want to give that control to the user so that it could be used for xyz control as well.
Over all I found the project really fun and educational, so I guess I’m gonna be adding programmer to my CV.