Anim8or Community

General Category => ASL Scripts => Topic started by: neirao on October 17, 2016, 06:19:10 pm

Title: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: neirao on October 17, 2016, 06:19:10 pm
Hi guys! :)

im starting my news 3D characters(but i wiil render like 2D)
so, these days i remember about this request...

AUTO GENERATOR and APPLY the 2D CELL SHADING MATERIAL:
please see the images :)

1-atual mode
2-with script mode


Someone can do this script :)????

This is very usefull - time saved on multiples objects!!

Thanks!!

Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: neirao on October 17, 2016, 08:46:21 pm
what do you think guys?
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: nemyax on October 18, 2016, 03:29:31 am
I think contour shading should be done differently.
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: neirao on October 18, 2016, 03:46:20 pm
yes!!
in this sample i SELECT ALL and put the same distance
but in the script we can select 2 shapes and put distance X and select anothers shapes and put distance X2, etc :)

PS: in the sample above i use only simples Spheres primitives, but in a complex shape, may works diferentily (better or worst) ;D ;D
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: Raxx on October 18, 2016, 04:01:53 pm
It's possible to do this. Even moderately easy for its most basic implementation. If no one takes a stab at it I might be able to work on it this weekend.

Of course, if Steve enables custom shaders for materials then this old method of outlining won't be necessary, and the results and ease of animation would be much, much better.

By the way, the term "cel-shading" refers to the flattening of the shading into a single tone, and does not refer to the black border/outline effect.
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: Steve on October 18, 2016, 05:35:50 pm
If only it were that easy. If I add custom shaders I'd have to support them in the ray tracer as well - and that's a ton of work!
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: neirao on October 19, 2016, 06:27:22 pm
Wow Raxx!!
thanks if you try :)

Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: daniel99 on October 20, 2016, 10:19:19 am
A couple of years ago I had a project like that, where I had to use this double mesh technique. Yes, a script that will make this outline would be useful. Great idea, neirao.
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: neirao on October 20, 2016, 03:28:09 pm
Thanks Daniel! :)

yes, very usefull!
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: daniel99 on October 20, 2016, 04:33:08 pm
neirao: You're welcome, bro! :D
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: Raxx on October 20, 2016, 09:29:58 pm
So, I got to work on this in my free time, and discovered that I can't make double sided materials via script (not documented anyway).

So unless that gets fixed, you'll have to create and apply your own outline material. I decided not to make the flat-shaded material either, for the sake of consistency. Basically it's just an outliner, not an actual cel-shader-er. Thus, I'm calling it...CelShadurr

Instructions:

Uniform scale or double click and manually enter the outline thickness.
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: daniel99 on October 20, 2016, 11:46:12 pm
Omg, Raxx, of course! :) Who else? The mastermind of scripts. Thanks, bro! Thanks! :D
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: Raxx on October 21, 2016, 12:05:52 am
You're welcome! Hope it helps, somehow. If you can't tell, I'm not very impressed with what it can('t) do >:(

I forgot to mention it, but you can change the thickness of the outline either by scaling it using the uniform scale tool or by double clicking it and entering it manually. It's measured in Anim8or units.
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: daniel99 on October 21, 2016, 12:25:34 am
Yeah, I've noticed. You may not be impressed, but maybe DaVinci wasn't impressed with Monalisa when he made it either. Anyhow, it's simple, but very useful script :D Thanks
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: Raxx on October 21, 2016, 12:59:58 am
Good news, I fixed the one bug and made a few optimizations. The new version is in my post above.
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: neirao on October 21, 2016, 01:16:52 am
wow thanks Raxx! you are a genius!! :)
i wake-up only for try it :)

no need auto create the texture! only this is very usefull.

Thanks!!!

i find only a problem(in this script version) is because we dont can select
the objects separately...

example:
there 3 objects(like a character "1 face" with "2 eyes") in stage...
and i need create for the eyes "outline thickness  value: 0.5"
and  the face  "outline thickness  value: 1.0" this is not possible in atual script
because he select ALL OBJECTS in SAME TIME!

