Group layer Depth Sort: Sort layers by Y-Position

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

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
Lukas
Posts: 1294
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Group layer Depth Sort: Sort layers by Y-Position

Post by Lukas »

Thanks for the very thorough answer. I'm afraid I've been down all those paths as well :D

The Reveal order way is pretty solid, but I still feel it's one of the many things that make Moho rigs overly complex for what they can do in the end. Having multiple layers of the same thing is usually the kind of thing that makes updating and repurposing rigs a pain, in my projects anyway. :/

Stroke-limbs are usually great, I wish their benefits (exposure, curvature, very simple rigging/animating) would be as easy to apply to other art styles. I find simple rigs gets the best out of animators and automation is definitely a dangerous rabbit hole. I find myself automating a lot of things though, but almost only to make things simpler (less layers, less bones, less keys, less tools, less clicking, less everything, okay more re-use) - in a way that does not restrict the animator or Moho - instead of adding a lot of fancy things.

I do hope using the z scale value for layer order is one of those things that simplifies projects, it might :)
User avatar
Greenlaw
Posts: 9191
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Group layer Depth Sort: Sort layers by Y-Position

Post by Greenlaw »

Lukas wrote: Wed Feb 26, 2020 7:52 pm The Reveal order way is pretty solid, but...Having multiple layers of the same thing is usually the kind of thing that makes updating and repurposing rigs a pain, in my projects anyway. :/
I know exactly what you mean. Sometimes I'll use Reference layers and clearly mark them as such so I don't edit the wrong layer. (I wish Moho had a native Lock button in the layers window like AE has--that would help prevent this problem.) Most of the time, I wind up using Duplicates though and hoping I won't have to edit the layers later.
I find simple rigs gets the best out of animators and automation is definitely a dangerous rabbit hole. I find myself automating a lot of things though, but almost only to make things simpler (less layers, less bones, less keys, less tools, less clicking, less everything, okay more re-use) - in a way that does not restrict the animator or Moho - instead of adding a lot of fancy things.
I agree. Finding that sweet spot can be a real balancing act, and for me it varies between productions and characters.
I do hope using the z scale value for layer order is one of those things that simplifies projects, it might :)
It really should simplify it for arms in many characters and the legs in some characters. I'm looking forward to trying it out. Will let you know how it goes.

Thanks again for releasing the script!
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Group layer Depth Sort: Sort layers by Y-Position

Post by hayasidist »

that use of the otherwise "unused" z scale is **really** neat!
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Re: Group layer Depth Sort: Sort layers by Y-Position

Post by funksmaname »

Amazing Lukas!
Daxel
Posts: 967
Joined: Wed Mar 27, 2019 8:34 pm

Re: Group layer Depth Sort: Sort layers by Y-Position

Post by Daxel »

This is awesome! I'm now diving into the more advanced layer sorting techniques, finding very useful every aproach explained here, and the Z scale technique, even if I still don't understand it very well, it really looks like a game changer. I would love an official implementation of something like this, that the program seems very capable of doing and the users really need to simplify their rigs.
Noob question: what's the original purpose of the Z scale parameter?

Edit: sometimes the Lua console says "LK_sortByZScale.lua:20: attempt to call method 'Layer' (a nil value)" I don't know what does that mean, I'm using Moho 12.5.


Edit2: I've been thinking about a system to have an easy to use UI to order the layers with bones and your Z-scale system:

Basically there would be one smartbone for each controled layer, every smartbone would assign to it's controled layer a Z scale value from 1 to 100 (for example).
Each bone, while pointing upwards would assign the max Z scale value (100) to it's layer and pointing downwards would be the minimum Z scale value (1).

All those smartbones would be exactly on the same spot, but they won't be animated directly, they will be hiden and they will move following one specific pin bone for each one, that will be the target bone and will show the name of the controled layer.

Then, the pin bones would be in a column, where the Y position of each bone is the layer position they have, so you should clearly see and modify the order of the layers moving the "head" pinbone, for example, above or bellow the "neck" pinbone. I only made one of these bones to test it and it works perfectly, I can move the pin bone up or down and see in realtime how the drawing goes above or behind the other drawings (that had Z scale values previously aplied, manually).

To the bed I go. Thanks for the script, Lukas.
Daxel
Posts: 967
Joined: Wed Mar 27, 2019 8:34 pm

Re: Group layer Depth Sort: Sort layers by Y-Position

Post by Daxel »

Lukas wrote: Wed Feb 26, 2020 7:52 pm
I do hope using the z scale value for layer order is one of those things that simplifies projects, it might :)
I'm using your script and it is amazingly useful, but I keep getting this error "LK_sortByZScale.lua:20: attempt to call method 'Layer' (a nil value)" very often.
Do you get that error too? I don't know anything about scripting.

