How to make flat shading in blender (basicaly like a 2D animation)

I’m trying to find out how to make a perfect 2D shader that responds to colored light. I can’t figure it out myself, I’ve tried 3 methods, toon shader, shader to RGB, and even OSL; but all of them didn’t work for me. Toon shader (although looks good) still looks 3D to me. Shader to RGB wasn’t really being cooperative, especially with colored light, and OSL didn’t support the use of light as a whole. You might be asking why I’d just use a proper 2D animation software, like Krita, but the reason I don’t is because I don’t really have a great setup for that (just a laptop), and I don’t want to spend hundreds of dollars on something I would be using sparingly. So please don’t recomend me that.

1 Like

Welcome to BA :slight_smile:

First of all, the “perfect 2d shader” you’re looking for is a bit of a unicorn- I personally, as well as at least five other highly prestigious art professionals I know, have been working on this very problem for many years. Let me spare you some searching and address this:

There’s no shader that is going to fix this. The only way to fix this is with a massive slew of various techniques ranging from camera-angle shapekeys to dynamic normal editing, with a nice mixture of dynamic UV-based inner lines animated on a geometry-nodes flattened proxy mesh and some 2D SDF shadow blending (see Petikam et al) thrown in for good measure. I’m not saying this to discourage you- I just want you to understand that there isn’t one simple answer for what you’re looking for.

That all said, I have built a shader after years of experimentation that does react well to colored light and has lots of powerful controls to get more of a 2D look. I think this will help you- check it out, especially the CEL_LIGHT part:

This is not everything you need, but it should get you started :slight_smile:

In terms of the normal editing I talked about, you can’t do better than @Ascalon 's work (check out their topics), and their site:

Referring back to Petikam et al, you can find that paper and research here:

You can find my personal (currently on-hiatus) experiments with that mechanism in Blender here:

While it’s in no way a complete solution, it is, unfortunately, the only existing implementation in Blender

3 Likes

oh, i can fix this easily. use your cel/toon shader… bake it… then flatten everything on the camera axis. wellah, all 2d. >>grinning<<

1 Like

A lot of good info there from Joseph; I’ll add one more… the GooEngine fork of Blender is specifically designed to aid in creating a 2D look. With various shader and light combos, you can have a shader respond to colored light (or not).

1 Like


:wink:

2 Likes

As others have said, its a difficult issue. A lot of the problem is limits in the Eevee pipeline.

Roughly speaking, here’s how the shader pipeline works:

  • Shading = the dot product of the Surface Normal and the Light vector. This is then modified by various light attenuation (like falloff) depending on the type of light.

  • The shading is multiplied by the Light’s strength, color, and shadow mask.

  • This is done for each Light, and its all added together. World/Ambient Lighting is also added.

  • This Lit Shading is then multiplied by the Shader Color (what you put into the Diffuse node’s RGB).

So all that combined is what comes out of the Diffuse node. When you use Shader to RGB, all that has already been combined. If you’re using Principled, there’s a bunch of Gloss mixed in too.

So the problem is that, in order to make a proper toon shader that works with colored lighting and behaves correctly, you need to be able to put the toon thresholding after the first step. It needs to go only on the Shading. But we don’t have the ability to do that. The Shader to RGB workflow forces us to put it after everything else.

So, in order to get a decent toon shader, you need to avoid using as many of the things that go into this as possible. Shader to RGB toon only really works properly with a single Sun Lamp set to Strength Pi, Color White, Angle 0, no shadows, and no World lighting. In any other circumstance, it will be wrong. And if you want colored light, it needs to be removed, and then multiplied back later.

Technically, it is possible to build the entire pipeline withing the shader nodes. But then you get into funky territory like having to input the parameters of every light with drivers or a script. And you still cannot get Shadows.

What Goo engine does is fix some of these problems by exposing the shading and shadow separately.

Alternatively, the above pipeline can be properly constructed in OSL (and keep shadows). You can check out the Cycles ToonKit addon for an example of this.

Or, the best solution is the community made Malt render engine. It was built specifically to solve issues like this. It comes with a proper toon shader and pipeline, lineart, etc and allows you to code your own GLSL. But its in early stages and is not new user friendly.

Of course, as has been said, the shader is only part of the problem. You also need clean Normals, as these are what actually represents the surface as far as the render engine is concerned.

1 Like