2

I am trying to create a transparent gradient texture for the top of a cylinder / disc / ring.

So far I have used this node configuration that is basically using the mathematical formula sqrt(x^2+y^2) to get the radius as it is explained here RADIAL Colorramp gradient texture

enter image description here

It is working good when the object is a cylinder that has been reduced the Z scale to a minimum so it looks like a disc/ring as it can be seen here:

enter image description here

However, the same material is not working right if the object is a disc created from a extruded circle (from the vertex). Nevertheless, if I change the power to another negative value, the material starts to work although not exactly how I want as it can be seen here:

enter image description here

I guess this has to do with the UV coordinates each object has internally generated but I cannot figure this. Why is this happening?

Also I am open to use another more simple approach than this nodes configuration.

Daniel Ortega
  • 267
  • 1
  • 7

1 Answers1

2

You're using Object coordinates, which, (assuming your object is not scaled in Object Mode,) are measured in Blender units, from the object's origin, along the object's own axes.

If your disc has a radius of 1, then you can simplify your tree as follows:

enter image description here

Since the answer you refer to, there's a Vector Math > Length node, so you don't have to do your own Pythagoras any more, and you could use alpha in your color-ramp colors to get rid of the shader-mix? It depends on the exact shading you want.

If the radius of your circle is not 1, then you could introduce a Vector Math > Multiply before the Length, to bring the radius lengths into the 0-1 range for the color-ramp to handle.. multiplying X and Y by whatever is needed, and Z by 0 to get rid of it.

However, you want the texture to be more general, and occupy the same proportions of a disc, no matter what size it is, you could use Generated coordinates, which are always measured 0-1 from the minimum to the maximum of an object's bounding-box in all directions, no matter what size the object is.

In that case, you would have to shift 0 back to the middle of the circle, and multiply by 2 to get the radius mapped back to 0-1 again:...

enter image description here

Robin Betts
  • 76,260
  • 8
  • 77
  • 190
  • Thanks for your answer. I was not aware about the difference between object and generated coordinates so this clarification comes great.

    I decided to try your second solution to give more independence to the texture from the size of the object since its possibly going to be reescalated and it works exaclty as I wanted it to work.

    However, I dont totally understand the two vector mathematical operations. If i get it right, it goes from values (0,1) to (-1,1) right? Or why do you need to use the substract and multiply in this case?

    Thanks

    – Daniel Ortega Oct 19 '20 at 14:04
  • 1
    @DanielOrtega Yes, in the 2nd tree, the coordinates are wrangled from 0->1 with the origin at the 'bottom left' to -1->1 with the origin at the center. This means the length is 0 at the center, and 1 at the perimeter. We chuck out Z before taking the length, just in case the object has a height. Not interested in that, texture is in XY, projected down Z. BTW, not strictly true Generated are always 0->1 from minimums.. that's a default. You can manipulate the Generated texture space in the object Properties > Data tab. – Robin Betts Oct 19 '20 at 14:54