How to Twist a Procedural Material? I'm trying to figure out how to twist a procedural material applied to a mesh.

I have a hollow cylinder like a tube (the two end cap faces are deleted) with a noise texture applied to it. 

My nodes are:


Texture Coordinate - Generated output to a Mapping Node, Vector input.
Mapping Node - Vector output to Noise Texture, Vector input.


On the mapping node, I can see that the Rotation ordinates will rotate the texture on the surface of the cylinder. The length of my cylinder runs down the Y axis, so as I rotate the texture on the Y axis it rotates around the barrel of the cylinder. So far so good, but the problem is that it equally rotates the texture around the cylinder barrel all along its entire length.

What I want to do is to fix the material's rotation on one end of the cylinder, but rotate it around other end so that it twists or spirals down the length of the cylinder like the rifling in a gun barrel.

Is there a way to tell Blender "on that end of the cylinder the material's rotation is 0, and on this end it is 360 degrees (or 720, or -180, or whatever)?

This seems as if it'd be a piece of cake, but I'm just not seeing it.
While @DuateFarrajotaRamos's answer will seem to work for small angles of rotation, it only approximates rotation and will not achieve 360 degree rotation mentioned in the question. Instead, you can apply a rotation matrix to the actual vectors concerned.

A solution is mentioned as part of this answer https://blender.stackexchange.com/a/77638/29586 - where the X/Z coordinates are rotated based on the Y coordinate using the following nodes :



This works by splitting the Vector into separate X,Y,Z coordinates and applying a rotation using matrix multiplication as :

X = x.cos(angle) + z.sin(angle)
Z = -x.sin(angle) + z.cos(angle)


Varying the Twistiness input will vary the rotation. The Twistiness is measured in Radians rather than degrees so 2*pi radians is a full rotation (360 degrees) - just type '2*pi' into the value node and Blender will automatically calculate.

Note also the Subtract color mix node at the start. This is set to mid-grey (0.5,0.5,0.5) to convert the Generated coordinates ranging from 0.0 to 1.0 into the range -0.5 to 0.5 so that the origin - and centre of rotation - is in the centre of the mesh.

For clarity, here's the complete node setup :



Note that I've removed the 'green' element from the first Subtract MixRGB node. This is to leave the origin of the Y channel at the edge of the mesh so that one end is not affected by the twist (otherwise it twists from the middle). The Subtract and Divide nodes at the end (after the Noise texture) are there simply to increase the contrast of the Noise texture and isn't related to the twisting.

And here's the result :



Blend file attached