When implementing a quite complex pixel shader on pixel shader for multi-cascade shadows maps on shader model 2.0, I’d got a usual error message saying that “Arithmetic instruction limit of 64 exceeded“, so once again I have to find an instruction slot.
I had a code that tries to find the best shadow map for current pixel, something like:
//float2 map[] is a u/v pair; if it is "inside" the texture, I can use it
if (map[0].x < 0 || map[0].x > 1 ||
map[0].y < 0 || map[0].y > 1)
{
//...
}
This code was converted to:
//float2 map[] is a u/v pair; if it is "inside" the texture, I can use it
if( any (map[0]-saturate(map[0] ) ) )
{
//...
}
This takes much less instructions, so now I have some free slots!
Advertisement
Tags: HLSL, optimizations