Triplanar texture mapping with normal maps


I am having trouble using triplanar texture mapping with normal maps. I use this technique for triplanar mapping:
I am trying to texture map asteroids so I modified it to use local coordinates instead of world coordinates by adding transforms after Absolute World Position and VertexNormalWS nodes and it seems to work well for diffuse textures. Here is my material function:

I noticed that for normal maps, half of the sides are wrong. Example:

I tried to correct this by inverting UV mapping accordingly on the opposite sides and it works for a cube. For sphere (or asteroid) it does not yield correct results all the time. If I have to guess, the problem lies in the blending of the normal maps or something to do with transforming from world to local? How can I use triplanar texture mapping with normal maps?

I managed to get this working mostly. I found a ready material function called WorldAlignedTextures_Complex, which does the triplanar mapping with normal maps. I had to transform the world position and world space normal inputs from World to Local. I also had to transform the normal output from Local to Tangent to get normal maps working correctly. It is also important to keep the Tangent Space Normals checked in the final material.

Here is my material function which wraps WorldAlignedTextures_Complex for my use case.


There are some minor rendering glitches sometimes, like this:


Also if I scale an asteroid too much, it starts to show bad stretching. I think this could be countered by just increasing the polycount accordingly, haven’t tried though.


Does anyone know how can I fix these rendering glitches?

Hi tukez,

Uncheck “Tangent Space Normals” checkbox and remove all “Word to Local” and “Local to Tangent” nodes. Should work.