[TUTORIAL] Triplanar material

Project download link

I made a material that maps 3 different textures to an object based on it’s xyz world orientation. It really speeds up the texturing process for rocks and other terrain features.
I apologize in advance for the audio quality, the mic is from a 1990s Gateway computer.

Added material functions:

this is great info… thank you very much for putting it together!

You could instead just use the World Aligned Blend node, which is basically planar mapping.

It took me a little time to dig up documentation on the world aligned blend node (This is all that I found), it seems to work by modulating the alpha based on a surface slope. I’ll play with the node a bit and post what I come up with.

It’s a flexible material function with a few static switches that compile out based on what you’re doing with it - you can open it right up and see what it’s doing. You could quite happily use one for each planar blend through an axis though :slight_smile:

In the end, I wasn’t able to use the world aligned blend node. It has a pixelnormalWS node in it that prevents it from working with normal maps or displacement maps. I did figure out how to get the textures to project almost completely without stretching. Here’s the (slightly modified) default UE4 rock that has vertex paintable displaced snow on top.

Repost bc forum outage

I uploaded 2 more triplanar tuts to youtube

and here is the material functions I used. Next up, projection texturing in local space.

Looks fantastic. Will this work with terrains as well; say the height is grass and the sides of the elevations are rock?

The most current version of the projection material allows for local or world space mapping (no heightmap based displacement on the local one though), wood grain type noise, and a rudimentary system for determining the projection direction. Instead of just being based on the XY or YZ planes you specify a rotation amount which is stored in the red and green channels of a vector. I’ll make a vid about the usage of the material soon.

Very cool. I see this is actually a pretty old post? I’m glad you bumped it back into relevance.

I got distracted with another project and never quite finished this one. I got a few questions on the materials so I decided that it would be best to get off my butt and clean it up so that I could share it.

This is what’s in the project for those that are interested:

For the material experts out there, I’m changing the projection angle for the projection material by creating a new transform basis based on 2 scalar values (stored in a vector). The values work between 0.0001 and .49999 with larger and smaller values repeating. At 0 and .5 it suffers from what seems like gimbal lock. I can prevent this by clamping the values, but it feels kind of hackey to me. If anyone has a better method I’d love to hear it.

One cool thing about using a vector is that I can use a texture to determine projection direction. There’s a raised panel door in the project which has the stiles and rails projected at different directions.

Damaged wall prof of concept

Oh sweet, i had a bit of an issue getting pattern variation right and was curious about decals, thanks for posting will check it out soon!

Thanks for this, download now to check it out

Can you re-upload it please?

Hi Steve, yes please re-upload if possible. This material looks great.

I’m coming from the world of Solidworks looking to visualize in Unreal and UV’s have been holding me from being able to do this. My Cad assemblies have 100’s of parts, most of which would be fine with a standard cubic mapping (I think that’s what is referred to here as tri-planar?). So this could be the solution? I would still create UV’s for the large and important parts, but small things like bolts or whatever could really benefit from this.

A couple questions:

  • Would existing materials like a Substance material be able to plug into this, or would I be looking to create all materials from scratch?
  • Also am I correct that you could bring in an object with no UV’s applied, and this material would map it tri-planar?
  • Am I on the right track with this or am I missing some other workflow to easily throw a cubic mapping to a non-UV object?

Thanks very much.

Sorry about the late response, I’ve been afk for a bit. I had started to roll the shaders into one of my other projects to simplify code maintenance.

 - For substance, you should be able to create a parent material and use material instances just like any other material.

 - An object with no UVs should be fine. Worst case scenario, you have to auto generate UVs. They don't have to be pretty since you're using texture projection.