Half-Lambert and Phong Material for Blender 2.8x (NPR) (Eevee & Cycles)

http://pasteall.org/blend/index.php?id=52799

Half-Lambert Shading.blend (1005.1 KB)

Material with node groups for Half-Lambert as defined in the Valve Software Developer Communnity wiki and Phong Specular as best I could figure.

The important parts of the material are in their own groups. There’s the core of the Half-Lambert system which is just a dot product and the half, add half, pow 2 as defined in https://developer.valvesoftware.com/wiki/Half_Lambert and then an “overall” Half-Lambert system which implements light intensity based on distance and brightness, and a phong specular group which I’m not 100% confident about but appears to look right, just when fed big numbers for intensity and exponent. It could just be my light’s brightness though. And there’s a group that takes the position of a light from the surface of an object through a Texture Coordinates input node set to use a light’s location through the Object output and makes a normalized light vector to use in the dot product of surface normal and light.

It doesn’t use actual real lights in the scene and instead uses an empty to get the location and intensity of a light, controlled by its scale. Light falloff and intensity are interrelated and I couldn’t find a clean way of separately controlling them so it’s all just scale-based.

Additional lights will need to have their own Half-Lambert cores and object information for light vectors.

It should all be labelled and more-or-less cleanly arranged.

In the material there’s some junk with colors and groups called Tint and Brighten, these aren’t related to Half-Lambert or Phong, they’re just things for coloring the shading I was playing with. The idea was to drive individual RGB gamma adjustments with an RGB color but it works a little unintuitively atm. If you want to refine it yourself the equation I came up with later on for getting 0.5 to equal a given value for coloring the midpoint of gray shading was 600/(x^0.0024)-600 but it was done by matching known values with regressions and not actually reversing the mathematical process–I just couldn’t wrap my head around it.

There’s no shadows implemented, I couldn’t think of a way to do it in the material that gets just the shadows and not direct + indirect lighting so it’d likely need to be handled with a render layer with a plain diffuse material override and a render pass of just the shadows to add them via the compositor, which means the shading coloring will need to be done in the compositor unfortunately, if at all.

Feel free to do whatever you want with these nodes.

3 Likes