is possible we can choose separate objets and apply the script?

thanks :)





Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: Raxx on October 21, 2016, 01:38:41 am
I chose to go the parametric shape route because it is easiest for the user to create and scale the outlines. In order to allow per-shape outline widths, I can offer two options:
#1 is easier for the user, in my opinion. I can also add an auto-width parameter to the parametric shape, where if you enable it then it makes the width of the outline related to the size of its bounding box. So smaller shapes would have smaller outlines, and bigger shapes would have bigger outlines.
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: neirao on October 21, 2016, 01:54:09 am
nice Raxx,
right, i try using "_noOutline" in the mesh name works very well
and i agree:  using the "_###" is more easy. :)

but think with me, using the "_noOutline" in sequence(separate objects groups)
we need "every time" "put"' and "remove" this information, because the script will get all previous outlined objects...and create
outline again if we no remove/put this information...

if the script works "only in objects selecteds with mouse" this is time saved!

i dont know about the complex made this in this new change in script! ::)  :)

Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: daniel99 on October 21, 2016, 02:05:46 am
Just a question about somethin' might be a problem sometimes, Raxx.
1 is the original mesh - lowpoly subdivided but not converted to mesh.
2 is the outline shape - subdivided converted to mesh.
When animating, the shapes bend differently because they're different poly count. (3)

Is there a way to correct this? (4) Maybe the script could generate the same type of mesh or maybe there's a technique?

Same problem I have when, for example, I apply fur (with Phur) to a mesh. Because the body mesh and the fur mesh have different polycounts. Any solution for such a problem?
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: Raxx on October 21, 2016, 10:30:57 am
Ah, yes. I forgot about that issue. There's no way to access the control mesh via ASL, nor to convert the control mesh to a subdivision mesh within a parametric shape. I think I brought this up a few times in the past but these features have yet to be added.

The only real option would be to put the inner shapes to subdivision 0, update the CelShadurr shape, convert the CelShadurr shape to subdivided, and then revert the inner shapes back to their original subdivisions. Or else you could convert the inner shapes to mesh in their subdivided form. Same for PHUR.

It'd be nice if there was mesh generation and access in the Scene Editor...then I could just make the outline conform to the rigged/skinned/animated shapes. Same with PHUR (with more dynamic effects available).
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: daniel99 on October 21, 2016, 12:50:48 pm
Raxx. Oh, yeah! Good advice. Strange I didn't think about it. It solves all the problems for CelShadurr.
But I'm not sure it works for Phur, the reason being the fur is made of many hair meshes, and they will react to the bones the same way, subdivided or not. If I generate the fur on the unsubdivided body, the hairs will keep their original positions after subdivision of the body, so they won't match. Some of them will float in the air, in convex surfaces of the body, and some will be deep into the skin, in concave areas or the body...
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: Raxx on October 21, 2016, 03:20:19 pm
Yeah, PHUR is a little tricky. To get the best results you'd have to convert the body subdivision mesh to mesh so as to permanently make it subdivided. This way the PHUR will much more accurately stick to the mesh when it's all being deformed.

So when dealing with PHUR, I recommend trying your best to use weighted envelopes instead of painted weights. This way you can have an object containing your "working" version (non-converted-to-mesh shapes), and an object containing your "final" version (converted-to-mesh shapes). Then you skin the final version using envelopes and if you need to make changes you can edit the "working" version and replace the "final" version's contents with a copy of the "working" version.

Then, when you're 10000% sure your model is final, you can change over to painted weights and do some good quality weight painting.
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: daniel99 on October 21, 2016, 07:49:18 pm
Yes, subdividing the body usually does the trick, but sometimes I need to keep it unconverted to mesh. Anyhow, with great care I kinda solve this problem, using precise movements and camera angles.
But you made some amazing scripts so far, so you really have my respect, sir.
Thanks, Raxx! :D
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: Steve on October 22, 2016, 02:09:33 am
Raxx writes fantastic scripts, if you ask me. Nice work.
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: Raxx on October 22, 2016, 03:14:44 am
Thanks :)

