normal problem

Hi, I am trying to create a customized toon shader using nodes and normals, but there is this terrible problem that is costing me hours (if not days) withouth a solution.

You can see in the image of the lion alone that there is a fine border that I created using his normals in nodes as you can see in the picture of the node. I really like it and need to keep it because his strength is different throughout the body in a nice way.

In this case he is in the center of the camera and all is fine. But when I composite him in the scene, where he is not in the center, the normals gets destroyed in a terrible way.

I have a theory why this happens that I try to show in the drawing. Blender should analyze the normals with radial rays with the camera in the center. In that way, both sides of the lion visible to the camera would be black (in blue in my drawing).
I guess blender analyze the normals considering all the rays parallels to the central ray coming from the camera. This way the camera would see a lot of black on the left side and the right black side would be occluded by the mesh, as it is happening.

If this theory is right, why is it happening or how to solve I do not know, but I beg you people to help me because I am going crazy trying to solve it my self.



Great looking model!

Try the node setup in the screenshot attached. (This was created in the latest SVN, I hope you can use it in whatever version you’re using.)


Thank you a lot, Rawpigeon! I would never have guessed it alone. Well, I did not even understand what is going on in this node you showed me, but I repeated it and it works. Some day I may understand why. Sometimes blender is not to be understood.

Instead of finding a way of repaying you, may I ask another thing?

I will use this node with blender rendered edge. I think good things will come with both metods, but I would like to have more control in this edge thing, like turning it off in some meshes or controlling its thickness by mesh. But just being able to turn it off is good enough

Experimenting with it (actually suffering with it because it would not work in the beginning until I figured out this) I found out that meshes with ztransp on (even opaque ones) will not have an edge. But if an edge is behind it, they will be visible, like I am showing you in this attachment.

Do you or anyone knows how not to let it pass through the mesh?
Or how to get a by mesh control of the edge. That would be better, but not necessary.

Thank you again for your help with the node.



I’m glad it worked. It’s quite simple actually - your theory was correct. Your nodes were calculating the dot product of the object geometry normals and a constant vector (as shown in your “Bad” image). I replaced the constant vector with the camera view vector so it would behave just like you’ve shown in your “Good” image.

Unfortunately, edge rendering doesn’t play well with ZTransp. It seems to work ok with ray tracing, but I think you’ll need to work around the problem somehow. I think the solution used to be that you needed to turn on the unified renderer and select All, but I don’t think this is an option any more. Sorry I can’t be more help with this.

. blend???

I see Rawpigeon. What I do not understand is what this vector math does, what is a dot product, what is the difference with normals, what is the relation to the geometry node to the normal node to the vector math and so on. I believe it involves mathematics I would not understand, so I am quite happy with the recipe you gave me anyway.

As for the ztransp… I solved it keeping the ztransp in the back trees and not in the front tree. It is a cheap way but for this time the problem is solved.

Ionee, sorry, I can not provide the blend file at the moment. Authorizations things. But I believe the problems are not file specific, so it might not be necessary.

It is possible to add a scene input in the Compositer, so you could have two scenes in the blend, one with Edge, and one without: And then composite them together.

As Guismo suggested, it would be great if we could use this technique to make edges of different colors on different objects or even made of different materials. I can see that that can be done with multiple render passes composited together but I was wondering if there is a way to use the UV input to the geometry node to select which objects to apply th composite to?

Also, I have looked all over the wiki and I can’t find an explanation of the geometry node, can anyone point me to a resource so that I can understand it??