I’m using a node-based material to render ponies in the style of the show My Little Pony: Friendship is Magic. First, my question. Is there a way to get the closest and farthest distances from the camera for a particular object and use those values in my node setup?
Attached is a .blend with my current node setup. Currently I have the node setup for the texture choice phase as the material. Then I do the lighting (which, for ponies, mostly consists of making the back parts uniformly darker) in the compositing phase. At some point, I definitely need to change the lighting phase so that less-lit parts are also less saturated (rather than just darker.) If you have trouble understanding my node setup I can elaborate on it later.
The main problem with my current node setup is that it’s unflexible and not sufficiently automatic for animation. The shader as it is is sufficient for rendering still images of ponies, but to animate ponies I would have to tweak the Z-buffer mapping in the compositor to get lighting to work right. One way that I’ve thought of to get consistent fake lighting that works with rendering in the show style is to find the points on the pony that are closest to and farthest from the camera, and using those to determine how I should map the Z-buffer to lighting. But, to do that, I need to find the points on the mesh that are closest to and farthest from the camera. And I’m not sure how to do that at all. Is it even possible using nodes? Or do I have to do something funky using Python?
The node setup is the most complex one I’ve made, so if you have some suggestions that are irrelevant to my question, please let me know.
pony-shader.blend (833 KB)