World alignment (Tri-planar mapping)

From reading the UE4 documentation, I found out that material functions are a bunch of nodes packed into one node. I figured out the Math behind how world alignment works by deconstructing and experimenting with the World Aligned Texture node. This node is one example of a material function. It is also widely known as Tri-planar mapping in substance painter.
Material Function for Tri-planar mapping 

This gave me the idea to make a block out material which can have grids, scale without texture stretching and change colours the way I want it to. I also wanted to add the functionality of animating the material. I did this by making some modifications to the World Aligned Texture material function.
Modified Material function with comments to help understand which part is doing what.


I found that substracting the WorldPosition from the Object Position will force the material to move along with the object and not have a weird scrolling effect whenever you move the object. The downside of it is that it can add more instructions to the material.
WorldPosition subtracted from the object position - Material moves along with the mesh 
WorldPosition not subtracted from the object position - Parallax scrolling effect when moving the mesh (The material appears to remain static, while the mesh moves.)
I also found that adding a Floor node to the mask values of the world aligned texture material function, makes the material transition smoothly when the object is rotated 45 degrees in any direction.

Mask from world aligned texture material function with added floor node multipled by 2 first.

Meshes rotated 45 degrees. The one on the left is rounded up and looks smooth, whereas the one on the right looks very conflicted and tries to blend between X and Y direction.


I masked the faces in the Z direction to a different colour for variation. This is controlled by a switch based on user preference.
Material is masked in Z to add second colour (white.)


2 layers of Grid textures. One is the base layer, which is the big rounded square.
The other layer is the hexagon pattern on top of the rounded square.
 Noise is added for further lighting information
As for the material itself, I made 2 layers to create 2 variations of grid masks. One being larger than the other. I added Noise information to  the Metallic, Specular and Roughness properties to allow extra lighting information rather than having a plain blockout material. The effect is very subtle though.











Final Material Setup with the modified World Aligned Texture material functions nodes in multiple areas



Here is the final video showcasing the customisability of the material:


Comments

Post a Comment

Popular posts from this blog

Environment Showcase Concepts

Distance Field water foam