Multiple tangent spaces shader graph?

Hello

A question regarding the shader has already been asked here, here is a specific quote from there:

[quote=“bluescrn, post:1, topic:876918, full:true”]

Has anyone created a shader that deals with 2 tangent spaces to blend normal maps that are differently oriented?

We want to use UV0 for a base map, and UV1 to add details (decals/trim) that also have a normal map. The problem is that the orientation of the mapping isn’t guaranteed to be the same between the two layers.

Is there a standard nice for this sort of case? Or do people avoid it?

I guess I could use an AssetPostprocessor script to generate the second set of tangents, or some data derived from them (the 2D rotation required to rotate one normal into the other tangent space?).

(And on that subject, is there a better way than naming convention/string matching to tag models that require special postprocessing? - Is there any way to add custom data/UI to the import settings?) [/quote]

Answer:

[quote=“bgolus, post:2, topic:876918”]Generally people avoid it, or they just YOLO it and use the UV0 tangents for everything (Unity’s own shaders do this!). None of Unity’s systems know how to handle more than one per vertex tangent, so things like batching or skinning will break if you try and generate a second set of tangents as they won’t get transformed properly. Though the idea of using a tangent that’s rotated from the base is a decent solution to that.

However what I do is I generate the tangent to world matrix in the fragment shader.[/quote]

Now the question.

Is it possible to repeat this but in a shader graph or in the Amplify Shader?

Not sure you solved this already, but I have a hack for this, and wanted to share in case anyone needs. Custom tangents, and any type of directional vectors, can be baked into tangent space normal map in your 3d editor. (At least it was trivial in Blender 3d; replace the shader’s normal input with any custom vector (including tangent derived from UV map of your choice), then bake tangent space normalmap for the object). Then, when you import this tangent map to Unity, and plug it into Normal Unpack node (or analogous function of Surface shaders), it’ll give you the worldspace direction for the new tangent. It will transform correctly with a skinned mesh.