So I’ve been mulling over this concept for a while now, and I’ve decided I might as well go ahead and start doing it.
I have a few material functions that I’d like to share with you all and I think some of them at least are really useful.
Maybe I’ll share some other small tutorials and things as i find them or discover them and post them below.
We’ll keep this first post as a sort of index and I’ll edit it and post links to the posts where I share them, but I’ll keep this first function here because chances are the ones I make after this will have one of these in them.
For a best-use scenario, make a folder in your root Content folder called ‘ConstrucContent’, and we’ll keep all of these in the right place. a lot of the functions I post after this will most likely rely on other assets being in the right place, so it’s important to keep the same folder structure as I do.
Functions:
- Gradient Remap (below this)
- Gradient Map
- Bell Curve
- Random Number Generator
- Sobel Edge Detection
- Atlased Texturing
The first post will be about a ‘Clamp’ node. because I have some serious gripes about the default UE4 clamp node, let me tell you…
Gradient Remap
- *Location: ConstrucContent/Functions/Tools/
- Name: F_GradientRemap
- Download it here, follow this, or copy-paste thisin to a new material function.*
For this first function, I’ll be showing you my ‘Gradient Remap’ node, which acts as a proper ‘clamp’ node. Why don’t I call it a clamp node? because one of those already exists and it is a liar.
The ‘clamp’ node that exists already in the material editor really is just a ‘min+max’ node, clipping values so they dont extent beyond the set values, which to me is a bit silly. A clamp squishes things, a clip chops them off. There already exists a ‘min’ and ‘max’ node, why does there also then need to be the clamp node if its not even clamping things?! It should be renamed to the ‘clip’ node. Anywho, rant over.
Here it is:
It takes in 3 inputs, none of which are ‘needed’. It has default parameter-ised values, so you can just chuck one straight in to a material and get all the default parameters exposed to you in the instance without having to make any parameter values yourself. I like that a lot.
The inputs it takes are thus:
the gradient. the value you want to change. it can be any value you want between 0-1, even a texture.
*min and max. * these are the values you set to clamp the gradient to. also between 0-1
Here I have a gradient, and I adjust its output by the default clamp node and by my gradient remap node to a value of 0.2 min and 0.8 max:
you can see that the default clamp node actually just clips the values so that any value above the set numbers are just stopped at that value. My gradient remap node actually does what the clamp node is supposed to do and re-maps the input gradient so that the 0-1 range is mapped between the input values.
It has so many uses:
- its super useful as a cheaper alternative to the ‘if’ node
- you can stack a whole bunch of them together to make a multi-coloured gradient
- you can use them as clipping masks within materials for things like paint weathering
- use it to reduce contrast on things
- gamma correction
- etc…