Getting Tangents for Normal mapped Triplanar shaders in Unity using strumpy editor

I’m using a normal mapped triplanar shader to texture the walls of a cave/terrain system. Works well but I’m a bit stuck with regards to the tangents. Usually tangents are calculated using UV and normals per poly but I don’t have UV’s for my polys (The triplanar shader does that). If I don’t pass any tangents into the shader I get an error and it doesn’t light properly. If I kind of fake the tangents by calculating them with UV of (1,1,) (-1,1)(1,-1) the terrain looks OK but I’m sure it would look better if I actually knew what I was doing. Can anyone offer me advice on this? I’ve no idea where the tangents get added into the shader calculation, they don’t appear to be used explicitly anywhere but they definitely are making a difference. I sample the normal map texture the same way as I sample the texture but then pass it through the unpack Normal box. Is that correct

As I said the shader seems to be working OK with tangents created using fake UV. Here is a screen shot to prove it.

I’m using it in a procedurally generated cave system. If you are interested you can play a demo here:

http://charliedoggames.com/WebPlayer.html

I’d be interested to know how the demo runs on different peoples machines. Controls are usual FPS with right click for jetpack thrust (only works if you have fuel) game needs a HUD… Controls work best in full screen.

Hey tony,

Firstly, It looks great. How are you making the tunnels? I do a lot of procedural stuff myself so im intersted to know, It looks like it might be marching cubes on a solid noise mesh with sphereical wormd running through it? Or is it jst 3d tiles?
The rubble really adds to the effect. As for your tangent problem, Ive had the same warnings too for my triplanar hshaders, I couldnt find a solution eithe rim afraid (but im not using nomrl mapping amt so im ignoring it). Id be intersted to know if you find a solution…

This is the closest I’ve gotten with any efficiency…

http://forum.unity3d.com/threads/94766-Mapping-texture-to-world-position-instead-of-object-position