Conditional branching on NV4x

I’m battling with pixel shader for 4+ lights now.
Problem I currently have is performance of it…

So far I’m doing attenuation coef calculation, light distance calculation, transform to tbn in fragment shader, as I’m runing out of varyings otherwise.

Shader is pretty costly as it’s based on relief mapping + multi point lighting/attenuation.

What I would like is to implement is some sort of conditional that is responsible for lighting calculation.

What I was trying to do so far is:

calc att
calc diff, calc spec

But that doesnt seem to work well, overhead seems to be too huge to give any speedup.

What can I do to get frames up???
Multiple drawbuffers and conditionals based on one of them?
Use vertex program to get number of active lights, then pass array of them to fragment and iterate through it (interpolated lenght != lenght calculated from interpolated positions in fp)?
Anything else???

Often there is only one light or two lights covering the region…

The platform needs real branching instruction support or it’s going to unroll and multiply to zeroes doing the math anyway, there’s also possibly negative effects of branching on pipelining/parallel execution. You may be better off stitching a program together based on light count and recompiling but that only gets you fixed light switches not attenuation based optimization that I see you’re attempting.
Moving the thread to shaders where you might get a better response.