Storing UV data on face corners / gradient interpolation problem

Hello guys. I try to create a cylindrical mapping for an object created in Geometry Nodes. The Idea is to use Radial Gradient Map, store the value on face corners and then use this to place the texture:

The issue I have is with the place where gradient starts / ends because the value gets interpolated between 0 and 1.

I tried to solve this issue by first selecting half of the points and storing the attribute, then the second half, evaluating the value on face corners, range mapping, but it doesn’t work.

Any idea how I can get rid of this interpolation?

I tried to search the forum and found some similar issues resolved but I fail to translate the answers to my problem :confused:

Hera are some screenshots:

Maybe try the following:

instead of encoding the 2-D texture coordinates in geometry nodes, instead just save the geometry position and then compute the cylindrical coordinates in the shader:

seems to yield better results

The reason why this works? At the “rear” boundary, the radial texture, or angle, jumps from 0 to one (or -pi to pi) so any interpolation will yield wonky results (compressing the range 1 to 0 backwards into a small strip of geometry). However, interpolating between some stored x and y values and then computing an angle from that always works, regardless of what the resulting angle is.

(by the way, this is one way of smoothing angular-valued signals that have jumps from -pi to pi (i.e no real jumps): convert to x and y coordinates via sine and cosine, smoothing x and y, and then converting back to angles via atan2)

1 Like

Thank you for the solution!
That is really great!

One thing I wanted to avoid is the additional computation in the shader editor.
Just to do a cylindrical projection using geo nodes, and in the shader editor use attribute as UV coordinates. But maybe it’s not possible.

One more thing I tried and “kinda” worked is splitting the geometry into two pieces, then storing gradient ramp attribute on each half’s corner points, and then joining it back together.

Is there any other way of storing data at the corner points?

Thank you once again kind sir :slight_smile:

1 Like

Yeah, you could do some hacking:

  1. make sure that there is a vertical edge right where the angle jumps from 1 to 0 (where the problem with the interpolation occurs using your original method:

  1. slightly distort the position of the face corners towards their face centers, i.e. away from the problematic angle jump:

(make the value in the scale block such that there is no perceptible distortion, it just needs to be larger than zero)

  1. Then, with the distorted face corner positions, do the radial mapping (you probably can also use the radial gradient):

  1. In the shader use standard texture coordinates:

  1. seems to work:

radial_map_hack_3.3.4_v01.blend (874.9 KB)

2 Likes

Yes! This works brilliantly. Thank you very much.
Based on your suggestion I was also able to store the gradient on face corners after splitting the edges and scaling them a tiny bit.

1 Like