   Slow shader loops
  I have a fairly complex terrain shader that I'm having an issue with. Without going into too much detail, I'm using a small texture sampler (with no filtering) as a lookup table. Each 32-pixel line in this texture contains 16 pairs of numbers. The first one is an index into a blend atlas and the second one is a material index.  Essentially, each 32-pixel run relates to a small terrain patch and allows me to have upto 16 materials blended per patch (way more than you'd ever need of course). Now if I just index the first entry, everything runs super-quick but as soon as I introduce any kind of loop, things start crawling. At first, I tried a while loop which was basically:While (index > 0 && i < 32){   Do the blend lookup from the index   Do the material lookup   Blend the two and add to the overall result   i += 2   index = lookup next index from LUT}With only one index pair like this:1,1,0,0,0,0,0....In the LUT, the shader really crawls along which is strange because it's essentially doing the same thing as explicitly getting the first index only.I also tried making the first index the number of pairs to follow so I could use a for loop but this was even worse.  Is there somthing I'm missing with regard to using loops in a shader?I'm using hlsl sm3.0 and my card is a gtx295.Thanks in advance   