Also when I keyframe the z scale value, the sorting only takes effect on the next frame, so if I want to change it on the frame 24 I have to make the keyframe on the frame 23 and the sorting happens at frame 24. Very easy to work that way but I don't know if it is related to that console error.

If you know what am I doing wrong that would help me so much.
User avatar
Víctor Paredes
Site Admin
Posts: 5646
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Re: Group layer Depth Sort: Sort layers by Y-Position

Post by Víctor Paredes »

I'm just coming to say today I animated a crowd of around 100 characters walking on the sideway. This script made it so simple! Just duplicated the characters each time, made some small modifications on the shapes and animation and then put each character wherever I wanted without having to worry about layer ordering.
It is amazing how much time it saved me and how much control over the scene I had.
Thanks again!
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
Lukas
Posts: 1294
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Group layer Depth Sort: Sort layers by Y-Position

Post by Lukas »

Víctor Paredes wrote: Mon Jun 22, 2020 7:33 pm I'm just coming to say today I animated a crowd of around 100 characters walking on the sideway. This script made it so simple! Just duplicated the characters each time, made some small modifications on the shapes and animation and then put each character wherever I wanted without having to worry about layer ordering.
It is amazing how much time it saved me and how much control over the scene I had.
Thanks again!
Awesome :)
User avatar
Lukas
Posts: 1294
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Group layer Depth Sort: Sort layers by Y-Position

Post by Lukas »

Daxel wrote: Sat May 23, 2020 2:22 amI'm using your script and it is amazingly useful, but I keep getting this error "LK_sortByZScale.lua:20: attempt to call method 'Layer' (a nil value)" very often.
Do you get that error too? I don't know anything about scripting.

Also when I keyframe the z scale value, the sorting only takes effect on the next frame, so if I want to change it on the frame 24 I have to make the keyframe on the frame 23 and the sorting happens at frame 24. Very easy to work that way but I don't know if it is related to that console error.

If you know what am I doing wrong that would help me so much.
Sorry, I don't have any time to look into it, but I'll try and remember to check it out some other time.
chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Re: Group layer Depth Sort: Sort layers by Y-Position

Post by chucky »

Huh, I missed this entire topic, really cool stuff.
Great idea Lukas, impressed also by the script and smartbone idea.
V cool.
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Group layer Depth Sort: Sort layers by Y-Position

Post by hayasidist »

Lukas wrote: Tue Jun 23, 2020 9:08 am
Daxel wrote: Sat May 23, 2020 2:22 amI'm using your script and it is amazingly useful, but I keep getting this error "LK_sortByZScale.lua:20: attempt to call method 'Layer' (a nil value)" very often.
'''
Sorry, I don't have any time to look into it, but I'll try and remember to check it out some other time.
I think SimplSam has cracked the "attempt to call method 'Layer' (a nil value)" issue .. http://www.lostmarble.com/forum/viewtop ... 12&t=33764
Daxel
Posts: 967
Joined: Wed Mar 27, 2019 8:34 pm

Re: Group layer Depth Sort: Sort layers by Y-Position

Post by Daxel »

Correct. Now it works fine and I'm experimenting with it creating a smartbone system that is easy to use.

I create a smartbone for each body part. It's convenient to create one and then copy-paste it as many times as you need. Those smartbones are controling the Z scale value of the body parts. I keyframed the z value to be 1 at the beggining of the smartaction and 30 at the end, and there are float numbers interpolated in between so it will work even if you have more body parts.

Each of those smartbones is set to always point to a different pin bone, that will be the one you actually move when you want to change the layer order.

You can then hide the smartbones and you will have those pin bones arranged in a half moon fashion that you can easily see and control. If you need the arm on top of the head in a specific frame, you
just put the arm pinbone on top of the head's one. And you can easily save certain layer orders in form of actions or control the layer order with a different smartbone like a head turn smartbone. And maybe I will find useful to have different half moon controllers like this, like one only for the layers inside the head etc.

I'm still experimenting with this but I'm loving it. Thanks Lukas for the script and SimplSam for the fix.

Image
User avatar
Greenlaw
Posts: 9191
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Group layer Depth Sort: Sort layers by Y-Position

Post by Greenlaw »

Nice work, Daxel! I think I understand what you did, and this layout seems clever.

Bookmarking your post to try the setup myself later today. :)
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Group layer Depth Sort: Sort layers by Y-Position

Post by synthsin75 »

Yeah, clever SB setup, Daxel.
chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Re: Group layer Depth Sort: Sort layers by Y-Position

Post by chucky »

Pretty cool how it can be copied and pasted to make additional layers without too much fuss... Nice.
Post Reply