More sophisticated Dirt Density & Thickness Controls

Hey there,

after following along with the Dirt Generator Lecture and the one before I was wondering if we could improve the controls for the dirt thickness and density.

As explained in the lecture the black pin of our color ramp controls the dirt thickness and the white pin of the color ramp controls the dirt density. The important condition was that the black slider may not exceed the white slider in value. To ensure that Stephen gave the dirt thickness (black slider) a value range of 0 - 0.15 and the dirt density (white slider) a value range of 0.15 - 1.

So far so good, but I want to be able to have higher values for my black sliders and lower values for my white slider, which is possible depending on the other sliders value. For example if the black pin is at position 0 the white pin should be able to have a value range from 0 - 1, because it would never be lower in value than the black value. On the other hand if the value of the black pin is 1, the value of the white pin must be 1 too, because again it can not be lower than the black pin.

I took a look at the blender documentation and tried around a bit and you can actually reference multiple values in your driver. So I adapted it to the following:

When you edit a driver, you can add a variable by pressing the button in the driver. Then switch to scripted expression to be able to state a formula. If you use the max(a, b) function, the max function will always return the higher value of the arguments, meaning if we pass in the dirt thickness and dirt density it will make sure the white pin will either take the value of the dirt density which you set, or take the value of the dirt thickness in case your dirt density is lower in value than your dirt thickness.

Apparently the input variables of your node group is an array, meaning the first input will have the path “node_tree.nodes[“Group.001”].inputs[0].default_value”, in my case this would be my “Input” Vector pin. The second pin, the “Scale” would have the path “node_tree.nodes[“Group.001”].inputs[1].default_value”. This means the Dirt Density pin will have the path "node_tree.nodes[“Group.001”].inputs[3].default_value"
and the Dirt Thickness input pin will have the path “node_tree.nodes[“Group.001”].inputs[4].default_value”.

Now after setting it up like this you can use your sliders freely and achieve something mostly covered in dirt, like this:

Was having fun playing around with the values, hope you do too.

Cheers!

3 Likes

Your exploration and modification of input variables through Blender’s node system highlight a deep understanding of how node-based workflows can be optimized for better texture creation.
Keep exploring, experimenting, and pushing the boundaries of what’s possible with Blender’s texture and material capabilities!

1 Like

Privacy & Terms