Procedural "Vector Sun Rays" Texture

Hi there,

I was looking to create a vector like sun rays procedurally with no success :no:
I am attaching an image of the “Rays”

Any ideas?

Gradient texture to rescue:

Brilliant! Thanks a lot for that!
Math node, Struggling with it

… and you don’t really need the color ramp… a simple rgbmixer works a little bit faster than that. :wink:

about the math nodes… it’s quite simple:
the gradient outputs a radial gradient from 0 to 1. Then we multiply it by 20 (or what ever) so the output goes from 0 to 20. After that, the ‘modulo’ function just splits the 0 to 20 into 0 to 1, twenty times. The ‘greather than’ breakes each 0 to 1 slice into a 0 to 0.5 =0, and 0.5 to 1 =1.

Pure Gold ! Thanks


A while back some folks on the Lightwave forums were making flags using only nodes. Some guy made the Texas state flag star and all! Too much math for a right-brainer like me.

The Texas state flag is quite easy to do with nodes… quite similar to the node setup I posted above but we need to add another gradient (sphere) to make the star corners go smaller with the distance to the center. The rest is just a matter of using ‘>’ or ‘<’ with the x and y components of the texture coordinates.

It will be really cool if you and others can post useful tutorials/docs on the MATH NODE.
I’m having a real struggle with it and I reckon a lot of noobies do.

anyone? please? :cool:

The math node is pretty simple, at least if you know the math nomenclature used (which is standard in math language)

What I think most users struggle with, is how the whole node shading system works…
Each sample (for each ray that hits the surface of the object with that material) calls the shader tree. And each sample has specific global variables like position coordinate, normal vector, UV coordinate, etc. And for each sample, the outputs for most of the nodes will vary also.

Think it like an equation where you define the function to deal with those global variables in order to produce some value, some color or some vector.

The math node is just an operator between two variables (or constants if the node has no input links).
Something like output=A+B, for any value of A and any value of B that are the current ones for the sample being called.
For the operations the node does, they are quite simple. ‘Add’ just adds, ‘Multiply’ just multiplies, ‘Sin’ and other trignometric operations return the sine of the first input… and so on.

I see what you saying. interesting, and also, you are right about dealing with the shader tree,
as I seen few times (using the node wrangler) some math nodes seem completely white/black and after few calculations, a magical texture appears from nowhere I understand that it can deal with very small units and all it’s quite frustrating trying to figure it out…, I guess I do need to refresh my math skills as well…

just a very simple example:
The gradient node, when set to linear, uses the following formula:
output = max( min(vector.x, 0) , 1 ) EDITED: This is wrong! it should be min(max(v.x, 0), 1)
this means that it uses the x component of the input vector (or the generated vector in case there’s no input link), clamps that value between 0 and 1, and outputs the result.
There’s nothing more to it…
When set to spherical, than the output = max(1.0 - sqrt(vector.x^2 + vector.y^2 + vector.z^2), 0.0), where that square root is the trignometric function for the distance to the center (which is the same for a spherical surface).
If the distance is 1 or bigger, than 1-distance is 0 or negative. Since we use the max (maximum) between that and 0, the output is 0. If the distance is less than 1, than 1-distance will become closer to 1 as the distance gets closer to 0.
You can even try this with math nodes, instead of using the gradient, and the result will be the same.

AMAZING, :spin: