# Toon Shader Programming/Noise Generation/Line Coloring

First off, I need two types of shaders, one for the "background" objects, and another for the "cel/moving" objects. The output will look something like this (but in color): (Mickey & the ship's wheel are cel objects, and the ship & grass are background objects)

shader toon(
color Diffuse_Color = 0.8,
float Diffuse_Size = 0.9,
float Diffuse_Smooth = 0.0,
color Specular_Color = 0.1,
float Specular_Intensity = 0.0,
float Specular_Size = 0.2,
float Specular_Smooth = 0.0,
float Reflection_Strength = 0.0,
float Reflection_Roughness = 0.0,
output closure color BSDF = 0)
{
if (isdiffuseray() > 0.5)
BSDF = 0.0 * emission();
else
BSDF = Diffuse_Color * diffuse_toon(N, Diffuse_Size, Diffuse_Smooth)
+ Specular_Color * Specular_Intensity * glossy_toon(N, Specular_Size, Specular_Smooth)
}


1. Whenever I add any "gloss" property, a compilation error is thrown, how can I fix this, and how can I make a gloss roughness property that makes the reflection blur, but with sharp edges? Like this, except the bottom image doesn't have the "ghosting" around the edges (the lighter colored "outlines"): Original Rough Visualization
2. More of a lighting-related question, but can certain lights illuminate the whole model, without shadows, but others do cast shadows? This would probably be created with a lighting script. Like this: Shaded Unshaded
3. How can I add seperate specular & alpha transparencies?
4. How can I add a slight displacement to the model on any frame it moves/deforms, to give it a sort of small inconsistency, like older cartoons?

The background shader would be similar, but the roughness property would work like a regular shader, and a noise-based setup would be used to shade the object, looking like the watercolor painted backgrounds of cartoons.

Finally, can freestyle line editor make an irregular line that looks like it was drawn with ink (cel objects) or pencil (background objects)? Not only this, but can the color of the line be based on certain material properties, such as reflection, transparency, & emission, with a color ramp defining which colors to map to the properties?

Sorry if that's a lot. I'm really new in the shading area of expertise. Thanks for any help! :)

• Just for clarification, do you intend to implement this as GLSL shader or is it supposed to be a node-based material for Cycles or Eevee? – rjg Jul 23 at 21:42
• @rjg It is supposed to be used as an OSL file, which will be accessed using the "Script" node. – chirpywiz711 Jul 24 at 23:43
• That's not my area of expertise, but hopefully somebody in the community can help. – rjg Jul 25 at 8:53
• @rjg Thanks anyways! – chirpywiz711 Jul 26 at 18:04