Triplanar texture mapping with normal maps

Hello,

I am having trouble using triplanar texture mapping with normal maps. I use this technique for triplanar mapping: Unreal Engine triplanar material 01 - YouTube
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:

http://s22.postimg.org/mf5tjp3r5/triplanar_local.jpg

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

http://s23.postimg.org/kv9ocekaz/triplanar_local_normals.jpg

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.

2299ffb259b54a50b9ce8727343f4dafd85b6d50.jpeg

There are some minor rendering glitches sometimes, like this:

a7000e1703efc75b8863429b2ac2f593d79a33e3.jpeg

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.