How do I swirl a procedural texture to get a result similar to this?
The Hacky Way
One way to do this is by stretching the mesh, so to speak, rather than the texture. When a mesh is bent by the deform modifier, cycles will give us the coordinates of the unbent mesh, but deformed to match the mesh's deformation. To see how this is useful, consider the following gif:
Unfortunately, for some reason this only works for the surface coordinates; we get undeformed coordinates if we try and use them for a volume shader. However, it's possible to fake volumetrics using an array modifier.
The complete process:
- Create a plane (⇧ ShiftA> Mesh > Plane) and give it a few loopcuts (⎈ CtrlR)
- Add a subsurf modifier, set it to Simple and increase the number of subdivisions a bit.
- Add a simple deform modifier, set it to Bend, bend it 360°
- Add an array modifier, use the Z constant offset to make a "stack" of planes.
- Finally, slap on a shader such as this: The Scale nodegroup performs identically to the scale component of the mapping node while in Point mode. I use it instead in case I wish to connect something to any of the scaling factors, and just because it takes up less screen real-estate if I don't need any of the other transforms
The Real Way
The above method renders fast, but doesn't work so well if you get too close or want to go inside it.
Instead of using some modifier trickery to get blender to generate the coordinates we want, we can generate them ourselves by transforming the default generated coordinates to polar coordinates.
This has the distinct advantage of letting us use real volumetrics:
Nothing special with the object this time, just a solid, flat, doughnut-shaped mesh with no modifiers. Everything is done in the shader:
The first group ("Centered Coordinates") takes the default generated coordinates (which are the normalized object dimensions, i.e. the entire object is within the 0..1 range, with each extreme of the object along a given axis being either at 0 or 1), and subtracts .5 from the X and Y so that
0,0 is in the middle of the object.
The next group ("Polar Coordinates") is where the important stuff is. It transforms the X and Y coordinates of the input to polar coordinates. It leaves the Z untouched. What this transformation does can most clearly be seen by comparing the way the X and Y coordinates vary before and after:
Before the transform, the X and Y vary along the axes. After the transform, the X varies with distance from the center, and the Y varies with angle to the center.
From here on, the shader looks pretty much like that of the first method. The only major difference being the use of a musgrave texture instead of a normal noise texture, which is, of course, completely up to interpretation.
Is this similar enough?
texture coordinate node--where the coordinates for the texture are coming from.
mapping node--so you can transform the texture
musgrave texture node--procedurally generated blobs
greater than node--increases the empty distances between the blobs
multiply node--makes the blobs brighter
emission node--color of blobs
material output node--assigns texture to the volume of the object.