Radial UV From Distance function

Hi, I want to reconstruct V channel for UV from Distance node in Shader.

Here is very simple setup and result:

Distance value can be used for U input, but I don’t really know how to somehow create V input.
Here is an example of radial UV:

https://realtimevfx.com/uploads/default/original/1X/8732436a225dac265564e2b73605af4f01ed888f.png

1 Like

Small update:

I decided to make V input from screen space UV + arctan2. It’s looking not so good actually. Also, there is some weir line artifact after using arctan2. Here is a quick video + nodes:

1 Like

Can you screen shot and red mark the line you’re talking about? There’s a line that seems to correspond to the ground plane.
When I used arctan in unreal there was always a terrible artifact at the very center.
Another artifact I had was related to a poor approximation if I remember correctly.
But polar mapping is totally win, keep going!

oh…here’s a thought. If you’re using a texture for the radial map then the line is probably occuring where the coordinates have to suddenly lerp back to 0 for the lookup. In a texture lookup that’s probably lerped by your gpu. Clamp?

Looks like a mip discontinuity. In Unreal you would fix that by manually passing the original UVs as derivitives so the texture sampler knows which mip to use there.

1 Like

The line is definitely a derivatives problem.

The other problem is a little more interesting. Ideally obviously you want the arctan to be centered around the point closest to the “ball”, but what does that really mean in the context of 3D space? How do you choose the correct planar projection for your atan2 that looks seamless for any geometry? The answer is you don’t because it’s not possible. This is a fool’s errand that always seems like there should be an answer just out of arms reach. Really it’s the same kind of problem as trying to unwrapping a sphere onto a flat plane.

My suggestion to you is abandon the arctan and attempting a radial V. Instead find some kind of inexpensive 3D simplex noise, or a 3D noise texture. Honestly just a 2D noise texture on the XZ plane might be good enough. Let the distance based U drive the main shape and use a fairly wide noise just to perturb the effect.

1 Like