# Rotationally stretch or compress 3D texture around Z axis

I want to distort a 3D texture around the Z axis in Cycles. I found here that you can convert cartesian texture coortinates to polar coordinates but the problem is that you end up with a projected 2D texture. I want to preserve all the 3 dimensions and stretch or squash the texture around the Z axis to get a behavior like this :

...but with 3D texture coordinates.

Can we achieve that with Cycles nodes ?

• you want to scale a texture around the Z axis, or do you want to create the effect shown on the bottom image, or is the texture intended to control the distortion of the objects? Commented Jul 3, 2017 at 1:51
• I want to scale the texture around the Z axis which would give the effect on the bottom image except not with meshes but instead a 3D texture (like noise or voronoi). So if I were to use volume scattering I would get the same behavior. Of course there would be a half plane in which the texture would disappear as I would scale it down which would create a seam, just like for the Cartesian to Polar coordinates conversion. Commented Jul 3, 2017 at 2:14
• I swear I did this by accident yesterday answering another question. Trying to find it. Commented Jul 3, 2017 at 2:31
• Please find it back ! Commented Jul 3, 2017 at 2:45
• Sorry, not sure what did it, I know I was messing with the scale, mapping node, separating the XYZ and some math nodes in between, I saw that effect and tought that it looked neat, and then went on because what I was lookign for had nothing to do with that. Also it probably wasn't a clean answer either, because I suspect the real answer is probably much more complex, Im going to give it a whirl, but I think this might be above my possibilities. Commented Jul 3, 2017 at 2:57

Found it. The idea is to use a gradient node in radial mode and plug it to the angle of a rotation node (just like a Mapping node but with an input socket for the rotation). Since such a node doesn't exist in Blender we make it with math nodes.

First the rotation node itself (it's a node group) :

then the general setup (the green node is the rotation we made above and the yellow node is the one to animate (the second value in the Multiply node) :

Result :

Here is the file :

• Why put in an answer that says "I found a solution and I am currently making this reply that I will edit..."? Just write your answer, then post it. Commented Jul 5, 2017 at 12:54
• no kidding it was simple >.< great solution, looks really fun! Commented Jul 5, 2017 at 21:03

Just for illustration of what I PM earlier..

• this solution is also great, tough I don't understand the math behind it, super elegant! Commented Jul 5, 2017 at 21:02
• yes but the result is not as clean towards the center (the texture converges to it). You can see it when looking from the top. Commented Jul 5, 2017 at 23:18