tesselation shader uv4

Hi there!

Usually I eventually manage to find what I am looking for, not this time.

I am playing around with the tesselation examples

The mesh has data on the uv4 channel. In other surface shaders something like the below in the struct Input{} works well:

float2 uv4_detailTex : TEXCOORD2,

When doing this in the above tesselation examples the following error is thrown:

invalid subscript ‘texcoord3’ at line361 (on d3d11)

texcoord3 does not exist in the struct neither does line 361.

Anyone knows what could be wrong here or knows the correct way access uv4 coords in this type of shaders?

A surface shader is a vertex fragment shader generator. The “line 361” being referred to is the line in the generated shader.

The uv4_ prefix translates to “use the variable with the TEXCOORD3 semantic from appdata as the uvs” in the shader since the texcoord semantics are zero based. That : TEXCOORD2 in the Input struct is completely ignored.

The issue comes down to their implementation of Tessellation in surface shaders doesn’t handle wanting anything but the normals, tangent, main uv and secondary uv. Anything beyond that and it generates a shader that won’t compile, like you’re seeing. The solution is to hand-modify the generated shader and use that instead. Its not ideal, but it at least works.

Here’s a thread on a similar problem.
https://discussions.unity.com/t/640528/6

Many thanks for the clear explanation!

The solution sounds complicated. I will check your post in the other thread.