Vary Color of Object Based on Object Dimensions (Size) I have a DNA model that I created and imported from a 3D chemistry modeling program (Avogadro). I exported the model in .wrl format (the only 3D format allowed for export by Avogadro) and imported into Blender. Unfortunately, there's a bug in Blender 2.8x that does not allow color to be imported in .wrl format.
So, I need a workaround. I need to color each molecule a different color based on its object dimensions. For example, the phosphorous molecule is a particular size as are carbon, oxygen, nitrogen, and hydrogen. I've spent a few hours now scanning the various forums for an answer. I have yet to find a solution.
Ideally, I'd also like to color the little stick bonds between each atom based on the colors of the two atoms it is binding together. That's not a deal-breaker, though. I can get away with making the stick bonds a single color.
See the attached images for the shader setup I have right now and the result it's producing.
You're so close - you just need to swap one of your Math nodes for a Vector Math node, and the other for a MixRGB. Note the divide factor for the mix node is set to 1 (anything less covers less than the whole surface).  See below:

NOTE - The scale I had initially was too big, apparently, I had to scale all the objects down (except for the empty) to get it to look right, but I was working fast and carelessly. I'm sure it can look &quot;right&quot; at any scale, it may just have to be adjusted by adding a Map Range node between the MixRGB and the ColorRamp - Just connect the color output of the MixRGB to the value input of the Map Range.