I have a ColorRamp node inside of a node group and I would like to have a group input which controls the "Pos" value of the white colour, but there doesn't seem to be a good way to do it. Since I'm only using two colours, is there a different way to do it?
2 Answers
You can use drivers on the Pos value.
All you need is a driving value.
Let's make the drivers from the group input. First enter the group node, select the Group Input node. In the sidebar (open with N). In the Node tab, you can add Inputs, name them and set their default/minimum/maximum values. I added two new inputs:
Get out of the node, right click one of the value inputs and hit Copy Data Path (here the White Posisiton):
Think of the Data Path is like the url of a website or the file path of a file on your computer, but here it's for any data on Blender.
Enter the group node, right click the Pos value corresponding to the data path you previously copied (here the white Pos) and hit Add Driver:
A pop-up will show to let you set your driver. Set it as I do:
- Type: Sum Values
- Icon next to "var": Single Property
- Prop : Material → select your material
- Path : paste the Data Path copied earlier
- Hit the Update Dependencies button
Note that once your driver is done, you can edit it via right click → edit.
And you can also copy-paste it from one value to another.
So if you want to create one for the black handle: - right click the white Pos value → copy driver - select the black handle, right click the black Pos → paste driver - exit the node group and copy the Data path from Black Position - enter the node group, right click the black Pos → edit driver - paste the new data path - hit Update Dependencies
And here's the result:
-
2
-
2$\begingroup$ works perfectly, thank you so much $\endgroup$ Commented Mar 18, 2020 at 19:01
-
3$\begingroup$ Note that you can right click in the node group field > "Copy as new driver" then right click in the color ramp field > "Paste driver" to save a few steps $\endgroup$– GorgiousCommented Mar 18, 2020 at 20:55
-
I figured it out, I used two add nodes to do it, like this.
the first one sets subtracts 0.5 so it changes everything to be under 0, and the second one adds a number from 0-1, which is connected to the Group Input node