Material Function Example: Post Process Half Screen Preview

I was recently trying out Allar’s Sobel Edge Post Process material, which you can find here:

It worked great, but I wanted to easily see the difference between it being applied and not being applied, and it ended up being a good example case for a Material Function. The behavior of this material function is to have two inputs, and display one along the left side of the screen, and one on the right side of the screen. The handy thing about this is that you can walk around the scene and very easily tell the difference in no effect vs your effect.

Result is the following, which has the sobel edge material applied on the right side, and nothing special on the left:

Here’s what the last bit of the sobel edge post process material looks like:

Here’s what it looks like inserting the material function:

You can see it just involves hooking up the old output to one input, and then the regular SceneTexture:SceneColor to the other half.

You can read about creating material functions on the reference page ( Unreal Engine Material Functions Overview | Unreal Engine 5.1 Documentation ). In the Content Browser, right click -> New Asset -> Materials & Textures -> Material Function, and then it behaves just like a regular material except you can add FunctionInput nodes and some other niceties.

The following is the material function for getting the left half/right half screen preview:

Pretty simple! It’s probably not the best way to do it, but it worked for my purposes. We get the screen X value (0.0 to 1.0), then round it. I couldn’t find a “round” node, so an easy way to round a floating point value is to add 0.5 and then floor it. After that node we’ll just have “0” on the left half of the screen and “1” on the right half. Then we multiply the input Vector4 values by that value or the opposite of that value, and add them together, so we get full weighting on the left half for LeftHalf input, and zero weighting on the right side of the screen, and likewise for the RightHalf input.

You can get MF_PostProcess_HalfScreen_Preview.uasset here:

Whoa that is awesome, looks like borderlands, but nicer.

Thanks for this! Really useful material function