# My Aim in Short

I would like to controll my Anistropic material with an image input.

# What I Have Tried

I made a mockup to show what I would like to achieve. This is a single plane with an anistropic material as simple as the following. The trick here is to distort the UV map (and add multiple lamps). By the method explained above, I managed to make an wood like anisotropic material. However, ...

# My Problem

Here I have 2 problems.

1. I do not have an intuitive controll over the pattern. (I prefer an image input)
2. I use an excessive number of vertecies. • Will the material be used on complex geometry or just a plane like in your example? – bstnhnsl Jun 20 '18 at 14:09
• The plan is to have it only on a simple geometry. Well, of course, I would like to know a way that applies to both. – Allosteric Jun 20 '18 at 14:16

This is math heavy.

So in this case, the only thing that varies, texel by texel, is the tangent. The tangent is a vector that points in the direction of delta UV (well, either U or V, I can't remember.) In order to represent this on a texture, you code how much the tangent has been rotated from a "base" UV map.

So start by making an additional, "straight" UV map. Now you need to know the difference in the tangents between the two UV maps. To do this you can use the arc cosine (math node) of the dot product (vector math node) of the tangent vector of each UV map (tangent node). This will give you a value ranging from 0 to pi that represents the amount of rotation, but not the direction (clockwise or counter).

In order to determine the direction of rotation of the tangents, you need to create another vector. Start by taking the cross product (vector math) of your two tangents, then take the cross product of the cross product vector and one of your tangents (probably the undistorted tangent). The first cross product is a vector orthogonal to both tangents, while the second forms an orthogonal 3D basis with the undistorted tangent and the first cross product. Now you can use the dot product (vector math) of this second cross product with your other tangent (from the distorted UV map) and evaluate whether it's positive or negative to determine the direction of rotation. Putting this together, you can generate a value ranging from -pi to pi:

(dot(cross(tangent1, cross(tangent1,tangent2)), tangent2) > 0) * arccos(dot(tangent1, tangent2) - (dot(cross(tangent1, cross(tangent1,tangent2)), tangent2) < 0) * arccos(dot(tangent1, tangent2)

(What if any dot products are 0? Or what if any cross products are 0 vectors? Then that means that tangent1 = tangent2, and there is no rotation; it is equal to zero.)

If you remap this to the 0,1 range (add pi, then divide by 2*pi, math nodes), you can bake it to a texture on your undistorted UV map and you have an image map of the rotation of your tangents.

How do you use this texture to regenerate your anisotropy? Load as non-color data from your undistorted UV. Now rather than feeding this into tangent, you can use it directly as a rotation input for your anisotropic shader, which accepts input in the 0-1 range anyways. Don't forget to use your undistorted UV map to generate the tangent vector.

Order of operations on cross product matters, and rather than getting into details regarding that, just be aware that you may have to invert your rotation depending on how you do it (rotation = 1 - rotation, subtract math node).

Once you do this, you can safely delete the distorted UV map. Your rotation is coded on a texture, and you can access it with only 4 vertices.

• While your explanation is very thorough, a picture is worth a thousand words. Could you please post a picture of the NodeTree and the result? – Scott Milner Jun 20 '18 at 20:10
• Thanks for the answer. I would set this as the best answer as soon as I tried it myself (a little too busy) In the mean time, would you provide me an image of the node and texture? I think I can manage it without them but it would be helpful for me and others – Allosteric Jun 20 '18 at 23:09
• @ScottMilner This problem isn't actually worth solving. If you want to play with texture anisotropy, just make a grayscale texture, plug it into rotation, and start playing. Baking from a distorted UV map is not worth it. The only reason for this answer is because the math is worth understanding for other, future problems, and pictures of node setups aren't going to help anyone understand the math. It's fine with me if this isn't the best answer, and if somebody wants to spend some time making pictures for the same solution, then yeah, you should mark them the best answer. – Nathan Jun 20 '18 at 23:48