So here's quite possibly the last update to this script, until double sided materials gets implemented in ASL at least.

I'll make this the official release post for now.



CelShadurr, the script that doesn't actually shade anything

What it is
This is a parametric shape script that creates an outline around all mesh geometry in the object, kind of. You have to add a double-sided material to actually get the outline effect. But still....

Instructions

Only tested in Anim8or dev release 1247
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: daniel99 on October 22, 2016, 03:40:02 am
Cool. Too bad you've changed the icon. It was funny and I was getting use to it :D
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: neirao on October 22, 2016, 12:33:02 pm
Thanks again Raxx!

how i say before:
if the script works "only in objects selecteds with mouse" this is time saved!
with it, no need the "_noOutline" parameter! :)
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: Raxx on October 22, 2016, 03:45:48 pm
daniel99, yeah I liked it too, but the script was getting to be less turd-ly so I figured I'd change it. It's commented out in the script, so if you reeeeallly want it then you can change

ASL Snippet
  1. /*#button(26, 26, 2, 0x00000000, 0x00410200, 0x00420100, 0x00422108, 0x00206110, 0x0010e210, 0x0020c010, 0x0221b808, 0x0203fc08, 0x0107fc08, 0x0107cf00, 0x001f8040, 0x003e03a0, 0x007c3ff0, 0x00787ff8, 0x00fdfffc, 0x01fffffc, 0x01fffffe, 0x01fffffe, 0x01fffff6, 0x01ffffe2, 0x01ffff04, 0x00ffc008, 0x007ffff0, 0x00000000, 0x00000000);*/
  2. #button(32, 32, 2, 0xfffffffffe000000, 0xffffffffffc00000, 0xfffffffffff80000, 0xfffffffffffc0000, 0x01fe0000, 0x007f8000, 0x001fc000, 0x1007f000, 0x3803f800, 0x5400fc00, 0x10007e00, 0x101c3f00, 0x000c1f80, 0xfffffffff8140fc0, 0xffffffffaf2007c0, 0x55c003e0, 0xffffffffaaa001e0, 0x555001f0, 0xffffffffaaa838f8, 0x55541878, 0xffffffffa22a287c, 0x4881403c, 0xffffffffa20a803e, 0x2820801e, 0x4402401f, 0x1080421f, 0xffffffff8004a10f, 0x00002f8f, 0x00001107, 0x00009207, 0x00001007, 0x00001007);

to
ASL Snippet
  1. #button(26, 26, 2, 0x00000000, 0x00410200, 0x00420100, 0x00422108, 0x00206110, 0x0010e210, 0x0020c010, 0x0221b808, 0x0203fc08, 0x0107fc08, 0x0107cf00, 0x001f8040, 0x003e03a0, 0x007c3ff0, 0x00787ff8, 0x00fdfffc, 0x01fffffc, 0x01fffffe, 0x01fffffe, 0x01fffff6, 0x01ffffe2, 0x01ffff04, 0x00ffc008, 0x007ffff0, 0x00000000, 0x00000000);


In a text editor.

neirao, sadly a parametric shape deselects all other shapes before it is created, so there's no way for the script to determine what was selected or not. I submitted a feature request that would fix this. I have v0.4 ready and waiting with it already implemented, on the off chance that Steve can get to it.
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: neirao on October 22, 2016, 07:40:12 pm
all right, :)
I understand the programming limitations.
your script is already very good, very helpful! only I asked about the change even if it is not possible to be able to go on record here in the forum! :)
thank you anyway!
Title: Re: SCRIPT REQUEST! - 2D cell shading (AUTO GENERATOR)
Post by: daniel99 on October 23, 2016, 11:31:07 pm
Raxx: I was thinking to look for that! :D Thanks, bro! Great job!