How calculate tangent vector for the second uv channel?

I have the exact same problem as in this post :

Solution using ddx and ddy is unclear and does not work properly…
Are there any other ideas?
How calculate tangent vector for the second uv channel?

Sorry, I meant to update that original thread with my findings but it totally slipped my mind.

The shader Ryan posted seemed to work perfectly for me. I didn’t even notice that triangulation problem that he had. I originally couldn’t figure out the final step to combine the normals on the separate UV channels, but I think i got it. I can’t guarantee that this is 100% right but it seemed to work out well.

Anyways, here are the results and the full shader graphs:

The normal map plugged into the new tangent basis function is a tiling brick texture that’s mapped to UV channel 1. UV channel 0 has the unique damage sculpt normal map.
It’s important to have Tangent Space Normal unchecked on the material attributes.

Here’s the graph for the tangent basis function using the shader that Ryan posted.

Thanks for the answer. I have this error. My version of the engine 4.8

This is cool! Thanks Calypso.

btw I did end up finding another way of doing this that fixed the viewing angle problem 100%, but it is a bit more expensive. It also reduces the faceting in some cases. It is based on this math:

Generating the Tangent and Binormal looks like this:

(EDIT there was a messup in the graph, fixed)

You can also just use the nodes “T” and “B” directly by just normalizing each of them. The current setup normalizes them to the largest one instead of individually which solves a minor issue with viewing angles. I tried to also add the “T” and “B” comments to the modified versions of them at the end but my build has a bug that made new comments not show up. But the nodes to the far right are still the T and B they are respectively connected to.

To use it you still need the use the transform as above with these vectors.

btw, the biggest problem with my ‘simple’ version, is that it will be very wrong if you go stand next to a wall and look straight up. It is basically assuming the geometry faces the camera and it will be wrong by the angle difference. In many cases it won’t be a problem and is about half the cost of the “correct” version.