Tangent in Matieral

Let me first say, I’m not rendering expert, so I’m hoping this is an easy one.

I’m trying to access the vertex tangent data that I have set in my mesh for my shader.

In Unity I can pull and use this data quite easily with one line of code:
float4 tangent : TANGENT;

Is there an Unreal equivalent? I’m using this data to blend four textures, vertex colours, and uv channels.

You can set the UV channels with the TextureCoordinate nodes, you can adress specific vertex colors with the vertex color node, and with proper use of add’s and multiplies you can get rather far.

I dont know if that helps any.

UE4 does not use TANGENT semantic anywhere as far as I know. I did not check myself, but as a wild guess, I think that tangent space is stored in a more optimized way.

If you are sure that you are running out of interpolators, you would need to modify the shaders. Material editor alone won’t cope with that.

However, you could describe the actual goal you are trying to achieve? It is quite common that there is a more accessible solution for majority of tasks.

Unfortunately not. I’m using 4 TextureCoordinates for the UV channels, and the Vertex Colours for the colours. I just need one more float4 through. If I had more UV channels I’d just shove the data in there.

Long story short, all I need to do is get an additional float4 per vertex in the shader. As I said, if I weren’t already using 4 UV channels, then I’d add two more and pass through 2 float2’s. I need those floats through to do some per vertex uv blending. I’m now wondering if I can pack them in with the other UV channels… which may work as long as it doesn’t mind those floats being > 1.

More info:

NewData.TangentBasisComponents[0] = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FU4DProcMeshVertex, Tangent, VET_PackedNormal);
NewData.TangentBasisComponents[1] = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FU4DProcMeshVertex, Normal, VET_PackedNormal);

Tangent and Normal are packed into the vertex data here. You can use the normal in the shader… I just need to get at that tangent data.

Uhm… I have meshes that use up to six, and afaik you can have 8 uv channels… or was it 16… brain just booted up (just woke up)

6 pairs? I was under the impression that there were 4 pairs of UV channels available, or 8 UV’s total.

Ok, here’s the solution I went with. From Luos’ comment I went searching for more UV channels. I wasn’t properly using the UV channels on my mesh and bumped it up to 8 UV pairs. That allowed me to have the 4 UV channels I wanted and shove a Vec4 into another 2 UVs. I can then pull that data in the shader.

It’s a pretty round-about way to get data. It’d be really nice to be able to have any amount of custom data per vertex accessible in the shader.

You were right, supports 8 UVs on a static mesh. I wasn’t using them properly. That allows me to do what I need.

This all makes me curious though, would love to see what you wanted to do with it.

If you want to request more data/vertex your best bet is probably the suggestions section on the forums :slight_smile: