NPR Rim Light help

I’m attempting to create a fake rim light on only the top, back edges of my model. The model will be animated, so I can’t fake it using a Normal node since that doesn’t follow the camera.
This paint-over shows my intent:
2018-10-19_13h24_05

Using Fresnel/Layer Weight Nodes I get this but, as you can see, the rim light is all the way around every object.
2018-10-19_13h43_20

I attempted to use a camera mapped gradient to mask it, but camera mapping takes every object into consideration rather than each individual object. Which means I end up with heavy rims all the way around objects at the top, but they fade away on objects near the bottom.
2018-10-19_13h50_21

but it almost works (I’m showing the gray-scale image since it’s difficult to see with the texture)
2018-10-19_13h49_44

You could use the normal of an empty parented to the robot and tracked to the camera. Then you can use the empty’s object co-ords to drive a gradient, with a mapping node to control the rim angle.

Here I’m using two locked tracks so that the empty doesn’t roll.
EDIT: And by your post, I’m assuming you want the rim light to follow the camera. Otherwise, skip the tracking.

1 Like

Thank you! That’s definitely a step in the right direction, but the gradient is still a single gradient across all objects that use the same material. It’s the same issue I have with camera mapping the gradient, though now I can control it, so it does sort of work.

Is there a way to control the output of a Normal node with an empty?

I see your point. Now that I’m thinking of it, that whole setup is way more complicated than it needs to be…

vector transform node. You can just use that to drive the object’s normal space with camera space. No need for empties and constraints.

Here I used the normal node to control the rim direction like you were wanting, but I’d personally use a mapping node and a gradient instead. That way you can animate it if need be.

2 Likes

Oh, brilliant! Thank you! I thought there must be a way to calculate vectors or normals together, but math is my unfortunate Achilles heel. I think this is what I am looking for, and, yes, I’m using a gradient instead of the Normal node.
Thank you again!

My pleasure, and bonus for me, I now have another control for my custom toon shader.