Also be aware that the layer selection (that would be the mipmap selection for a real texture) the way you do it is only suited for the bilinear filter. If you want to have 'real' anisotropic filtering, you have to use the right math as well. Consult the EXT_texture_filter_anisotropic specs for that.