Change color by radius

So I am currently working on a CAD rendering and decided to give Blender a try instead of Keyshot. One part is a black ring with engraved writing (silver/white) on it (in the mesh since it is a stl import). I thought just like color by z hight it should be possible to assign color by radius -> lower parts of the ring white and higher parts black. So my approach was calculating the radius and input into a color ramp set to constant.

Also tried to add a Mapping Node to scale the vector etc. but no luck with that. I am quite new to blender so I guess my understanding of the texture coordinate object vector might be wrong. Switching the xyz outputs didn't help either.

Maybe someone could help me out here.

• Your node setup seems correct assuming your object coordinates are correctly aligned and orthogonal in relation to the ring plane – Duarte Farrajota Ramos Mar 31 at 15:05
• Make sure the transforms of your ring are at scale 1,1,1. You can do it by hitting CTRL + A, and choosing 'Scale' – Gorgious Mar 31 at 17:03

Your node setup looks correct, although it could be made slightly less verbose by making use of the Vector Math: distance node.

I've managed to make it work on a torus. Perhaps you should try:

1. Making sure the origin is in the centre of the ring.
2. Tweaking the ColourRamp slider's Pos values so that the results of the previous node operations fall in their vicinity. As of right now, yours are set to 0 and 0.077, it seems; for me the spot was around 0.9 .

The material for the planet rings below (ignore the planet itself) changes the color based on distance from object center using object texture coordinate, Gradient/Spherical node and a map range to control the distance range to use. Change to Constant interpolation in the color ramp in order to have hard stops between colors.

Change scale of your Ring in Edit mode in order to see the color changing based on scale (or Apply Scale to the object)

Another option is to use a driver for that same color ramp using the scale of the object:

As @Duarte has commented, your set-up should work.. things to bear in mind:

• Blender's Object space is measured in Blender Units, from the object's origin, and in the orientation of its local axes.
• The Color Ramp node maps a 0-1 'Fac' range, your radii might be outside that altogether.
• You would need three stops on the Color Ramp; the area you want to pick out is between 2 others in radius, and it looks as if it would be very fiddly to hit the right spots

To get this example, I created a temporary single vertex at the center of the ring, and used the Measure tool to find the distance from it to the shallow relief. The nodes then compare the XY radius of the shading point to that length, with enough tolerance to catch all of the inset faces, also bearing in mind, under the hood, the faces are flat: the radius is not constant.

• I tried your setup and could not find the Compare Note... using 2.8.2 and it should be in math but no compare there. – B G Apr 1 at 19:00
• @BG it's one of the functions in the Math node – Robin Betts Apr 1 at 19:42