What does this error mean?
I am working on a Unity shader and I got this error:
Vertex program 'vertex_main': unknown input semantics BINORMAL/0
What does it mean and how do I fix it?
I'd look at the structs. Specifically the binormal, what does it look like? Hard to tell without seeing the code. but my guess is there's a typo in the Input struct.
this is the struct that BINOR$$anonymous$$AL is located in:
struct Application2Vertex {
float3 Position : POSITION; // vertex position in model/local coordinates
float4 UV : TEXCOORD0; // texture coordinates
float3 N : NOR$$anonymous$$AL; // vertex normal in model/local coordinates
float3 T : TANGENT0;
float3 B : BINOR$$anonymous$$AL0;
};
Try: TEXCOORD1 or TEXCOORD2 or something ins$$anonymous$$d.
float3 B : TEXCOORD2;
I don't really know why you get this error, I think BINOR$$anonymous$$AL0 is an invalid semantic to use. I would assume TANGENT0 would cause an error too. $$anonymous$$aybe it depends on whether it's a surface shader or CG. Either way, TEXCOORDs should work, TEXCOORDS don't have to be texture coordinates, you can use them for anything.
Answer by tanoshimi · Nov 24, 2015 at 07:24 PM
As the error states, Unity doesn't recognise the BINORMAL semantic you're using for the "B" member of the input to the vertex shader. As described here, vertex data must be described by one of the following semantics:
POSITION is the vertex position, typically a float4.
NORMAL is the vertex normal, typically a float3.
TEXCOORD0 is the first UV coordinate, typically a float2..float4.
TEXCOORD1 .. TEXCOORD3 are the 2nd..4th UV coordinates.
TANGENT is the tangent vector (used for normal mapping), typically a float4.
COLOR is the per-vertex color, typically a float4.
If you want the binormal, you can calculate that in the vertex shader from the NORMAL and TANGENT as:
v2f vert (appdata v) {
...
float3 binormal = cross( v.normal, v.tangent.xyz ) * v.tangent.w;
...
}
The Application2Vertex
structure that you're defining specifies what data Unity supplies to the shader pipeline in order to render objects on the screen. At the bare $$anonymous$$imum, it must contain an element with the POSITION semantic, because that's what defines where the vertex is in 3d space. The other semantics specify optional additional information.
If you write float3 B : TEXCOORD1;
in your Application2Vertex structure, it'll work, but what that field will be populated with is the second set of UV coordinates assigned to each vertex (the first set uses TEXCOORD0) - is that really what you want?
Not if it doesn't give me as good of a shader. So you would recommend adding the cross product you mentioned earlier within the vert2frag function?
You haven't told us anything about what your shader is meant to do, and assessing how "good" it is is somewhat subjective anyway.... But if you want the binormal, that's how you calculate it.
Your answer
Follow this Question
Related Questions
I don't understand this build error 0 Answers
How to fix (NullReferenceException: Object reference not set to an instance of an object) in my case 0 Answers
Shader error upon build to Oculus Quest 2 1 Answer
how to remove unity system package from player setting 1 Answer
Error: 'failed to open source file: 'CoreRP/ShaderLibrary/Common.hlsl' what to do? 1 Answer