How to process a color ramp as an INPUT of a node group?

Hello, basically what the title says. The question is illustrated here:

You have to mixrgb inside colorramp with the value from the group input.
But that wont give you the result you expect i guess. Coloramp input gives the value not the position on the scale.
You want a global coloramp i guess?

VSHADEā€™s next version will has custom Linear Color Ramp nodes. Coming very soon.

Short answer: You canā€™tā€¦ at least not with a node group.

The reason why not, is that the output of a color ramp is the evaluated color for the ā€˜Facā€™ value of that ColorRamp node, and not the color_ramp definition itself.

The solution is to use a Python CustomNodeGroup, where you can check if some input is connected to a ColorRamp node, and if it is, then you can reference the ā€˜color_rampā€™ of that node in your internal nodetree.

Edit: Another possibility of a CustomNodeGroup is that you can add the ColorRamp interface to your custom node, turning the usage of an external ColorRamp node unnecessaryā€¦

Yes the palette defined by/in the ColorRamp node is not ā€œparameterizableā€ (something like the green line) you have temporary output your data (pink line) and use an extern ColorRamp inputting the ā€œrampedā€ color (disconnet internal) and output the resultā€¦ of course in your example just put the ColorRamp after your Nodegroup because there is no further processing.

I want the Custom Node Group and the Color Ramp to be 2 separate entities. (for that reason Iā€™m not trying to expose the Color ramp to the node groupā€™s interface and I donā€™t want to use code for this).

What Iā€™m trying to achieve is a collection of ā€œbasic building bricksā€ similar to Substance Designerā€™s way to build materials. And I want things to be very simple: just plug into a group that processes the information and immediately outputs the result.

I thought there could be some trick with a few nodes that will somehow allow me to transmit the information I needā€¦

Thanks for the answers anyway.

Yes and the usual way to do so is having any custom node/group making any form/pattern/image and adding a (or mutliple) colorramp(s) afterward to get heightmaps and/or mask/coloring different areas for varying textures. So not ā€œinputingā€ the colorramp into the custom node/group but just adding afterward.

I was looking for an answer for the same question.
It seams that we actually can control Color Ramp outside a node group.
Check this video:

As RGB or HSV value are normalized beetween zero and one, like vectors. You normally could use a map range node switched to vector to interpolate between two colors. And if you need more than two colors use another map rangeā€¦ and so on.

@RyanKingArt made a video some time ago that shows his process of adding color stops in a node groupā€¦

1 Like

Thanks for recommending my video! Hope it helps.

1 Like

As I commented on @RyanKingArtā€™s video, you can actually simplify it a lot using the same technique he used for positions.

Just add a driver for the color elements too and connect it to the input color slots using the data path. Just be mindful that the data path for a color slot is an RGBA object, so when connecting to each individual channel you need to append a .r, .g, .b, .a, respectively. No need to painstakingly create a network of color ramps.

I.e.

  1. Create a ā€œColorā€ input socket for your group, give it a name (e.g. Vein Color), and choose some color for it:
  2. On the color ramp node you want to drive, right click on the color swatch for the desired element and choose ā€œAdd Driverā€:
  3. Configure the R, G, B, A channels based on the copied data path from the group input socket.

Notes:

  1. Use the Copy / Paste Driver variables buttons to repeat on the G, B, A channels after configuring the R channel to make it easier.
  2. Ensure to set the .r, .g, .b, .a as appropriate for each channel.
1 Like