Cel-shading code

I’m a cel-shading artist trying to develop a way to make a vector match so the light gets properly distributed through the mesh. I’m using mostly Animation Nodes for that.
I wonder if there is any built-in module in Blender that would allow me to get a point or spot light vector?
I’m sending a picture of what I mean. There has been a lot of cel-shading productions lately, but 3D softwares lack of instruments in order to produce a high quality cel-shading. The limelight of cel-shading productions is Archviz, they have produce in Softimage titles as Dragon Ball Fighterz, Blaz Blue and Guilty gears. The way to do it right is by pairing the light vector and the normal vectors of the mesh, so a 90º light vector upon a mesh results in mesh lit and more than that unlit, there is a small spectrum of gradient hardly separated (in stepped decay) which depends on the angle away from the normal.
How could I achieve such result? Is there a way to pick the light vector data from the lights? I wish there was! Again: I’m sending a picture. Cheers!


You should take a look at ToonKit for Cycles… you have to pay for it, but it does a lot of what you’re asking about in OSL (As far as I can tell, I’ve been eyeing it for some time but haven’t purchased it myself).

1 Like

Look nice! But I couldn’t find any videos showing connections with texture, if that’s the case is a big problem!

1 Like

IMO doing this with vector math is the wrong way to do it, anyways- since it doesn’t give you shadows. You should look at EEVEE’s Shader-to-RGB node and some color ramps.

Now that I’ve read your post again, I will suggest this- you can use the Texture Coordinate node and then choose the light you want to use for vector math with the eye-dropper at the bottom of the node. And the geometry node can give you the location of the current object.

Again, unless you have a reason for doing it this way, I wouldn’t recommend using vector math for this at all. It’s much harder to art-direct and requires a lot of tweaking. And it doesn’t give you shadows.

1 Like

Yeah, that was going to be the next concern… haha
Hell, that’s difficult to implement man!
Anyways… I asked Toonkit, they said you can use textures no problem.

1 Like

Anyways, thank you so much for your concern and your answer!

1 Like

Toon shading is my favorite! There’s a discord for Blender Non-photorealistic rendering if you need help, too. Click on the link called “discord server” at the top of this page: https://blendernpr.org/