I tried to write a if-else statement to chose a vector form to different arrays in for loop yesterday. But an odd thing occurred, my program has linking error.
The error is as follows :
Vertex info
Internal error: assembly compile error for vertex shader at offset 17290:
– error message –
line 362, column 1: error: too many result variable components written.
I have no idea why the error appears. Does every one encounter this problem as like as my problem ?
you’ve exceeded varying limit. you can get it by querying GL_MAX_VARYING_FLOATS with glGet. when you replace “i” with “0” in your code, compiler just optimizes out unused varyings.
64 varyings already. and there are probably others you didn’t include in your example. your card, most likely, has a limit of 32 varying floats.
most likely you’ll have to optimize your shader in such way that it will use less varyings(like make a limit of 2-3 lights per object, and find most contributing lights on CPU for every object), or switch to another method of rendering multiple lights(see deferred lighting). or consider targeting different hardware, because G105M is really limited. you may also consider calculating tangent-space-normal-mapping only for main distant light(like sun) and for local lights use regular normals(passed with vertex attributes) without bump-mapping