# Vector math to get Curve object silhouette

If you color ramp the Facing output of a Layer Weight node, you can make a mask of faces at glancing angles. This can be used as a material based silhouette mask for effects, or directly as line art.

Here is a curve beveled into a cylinder showing the effect working pretty nicely.

However, the effect doesn't work so well on larger faces, such as the sides of a cube, or down the length of this cylinder. In those cases, it shades the whole surface because it is all the same normal facing. I am trying to find a way around this problem.

I learned from this question that it is possible to use UVs and vector math to get a curve's direction. It seems it should be possible then to either use a similar method to get the silhouette of the curve, or use it to mask out of the Layerweight along the curve, or something along those lines. But I'm not strong enough on my vector math to figure out what needs to be done to make this work.

Anyone tried something like this before, or know what to do? Of course, it will only work on curve objects.

• have you tried this solutions? blender.stackexchange.com/questions/562/… Oct 24, 2017 at 18:52
• @MCunha I am familiar with all the methods in that answer, but the goal here is not to get any form of contour outlining. I'm specifically trying to do it with vector math so that it can be done in the material. Oct 24, 2017 at 23:47

The solution is to calculate the crossproduct of the incoming and curve direction vectors. The absolute of the dotproduct of that and the normal is the facing which you can connect up to your color ramp.

• This is the right sort of thing. It seems we've created an effect similar to color ramping layer weight, but via a different method. So this answer is correct, but it looks like I may not be able to use it for the artistic effect I wanted. Oct 27, 2017 at 4:06
• To clarify, what I wanted to do artistically was to remove the area down the middle when viewed from any angle (don't care what the end caps do though) Oct 27, 2017 at 4:46

First of all yes i know this answer is not a shader solution.
Neither do i know how deeply you know blender.

So I was puzzling for a while, as i gave a solution for the linked article as well. Though then i realized maybe you just want to have such an effect for some production goal. And how to get there isn't that important, maybe you just want to have outliner effect on technical drawings for example. As that's a very common usage of the effect you want.

If something like that is indeed the case be aware that there is another way to achieve contour lines, its possible to create it using the most basic freestyle line shown below :

(And if you would like to have a little bit more detail then just add silhouette.)

(and if you want to hide any feature of shape then make it emmision as i described in the article you linked)

• Thank you, but as I have said in other comments, I am specifically trying to figure this out in the context of vector math on curves. It matters for the production goal. Freestyle is very limited and can't be accessed within the material. Oct 25, 2017 at 21:21
• Ok i understand, i'll puzzle some more then Oct 25, 2017 at 21:59

Yeah, you want send the View Vector from a Camera Data node into the Normal input on your shaders.

I added Subsurf to soften it a bit. Object masks often do better if they don't cut off suddenly, so that was the thought there. You can tweak that if you want.

You may decide you don't need Glossy.
I thought it looked decent, but it might not be needed for your purposes.

Hope that's what you were going for. Lemme know what'cha think.

• I'm afraid I don't understand what this is doing at all, or what it has to do with the question. Oct 23, 2017 at 19:19
• You're trying to make a black & white mask to outline objects for use in something like Photoshop or Gimp, right? Oct 24, 2017 at 19:43
• No, I'm trying to make a mask down the length of a curve object Oct 24, 2017 at 23:45
• To only get light on the curved surface, and nothing on the flat side? Oct 25, 2017 at 10:34
• No, it isn't to do with shading at all. This is to make a mask based off angle of normals, minus some areas based on curve direction. Oct 25, 2017 at 20:36