Fills as alpha

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
Víctor Paredes
Site Admin
Posts: 5646
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Fills as alpha

Post by Víctor Paredes »

Hi, I think this is probably not possible, but maybe I'm wrong :)
Do you know if there's a way to export fills as alpha? I know using Render styles you can set every fill as transparent, but that doesn't work for what I'm looking for, because I don't want to see what is behind each fill (overlapped lines, for instance).
I know you can modify Render styles by scripting, so maybe there's something there that could be done. What do you think?
Image Image Image Image
Moho Product Manager

www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Fills as alpha

Post by hayasidist »

not quite sure what you mean..

guessing:

filled shape overlaps another with stroke and fill as on the left below - blue/white fill, black stroke

and you want fill (and outermost stroke?) as in the right? - e.g. black fill white stroke

Image
User avatar
Víctor Paredes
Site Admin
Posts: 5646
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Re: Fills as alpha

Post by Víctor Paredes »

Sorry I wasn't clear.
Image
Considering the background as alpha, the first image is what I have. The second one is how it looks if I render it with transparent fills. The third one is what I'm looking to get.
Image Image Image Image
Moho Product Manager

www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
User avatar
Greenlaw
Posts: 9191
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Fills as alpha

Post by Greenlaw »

I've wanted to do that a number of times, typically so I can light a character in comp without affecting the lines.

In the past, I've had to make a reference of the rig with different styles applied, and then use Layer Comps to make a separate 'Fills Mask' pass, and maybe a 'Strokes Only' pass.

If you're using After Effects with Moho, a trick that may work even better is to render your Moho animation with NO anti-aliasing. Then, download and install the free OLM plugins for After Effects found here: OLM Digital R&D. The plugins (notably the 'Keep' plugins) give you a number of ways to select the present colors and strokes and create new masks within AE, and they work best when there is no anti-aliasing in the renders. Then, after you've finished with your selections and processes, you add OLM Smoother to apply your antialiasing.

This is a fairly common 2D workflow used in TV animation production. I've used it with Harmony render passes to AE, and it should work fine with Moho render passes too. (I've been meaning to use it with Moho renders the next time I needed this kind of masking.)
User avatar
Víctor Paredes
Site Admin
Posts: 5646
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Re: Fills as alpha

Post by Víctor Paredes »

Greenlaw wrote:I've wanted to do that a number of times, typically so I can light a character in comp without affecting the lines.

In the past, I've had to make a reference of the rig with different styles applied, and then use Layer Comps to make a separate 'Fills Mask' pass, and maybe a 'Strokes Only' pass.

If you're using After Effects with Moho, a trick that may work even better is to render your Moho animation with NO anti-aliasing. Then, download and install the free OLM plugins for After Effects found here: OLM Digital R&D. The plugins (notably the 'Keep' plugins) give you a number of ways to select the present colors and strokes and create new masks within AE, and they work best when there is no anti-aliasing in the renders. Then, after you've finished with your selections and processes, you add OLM Smoother to apply your antialiasing.

This is a fairly common 2D workflow used in TV animation production. I've used it with Harmony render passes to AE, and it should work fine with Moho render passes too. (I've been meaning to use it with Moho renders the next time I needed this kind of masking.)
Oh, that's great. I will try it at home (and check the other plugins too!). Thank you very much, Dennis!
Image Image Image Image
Moho Product Manager

www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Fills as alpha

Post by synthsin75 »

Maybe too complicated for your task, but here's how I'd do it in Moho alone: http://www.filedropper.com/alphafills

Just make each shape it's own stroke and fill layers and mask them, subtracting the fills from the strokes, with the layers stacked in the opposite order (front one at the bottom). The only drawback, aside from too many layers, is you lose centerline strokes.


There's no scripting access to modifying render styles, aside from just setting which one to use.
User avatar
Greenlaw
Posts: 9191
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Fills as alpha

Post by Greenlaw »

Yeah, ideally, I'd love to see a native option for this, and an option to have the fill extend to the center line of the strokes.

I've done something like this in Harmony but it's easier there because of the program's nodal compositing system--just branch out from the original character, treat second branch to become the 'fill mask', and give each branch its own output node. This is essentially the first approach I described but it's a lot more efficient to do with nodes than with a lot of extra layers and multiple project renders.

I know it's a tall order for the devs, but someday I'd like to see a similar (but better) nodes system inside Moho.
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Fills as alpha

Post by hayasidist »

A few vague and not well-joined-up thoughts here:

>> you can set the background colour via scripting interface to have zero alpha
>> there is a render style "background" which does use the background colour but not the alpha (but I guess if it did you would see the strokes "underneath" as in Victor's 'not this' picture -- similar to render style back transparent)
>> but a "destructive" fill - i.e. one that simply took the fill rgba from a "higher" layer rather than blending fills with alpha < 1 ought to work? (is this a realistically achievable request to the devs?)
>> in the meantime, if you are feeding this into a compositor, it ought to be possible to set the background colour to a nice primary green or blue or whatever else you're not using, use render fill as background and chromakey it out? (maybe easier than selecting a set of colours with OLM??? can't say as I've never used those plug-ins)

anyhoo -- as I said, not completely joined up thinking but maybe might spark some better ideas...
User avatar
Greenlaw
Posts: 9191
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Fills as alpha

Post by Greenlaw »

hayasidist wrote:...maybe easier than selecting a set of colours with OLM??? can't say as I've never used those plug-ins)...
It should be pretty easy if the stroke is one color. Just select that, knock it out, and what remains in the alpha is the fill. If you have some kind of 'erode/dilate' node or plugin available, you can sort of expand the alpha to where the centerline would have been in the stroke. Then, if necessary, lift the alpha to the RGB channels (In AE, you can use Shift Channels or Set Channels, and in Fusion you'd use Boolean Channels.)

If there's more than one stroke color, it could get more complicated but it depends on the image.

This is where I wish Moho supported .exr and could embed the Layer/Styles data in the Object/Material ID buffers. Then much of the hard work is done for you on export.
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Fills as alpha

Post by synthsin75 »

A slight improvement, so you can animate from a single original layer: http://www.filedropper.com/alphafills_1

This could be automated with scripting. Say you have an animation and you want to render with this effect. A script could reference everything, or selected layers, set those to not render, create all the necessary references and masking, allow you to render it, and then revert everything back to how it was. That way all the excess layers wouldn't have to be an issue while animating, nor kept around to inflate file size.
Stan
Posts: 199
Joined: Sun Apr 19, 2009 3:22 pm

Re: Fills as alpha

Post by Stan »

I already have a script that can paint all fills to one color (it does some other things too), so you can use green or blue for all fills and then chromakey.
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
User avatar
Greenlaw
Posts: 9191
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Fills as alpha

Post by Greenlaw »

Oh, that reminds me of a technique I used to employ for 3D renders. Basically, I set object visibility properties to use full-on R, G, or B values or to be visible only in the alpha channel. Objects I didn't want to be rendered as part of a matte was set to black and behaved like mattes within in the render. This way, a single project could render up to four custom mattes in a single image. Since the colors were 100% luminous, I could disable all lighting and raytracing effects and get this 'multi-matte' rendered out lightning quick. Then, in AE or Fusion, I set the image's RGB channels to show either only R, G, B or alpha, and get a perfect matte with anti-aliasing...and no color keying necessary.

There are better ways to do this now but this was one reliable low-tech method I used for many year. (Actually, I still use it occasionally.) :)
Post Reply