Unity 5 - Shader error in VertexBlend : Too many output registers declared (12). How to fix it?
Hi! I upgraded a project to Unity 5, I had the usual " variable not fully initialized" error in a lot of shader, I fixed it by adding UNITY_INITIALIZE_OUTPUT(Input, o); No problem. But now I have a shader that blends 2 * (diffuse+normal) texture pairs based on a blend texture I got a strange error. The shader only throws the error when in playmode. The shader error:
Shader error in 'VertexBlend': Too many output registers declared (12). When no output register has been declared with the semantic 'psize0', 11 o# registers are available. When an o# register has been declared with the semantic 'psize0' (same as 'psize'), 12 registers are available. at line 192 (on d3d9)
Compiling Vertex program with DIRECTIONAL SHADOWS_SCREEN LIGHTMAP_OFF DIRLIGHTMAP_OFF DYNAMICLIGHTMAP_OFF FOG_EXP2 VERTEXLIGHT_ON
It seems to work, but I am affraid it will break on some mobile devices. Can anyone tall me what is wrong? What should I change to make it work?
My vert output structure:
struct Input {
float2 uv_MainTex : TEXCOORD0;
float2 uv_Diffuse2 : TEXCOORD1;
float2 uv_BlendMask : TEXCOORD2;
float4 color : COLOR;
float2 uv_Normal1 : TEXCOORD3;
float2 uv_Normal2 : TEXCOORD4;
};
Thanks!
Answer by fguinier · Sep 29, 2015 at 02:49 PM
Hi Borissow,
Depending on the platform/shader model targeted the amount of output register available are different. Furthermore the packing can have a great importance too.
Shader model 3.0 doc -> 1 pos register, 1 scalar point size register, 10 general purpose register. Shader model 4.0 doc -> 16 all purpose register
So i suppose in your case you can probably pack things up to use fewer register, or increase the target shader language (and min spec of your project ?).
PS : Additionally on some hardware you will have a performance gain at packing stuff.
Hope it helps
Florent
The strange thing is that I am using shader model 3.0 and when I open the compiled shader it has exactly 12 registers, so theoretically it should be ok. Another strange thing is that this shader is used in multilpe scenes, in some the error appears when I hit play in the editor, in other it doesn't.
By packing up you mean I put two float2-s in one float4?
You are right ! Actually looking better at the error message the compiler say that you only have space for 11 register as no psize semantic is used ! -> finally looking at that doc its problematic in S$$anonymous$$3, thus the trouble (i just updated the anwer too to avoid confusion)
https://msdn.microsoft.com/en-us/library/windows/desktop/bb147365(v=vs.85).aspx look for "Simplify Output Registers"
By packing up you mean I put two float2-s in one float4? -> Yep
PS : just in case this link might be related http://forum.unity3d.com/threads/error-too-many-output-registers-declared.309662/
It's seems it was one of Unity's schenanigans. The next day when I opened the scene with the error it was gone. Anyway what you suggested was correct for this error (AFAI$$anonymous$$). Thanks for the help :)
Your answer
Follow this Question
Related Questions
Migrating from 2018.3.x to 2019.1 0 Answers
[Video] Very strange wavy(shader?) bug on device but not on emulator where gameobjects meet 1 Answer
Can't find shader on iOS - GpuProgram creation error: shader program type is unrecognised. 2 Answers
What are the property names in the new Unity 5 standard shader 3 Answers
Replaced '_Object2World' with 'unity_ObjectToWorld' 1 Answer