Neat Toon Shading Technique
By: Martin Krol.
Today we will do some fiddling with some of the tools inside the Animation Timeline. What we are after is a simple toonshader. In short, the way we will get this is by grabbing what is inside the animation viewer, copying the information into a canvas, and then putting the image through a series of filters.
step 1.)Preparation
First you want to do your animation , or just scene setup in its own separate script. this will make sure that you can animate quickly and dont have to put the scene through the filter calculations every time you advance a frame. ( Tip: I usually split apart the scene setup, camera animation, and the actual animation in separate scripts, then just use the "Add Operation/ Programming/ Call Script" command to bring in these scripts as single channels. This makes things a lot more tidy than having to browse through hundreads of channels in the scene. ) ( also use containers where appropriate. )
step 2.)Setup
Press "F5" Make a new script and name it "Toonshade-Composite".
Once inside this script. what we want to do is first grab the information inside the viewport, and put it into a canvas so we can process the image. ( keep in mind, what you see inside the animation viewer will be directly copied into the Animation Canvas, so it is important for best results that the size of the Animation Canvas, and the Animation viewer are equal. )
Now, we first need to add this Animation Canvas. So on the top left of the Animation Timeline, click the downward triangle, and choose Add Animation Canvas. set the size. click OK.
This is the setup i use for this task.

step 3.)Copy 3D Viewer.
To Copy the data from the Viewer and into the Canvas, put your mouse over the Animation: Timeline and press F6 ( or you can just right click and choose Add Operation ). From here scroll down until you find Canvas, expand the selection and choose "Copy from 3d Viewer". you should now see a channel in the Timeline that will execute the copy from 3d viewer operation every frame that it isenabled for. ( to see the image


step 4.)Filters.
At last we can start playing with the image inside the canvas.
1.)First you want to get the lines around your model. Over the Timeline, press F6, scroll down to Create Matte, and choose "Edge Key" , and for Mix mode, press "Pixel Sub". this will make sure that after detecting the sharp changes of the values in the picture, it will then Mix those with the picture rather than cover it, and just show the areas that the filter has detected.

2.)( optional ) sometimes you want to tone down some of the mid tones that are made by the Edge Key, so you might want to then try putting in a "Add Operation/ Filtering/ Blur". before the actual "Edge Key" channel to blur the image a little and make some of the sharp value changes a little less harsh. ( you can reorder the channels by pressing R while having your mouse over on the Animation: Timeline ) Set the opacity to something low like "0.30", and the count up to about 3
( you wont notice much of a difference after using blur on low settings. but it will be enough to get rid of some of the unwanted outlines. )
3.)Next step is to Enhance the shading on your models to make the composite look more "Toon-ish". To do this we will add a "Add Operation/ Recolouring/ Equalize". change the Mix mode to "Subtractive", Channels to "Value", Opacity down to below " 0.20 ", High to a low number like "0.08", and Low to a mid value. ( between 0.30 and 0.60 ).

4.)Toonshading without making step colouring isnt really toonshading. so what we will do next is add steps to any gradients in the image. "Add Operation/ Recolouring/ Posterize". I will let you play around with the settings on this one. but you might want to turn on subtractive for the Mix Mode, and keep the opacity at "0.5"

5.) If your image turned a little too dark to your liking, you can make it brighter through a number of methods. In this case i was just fiddling with some of the operations and the one that seems to give good results is "RGBA Recolor" (Add Operations/ Recolouring/ RGBA Recolour ).

Action= "Scale/ or exponent" , Amount "1.2" , Opacity "0.8" Mix Mode = Additive. this will make the image brighter, and add a little further contrast to the image.
step 5.) Saving images out to Hard Drive.
if you want to save your images to hard drive, just choose "Add Operation/ Canvas/ Save Canvas to File", name the image, choose the file type, and when you playback your animation it will process each frame and save to a space on your hard drive that you chose.
( Note: once you save the images, disable the save channel. because once you start fooling around with the settings further and scrub through the timeline. each time you move the cursor, Mirai will save the image over the old ones you had. so just to play safe. turn off the save channel when you dont need to use it. )
So there ya have it. A simple toonshader that you dont need to render out before doing any work. although you could if you wanted. I will make another tutorial some other day on making another script that sets your scene up for alpha channels for if you want to do it using the screen grab method. until then. have fun!