The Construc's Material Functions Blog

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.


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…

Gradient Mapping functions

Gradient map

  • *Location: ConstrucContent/Functions/GradientMaping/
  • Name: multiple values
  • Dependencies: F_GradientRemap
  • Download them here*

To get a bit more advanced with the first function here, I’m going to stack a few of the gradient remap nodes together to create a fully-dynamic gradient map tool.
Simply input a heightmap and set your colours up in the material instance!

Bell Curve


  • *Location: ConstrucContent/Functions/GradientMaping/
  • Name: F_GradientBellCurve
  • Dependencies: Gradient Map
  • Download it here*

This one is a bit more subtle. It’s still essentially a gradient map function, but I’ve used these for more than just painting colours on to heightmaps. You can use this to reduce the contrast of an input without changing the values at 0 and 1 in the same way that a ‘curves’ modifier in photoshop works, or blend the start and end of values to smooth them out, say if you were doing what I did in the cover image for this post where I blend between two values that shift the vertices of a mesh using the world position offset. to stop them from stopping so harshly at the end of the lerp, i multiplied the output by this bell curve function to get the smooth motion you see there (there’s also some random noise and other things in that .gif, but that’s for another post).

Random Number Generator

Randomize Per Instance

  • *Location: ConstrucContent/Functions/Tools/
  • Name: F_RandomisePerInstance
  • Dependencies: Substance Plugin
  • Download it here*

While there is a ‘PerInstanceRandom’ node for certain mesh types within blueprints, for normal drag-and-drop meshes there isnt any way to generate a random number. This node solves that by using the object’s position in world-space as the UV coordinates to a noise texture.

The windows on the roof in the following image use this node to get some variation to them:

Sobel Edge Detection!

Sobel Edge Detection

  • *Location: ConstrucContent/Functions/PostProcessing/
  • Name: Master_SobelEdgeDetection
  • Dependencies: f_GradientRemap
  • Download it here*

Because there can never be enough of these.
I’ve messed around with a few of the ones people have posted over the years, and the one that still has the best result is the one posted over here by @Allar. But there are a few problems I had with it. Firstly, it doesn’t even work when you download it. the material functions in it are in the wrong place, so you have to go in and fix it. then there’s the sheer size of it, along with the ‘if’ statements (which i try to avoid when at all possible).
So I adjusted it, and came up with this.
Here’s the material for it:

See how much smaller that is than the sobel edge material that Allar posted? Much better :slight_smile:

EDIT: So uh… I go on this big rant about Allar’s material not working, only to have to go in and fix this *twice *because other people couldn’t get it to work… This is what happens when you don’t double-check your material for nested functions :stuck_out_tongue:

awesome post thanks for sharing.
i am having some issues getting the sobel edge working though. i attached a image below showing the issue. i tried installing all the things you posted just in case it was missing something from them but i just cant get it to work and i also tried to look a the image of it that you posted but the res is to small to be able to read the function that’s missing.

Ah, oops… yes, I know what that is. I’ll post an update in an hour or two with the fix. its another function i made that isnt included there

@olkiller730 It should be fixed now re-download it and over-write any conflicts :slight_smile:

@Construc_ i redownloaded and it still wont work. I see that you added the simplegreyscale and that is what was missing from the sobel effect so it does run now but your simple grey scale has a missing function now so it doesn’t run correctly.
Edit: i did get it to work though probably not correctly as intended by changing some of the math in simplygreyscale
image of problem now in F_SimpleGreyscale

@olkiller730* Oh my god…* I really do need to go in and double-check everything. Try one last time to download it. I should have fixed it now.

jeeze… i go on this big rant about materials not working only to have to go in and fix my own ones :stuck_out_tongue:

@Construc_ this should be the last one i swear hopefully… i think you forgot to update the link with the latest fix as it directs to a dead mega page.
Also i went though your other materials and also changed some stuff in the simplegreygreyscale to make the sobeleffect work even with whatever function its missing(so probably not working 100 as intended) i just wanted to say great work.

I would say the one thing you should think of doing if you are thinking ever releasing more materials like this is what would take it to a whole new level of awesome is make the main variables that affect what the function does into parameters and create a mat-instance so its more easy to edit(like allars i believe)

oh my god… i re-uped it to mega but forgot to put the new link in the post?? jesus christ…
try now.

but yeah, its certainly more limited than allars, i still cant get AA working with it properly.

Atlased Texturing

Atlased Texturing

  • *Location: ConstrucContent/Functions/Tools/
  • Name: F_UVAtlasing
  • Download it here*

So you have some basic meshes, but you’ve atlased the textures for all of them? Or maybe you just want to be able to zoom in on a texture. Or you have a decal atlas and you want to be able to use the decal actors with it.
This is what you’ll need:

Here’s the node network:

the positions it takes as inputs are fractional percentages of the zoomed area compared to the whole texture. Say you have a grid of 10x10 squares, and you want to only see the square at position 3 from the left along the x axis and 6 down on the y.

the inputs for that would be:

  • x1: 0.333 (position 3 of 10 is a third of the way there)
  • x2: 0.433 (position x1+width of the square)
  • y1: 0.666 (position 6 of 10 is 2/3=0.6[SUP]o[/SUP])
  • y2: 0.766 (position y1+width of square)

-to show a grid of two squares, add 0.1 (0.1=width of one unit/whole texture) to x2+y2, etc…

Blur Tools

Atlased Texturing

  • Name: multiple items
  • Download it here*

I’m going to be really quick with this one, but it’s super cool!
Blur, sharpen, and stipple effects are included here and I hope everyone finds them as exciting as I do.

Hey I would love to use your blur tool, but it has an unspecified funtion… Could you help me?