[SOLVED] Angle based material that excludes one axis

I am trying to create a material that should look like a chain given a cruziform base mesh.
For that, I have create a material with chainlinks. Now, when looked at straight on, that looks off as of course the flat nature of the chain links become evident.

I am now trying to create a material that will switch the texture based on the Z rotation angle compared to the Z component of the vertex normal. Given that the chain mesh might move around compared to the camera, its important that only the Z rotation is looked at. I don’t want the texture switching when the chain is looked at from below, only when its looked at from the side.

I hope you get what I mean… else I will have to create a drawing :slight_smile:

I was able to click something together using the VertexNormalWS and CameraVector node and getting the dot product of those, and that worked when looking from the side, but I cannot get the material to ignore a shift of the camera towards the bottom of the chain. I think my logic is wrong.

Does anyone know a good way to realize such a thing in the material editor? I think I am out of my league here.

EDIT:
I spent another hour debugging the nodes output and trying other nodes… yeah, not the most scientific approach unless you see trial-and-error as a form of science :wink:

But I got my angle based switching to work. My mistake was using the CameraVector instead of the CameraPosition node. In hindsight, it makes sense. Guess the camer vector mostly is useful to find out where the camera is looking at, not where the camera is in relation to the pixel being rendered.

This is the node system:


Probably not the most elegant solution, but it works. Material ends up quite expensive, but that is mostly down to POM to give the chain the illusion of depth. Result is satisfying though, and the chains will not be filling up most of the screen, so it should do the trick nicely.