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:
for(lightcount)
{
calc att
if(att>=0.0001)
{
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…