Triplanar Shader doesn't work with Terrain Tool.

Hey Community,

I’ve created a custom Toon Triplanar Shader in Shadergraph. It works as expected using the build in terrain tool choosing it as terrain material.

The build in terrain has very limited features. So I tried the extending it with the Unity "Terrain Tools" which is no longer in preview for 2021.2 URP which im using.

Unfortunatly my shader no longer works:

Any ideas?

Officially, ShaderGraph shaders are not yet supported for Terrain in the 2021.2.
That said, you can work around that fact to a degree.

Here’s what works and what doesn’t:

  • The Draw Instanced flag does not work with ShaderGraph shaders on Terrrain objects. This can be less performant, particularly if you have multiple terrain quads in the scene.
  • Terrain objects and ShaderGraphdon’t agree about the orientation of the tangents, which means tangent space normal maps will look wrong.

Unfortunately the Draw Instanced is a limitation that can’t easily be worked around without an engine change – if you absolutely need that in 2021.2 you’ll need to use a text shader.

However the tangent frame issue can be worked around pretty easily. In the graph below, the vertex tangent is set explicitly in the vert stage, and then a flip of the Y-channel on the normal map gives the proper per-pixel normals. This is a bit of extra work – but if your application requires Shadergraph features it’s a doable workaround. You’ll still see a warning mark in the inspector when you assign this shader, but the warning is harmless.*

If you’re compositing layers in your shader you probably know that adding a texture property called _Control0 will give you the alphamap texture (_Control1 adds more channels if you paint more than 4 layers, and ). When your shadergraph combines these together remember to flip the Y channel if you use this interim solution.

If you’re implementing triplanar mapping with bumps, I’d highly recommend reading up on the Surface Gradient Framework which does a great job of normal map compositing, in particular for the tricky case of normal map compositing. There’s a ShaderGraph subgraph version of the framework in this github project.

You’re probably thinking “when will this get fixed?” Unfortunately we aren’t publicly committed to a release date – but I can say the team is very aware of the need for proper ShaderGraph support and wants it to happen as badly as the community does!


  • I have to admit I have not tested this on any OGL devices!
2 Likes

Would you expand your explanation on this?

The default shader starts with a single pass that uses a normalized rgba texture to establish the blend weights between the first four paint layers. If you add a fifth layer, the system creates a second rgba texture and now it normalizes across both textures:

Say your original texel was (.5, .5, 0 ,0) and you add a 5th layer and paint a little bit of that onto that texel of the terrain, you’ll now get two textures (_Control0 and _Control1) which still sum to 1, say (.25, .25, 0, 0) in the first texture and (0.5, 0,0,0) in the second – meaning the final appearance is 1/4 layer1, 1/4 layer 2, and 1/2 layer 5.