URP Triplanar Node with more than one input texture?

Hi all, the Shader Graph’s included Triplanar node seems to work as I expect it, but there’s only room for one input texture?

It’s a pretty common use-case to have Triplanar map different textures onto the sides of an object than on the top - terrain would have grass on the top, rock-face on the side, for instance.

Is that just not a supported feature of the Triplanar node?

I once had the same problem and made it myself:

If you view the raw image you can read it.

Subshader File attached (just remove the .txt ending).
Hope it’s useful to you :slight_smile:

7455866–914960–Terrain.shadersubgraph.txt (166 KB)

3 Likes

:open_mouth: :smile:

@_geo1 That’s enormously helpful of you, thank you for sharing! I’ve given it a go and it seems to work great. I’ll need to keep testing and tweaking it, but wow, yeah, thanks!

1 Like

Glad you like it :slight_smile:
If you find any issues or have optimizations please let me know. I am using this for my game on mobile and it works fine. Though on very old phones it is a bit of a performance downer.

So, this solution does not use the triplanar node. If i am not mistaken, the triplanar node is faster and correct, based off an article by bGolus:

What you have, and what iwas using was the " incorrect" way, which is hardly noticable in terrain shaders, because terrain is mottled noise mostly, but the more correct way is faster and more accurate, which does make a big difference when compared side by side.

Wondering if anybody knows how to use triplanar nodes with three normal maps correctly.

I think i can use normal blend node based on the vertex normals, but i feel like that might actually override the intent of the triplanar node and double or triple the calculations.

For future readers:

The triplanar node is mostly to make your normals as correct as possible with one normal map, regardless of the mesh’s face normals.

I tried to use a triplanar set up , (no triplanar node, but the correct way, found here:. Shadergraph triplanar object space normal mapping help ) , but mixing a “grass layer” for y-plane, with the “rock” for mountain sides, but this created ugly horizontal lines, that looked kind of like some mountains do, but not the result i wanted. Changing blend power then just made the grass layer look like a scotch / criss cross pattern.

Then i figured out what the triplanar node is really for, (second phrase of this post), and used that only for rock, all three sides. My mountains looked awesome, but i had no “grass”. (In my case, a strategic map, i made a forest canopy texture). I then basically created a mask in the shader, where the steeper the vertex normal, the more rock, and less “grass” showed. Mixed it up, and my new terrain shader, using the triplanar node, was incredibly faster, 12 percent in fps overall.

I did not use triplanar node for the grass part, as well as rock, though i tested it, and it only; slowed my fps by about 3percent compared to the triplanar rock + masked grass. However, the artistic effect on the grass/canopy was negligible, so i opted to save the three percent fps.

Tl:dr the triplanar node is much faster than the old and not-so-correct way seen in most older tutorials. Furthermore, it looks way better. I now have the best of both worlds, smear free, detailed mountains and hills that react to light correctly, and in the flatter areas, a nice looking forest canopy.