# How to make circular transform texture coordinate?

I am trying to make circular transform texture coordinates so that I can add a gradient to achieve the given result.

Input can be a gradient, noise, or just a white value but it should transform in the circular transform with parameters Inner Margin, Outer Margin, Repetitions, and Swirl.

E.g. this result where:

Input is a gradient with parameters Inner Margin = 0.25, Outer Margin = 0.75, Repetitions = 2 ,Swirl = 1

Repetitions = 2, Repetitions should increase the number of radial lines

=

Swirl = 1, Swirl should curve the radial lines

Repetitions is the number of lines and Swirl is the amount of curve to those lines

• Possibly related: blender.stackexchange.com/a/276363/60486 Commented Jan 5 at 16:13
• Could you define what you are expecting from the Repetitions and Swirl parameters ? I understand Repetitions as duplicates in radial direction, and Swirl as turns. So Swirl=1 means 1 turn to recover the pattern ; Swirl=2 means 2 turns to recover the pattern; Swirl=0 means 0 turn, so axisymmetric (only radial variations). Commented Jan 6 at 9:53
• Repetitions is the number of lines and Swirl is the amount of curve to those lines Commented Jan 6 at 11:58
• What kind of gradient is used in your examples? Commented Jan 6 at 12:01

(Using Blender 3.6.5)

### Objective

To render a picture such as Fig. 1, the apparent transformation of a texture map such as shown Fig. 2, is to duplicate it in the azimuthal direction by the factor Repetitions as shown Fig. 3 (where Repetitions is set to 2), to shear it in the azimuthal direction proportionally to radius by the factor Swirl as shown Fig. 4 (where Swirl is set to 0.25, i.e. a quarter of turn), and finally to wrap it between radius Inner Margin and Outer Margin (set respectively to 0.25 and 0.75 in these figures). Inner Margin and Outer Margin are non-dimensional parameters, i.e. defined for a circle of radius 1.

### Approach

Because in Blender a Texture node can not be connected at a NodeGroup input socket, the process has to be reversed.

1. The world coordinates are transformed to the texture coordinates, i.e. a square with $$(x,y) \in [0,1] \times [0,1]$$, as shown Fig. 2.
2. The chosen Texture node computes the Color from the Position Vector defined in the texture coordinates system.
3. Radius lower than Inner Margin or greater than Outer Margin are rendered in black using a mask.
4. The resulting Color is input to the Shader node.
5. To switch between textures, a Mix node can be inserted before the Shader node.

#### From Cartesian to polar coordinates, in world coordinates system

1. The world coordinates of the surface to shade are transformed in a square domain $$(X,Y) \in [0,1] \times [0,1]$$, based on the surface bounding box, using a Texture Coordinate node.
2. $$(X,Y)$$ are scaled and shifted to vary between -1 and 1, instead of 0 and 1. The polar coordinates system origin is thus $$(0,0)$$, and the largest circle radius is 1.
3. The radius $$R$$ is computed as $$R=\sqrt{X^2+Y^2}$$.
4. The angle $$\theta$$ is computed such that $$\tan{\theta}=-\frac{X}{Y}$$. $$\theta$$ origin is thus set at the +Y Axis, and $$\theta$$ is increasing counter-clock wise, with $$\theta \in [-\pi, \pi]$$.

#### From world to texture coordinates systems

1. The radius is directly mapped to the $$y$$ axis of the texture coordinates system, such that Outer Margin is associated to $$y=0$$, and Inner Margin to $$y=1$$. This choice is arbitrary.
2. The angle is mapped to the $$x$$ axis of the texture coordinates system with some transformations. First, the interval $$[-\pi,\pi]$$ is mapped to $$[0,1]$$.
3. Then, a shift $$\delta x$$ proportional to $$y$$ and to the Swirl parameter is subtracted (because of the reversed process) from $$x$$. Mapping Outer Margin to $$y=0$$ yields no angular displacement at the external boundary.
4. The Repetitions parameter is used to scale $$x$$.
5. Finally, $$x$$ is folded back between 0 and 1 using a Warp node.
6. A B&W color mask to blacken radius greater than Outer Margin is made using Map Range and Color Ramp nodes.
7. A B&W color mask to blacken radius lower than Inner Margin is made using Map Range and Color Ramp nodes.

### Resources

I'm not sure what the swirl and repetition is, so I made some assumptions.

Use the length from the center and map it to a new range. That is how you can control the inner and outer radius. The radial setup, which you posted in the question, can be substituted with the Gradient Texture node. By subtracting these values from one another, you can create the swirl.

If you want to modify coordinates by rotating them, use the Vector Rotate node.

• For information, I've tested it: I obtain something similar but with other input values for the radii (I don't think I'm mistaken in the setting?). But as it is, the result is black on a simple plane. Could be due to the UV map itself. Commented Jan 5 at 12:29
• I want the vector as an output so that I can use that in other textures e.g. noise, gradient Commented Jan 5 at 15:14
• @Karan: could you please share your Blender file with blend-exchange.com to help us to understand how you would like to "plug" the vector you are expecting ? Commented Jan 5 at 15:49
• @Karan Sorry for the misunderstanding. Please check my edit. Commented Jan 5 at 17:13

(Using Blender 3.6.5)
NB: this is an incomplete answer, to clarify what is expected.

### First edition

Such results are achieved with the following nodes graph:

### Second edition

Following is a proposal converting cylindrical $$(R,\theta)$$ world coordinates to (x,y) texture coordinates. These can be input to texture nodes, such as a Gradient Texture node.

Resources:

### Third edition

Following is a proposal for the data flow because a Texture node can not be an Input to NodeGroup. Texture nodes have to be "downstream" of NodeGroup.

• @Karan: I understand from your comment on Leander's proposal that this is not the graph you are expecting. Please share your Blender file, so I could tailor this proposal. Commented Jan 5 at 15:52
• Is it possible to have the gradient or noise as input, then the circular transform will transform it as described in the question? Commented Jan 5 at 16:23
• Input can be a gradient or a noise or just a white value but it should transform in the circular transform with parameters Inner Margin, Outer Margin, Repetitions and Swirl Commented Jan 5 at 16:26
• @Karan: I am trying a second proposal, where instead of a color ramp, a gradient texture node is used. Is this more in line with your expectations ? The Blender file is available to try by yourself. I will clean this answer and write detailed explanations after your feedback. Commented Jan 5 at 21:38
• Thanks, it is working. Can you do me a favor and make another edition, can you make it in a way that takes the gradient or any input and transforms it? e.g. it takes the gradient as the input and transforms it. Input can be anything e.g. checker pattern, brick pattern etc. Commented Jan 6 at 6:41

I realized it may not be very clear in the linked geonodes answer, so I decided to also add a shader screenshot here:

there's a simple relation here between the ping-pong value ($$p$$), the multiply value ($$m$$) and the number of arms ($$a$$), which can be expressed as $$a = |{m \over p}| ÷ 2$$ (multiply the ping-pong value by 2 and then by the number of arms you want)