0
$\begingroup$

You'll understand once you see the image. I wanted to make a procedural shader that made smooth lines converge in the middle, but the catch is that I want the lines to smoothly fade instead of having hard edges. I managed to make a mockup with a color ramp but it's not procedural.

The result that I'm going for The node setup to achieve the mockup

Using a Radial Gradient with a Vector Math node set to Modulo leaves me with these harsh edges on one of the sides, I just want to get rid of them

What I'm NOT going for The nodetree for the wrong shader

$\endgroup$

2 Answers 2

3
$\begingroup$

Doing this with a color ramp with that many stops looks like a nightmare. Let's instead divide the plane into 24 radial bits along its center:

enter image description here

Atan2 is a special function that gives us the angle of the sample relative to the origin, in radians (minus pi to plus pi), which we can then remap into 24 parts. Why 24? So that we can mirror half of them:

enter image description here

So we take the second half of each 30 degree arc, and invert it.

(Edit: There's an error here that I can't easily fix, which is that I really should be multiplying my values by 2 now, because mirroring it over the center means that I'm only exploring the color range from 0 to 0.5.)

So right now we've got linear color forming a sawtooth wave. It's already continuous, in a sense, but to make it really smooth, we want to turn that sawtooth wave into something smooth:

enter image description here

We could do that with some direct math, but it sounds like you're interested in tuning this to eye, and nothing beats an RGB curve for that. Remember, that curve you're drawing is repeated, back and forth, over 24 sections of the circle, so for us to be smooth, we want the slope to stay the same at the transitions-- that's why this looks smoother than the sawtooth above, because the slope of the curve at the left and right edge is close to horizontal. (Edit: well, it would be better if I multiplied values by 2 first, to explore the full 0,1 range of brightness, as mentioned in the above edit. Otherwise, the slope at output 1 doesn't have much to do with the slope at output 0.5....)

$\endgroup$
1
  • $\begingroup$ Amazing answer Nathan, not only answering my problem but also teaching me something on the way. Thank you very much :) $\endgroup$ Commented Dec 10, 2021 at 23:24
3
$\begingroup$

This can be done with built-in nodes, if you're lazy:

enter image description here

  • To get a 0 value always at North, rather than West, rotate the Object Space by 90 degrees.
  • To get N spokes, set the scale of the Wave Texture to N * pi /10

For a custom softness, you could use a Sawtooth wave instead of a Sine, and put the output through a Color Ramp

$\endgroup$
1
  • $\begingroup$ ... but as you commented, @Nathan's answer tells you more about what's going on under the hood of 'convenience' nodes, letting you choose when to use them more accurately. $\endgroup$
    – Robin Betts
    Commented Dec 11, 2021 at 0:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .