Control a Color Ramp node from outside a Node Group!

I often create shaders that use the Pointiness attribute, followed by a Color Ramp to create a sort of edge map. I love it so much! The problem I kept running into was when I wanted to package my shader into a neat node group. I had no control over that edge map without having to dive into the node, find the Color Ramp and adjust the handles. So I looked online for a solution but found nothing that I liked. So I fiddled around until I came up with this solution. Let’s get into making the setup!

Step 01

The first thing you want to do is add your base node, in this instance I just used a Diffuse BSDF with an orangy brown color.

Step 02

Next you want to add your underlying shader, the one that will become exposed by the Pointiness map. I just added another Diffuse BSDF with a blue green color. Then add a Mix Shader and connect them up.

Step 03

Next add in the Geometry node that has that awesome Pointiness attribute built in.

Step 04

Next add in that Color Ramp node and connect the Pointiness into the Factor of the Color Ramp and then connect the Color Ramp up to the Factor of the Mix Shader.

Step 05

Now just play with the handles till you get the desired result. Now we seeing the magic of that Pointiness attribute come into action!

Step 06

Now group it all up into a neat little node. Select all the nodes except the Material Output node and hit Ctrl + G (or cmd + G).

Step 07

Dive into the node by hitting Tab and connect all the input you want exposed into the Group Input node. You can hit N in the node editor and name your inputs as you see fit. Now dive back out when you have done that by hitting Tab again to see your node in all it’s glory! Nice work, we are getting to the fun bit now!!

Step 08

Now we need to create an “Age” parameter that we can control on the outside of the node group. Start by diving inside the node group (using Tab if you don’t remember).

Step 09

Now add a Math node and insert it between the Geometry Node and the Color Ramp Node. Set the mode to Power and set the bottom value to 1.

Step 10

Connect the bottom value of the Math node into a new slot of the Group Input node. Now open the properties panel by pressing N. Scroll down to the list of inputs to the bottom and find the Val input. This is the input we are interested in! Rename it to something like “Age” and set the Min to 0.5 and the Max to 2 for now.

Step 11

Now if we dive out with Tab key again, you will see your node group with a new parameter called Age. If you scrub it you will see your edge mask get bigger/smaller based on the value. Now for some extras to really fine tune your node!!

Step 12 (BONUS)

Dive back into the node group and disconnect the Math node from the Group Input and delete the Age input in the properties panel (find it by hitting the N key in the node editor). Now we are back to where we were before we connected the Math node up. Now add a Mix Shader. These next steps are cool so pay attention.

Step 13 (BONUS — FINAL STEP)

Connect the Mix Shader Factor into the Group Input node. Then delete the Mix Shader. This gives you a Slider Control instead of a Value Control. Neat hey. Now connect that input you just made on the Group Input node to the bottom input of the Math node. Open the properties panel again and set the name to of the Input to “Age” and set your Min and Max values. These values may take some trial and error but I found 0.5 as a Min and 1.5 as a Max worked well!

Now jump out of the group node by hitting Tab. Bring up the properties panel by hitting N in the node editor and name the node anything you want! We are now done!! You now have a node group that from the OUTSIDE you can control the effects of the Color Ramp!

This technique can be used for procedural textures in Blender as well! Instead of using a Math node with Power, try Add and that can allow you to expand or contract a noise texture for example.

I do hope this was helpful and it opens up a new way of thinking. Here you can check out my ArtStation or Instagram. Thanks for reading!!

-K1FF

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.