Triplanar Projection - Object to Tangent Space Seams

Context:
I’ve been working on an add-on in Blender that automatically connects nodes to mix full PBR materials together through a simplified interface with a layer stack, available free here: https://github.com/LoganFairbairn/matlay

I’ve created a custom triplanar projection method with a combination of personal experience and shader examples found online which seems to work well.

Triplanar projection output:

This custom triplanar projection is being used instead of box projection mainly because normal maps seem to be inverted when using Blenders default box projection from the image texture node, (see https://blender.stackexchange.com/questions/270490/how-to-fix-box-projected-normal-maps/270517#270517 for more details) but also has other advantages, like the ability to offset, rotate and scale projected axis individually.

For this add-on I need to be able to mix multiple PBR materials together in the shader nodes, to do this I convert the triplanar projection normals (which I believe are in object space) to tangent space using the solution found here https://blender.stackexchange.com/questions/190126/how-to-convert-object-space-normals-to-tangent-space, however this leads to visible seams for normals around UV breaks.

Question:
Is there any way to convert world space to tangent space without ending up with seams? Am I missing a step or a setting somewhere in the material nodes? Is there a completely different alternative to achieve triplanar projection with correct normals and rotations?

Triplanar projection converted to tangent space (note the visible seam in normals down the top of the models head):

You can download the blend file with the triplanar projection setups here: https://github.com/LoganFairbairn/matlay/blob/main/blend/Matlay.blend

The textures used in the screenshots are not packed into the blend, you can use your own or download the one I used here: https://ambientcg.com/view?id=Rock037

I’m actively working on a solution for this, and any help is really appreciated!

1 Like

Full node setup for those not wanting to download resources:

Triplanar projection main nodes:

Triplanar projection mapping:

Triplanar projection normals:

Normal map fix group node (rotates the normal RGB values in the opposite direction of the rotation value to maintain consistent normal map direction information) :

Triplanar normal fix group node:

Took me a long while, but…

The seam issue in this post was caused by a calculation error when converting from world to tangent space normals.

Incorrect Calculation (from original post)

Correct Calculation

3 Likes