fix a function variable name that was shadowing a parameter name
restrict max_anisotropy to 1 ≤ max_anisotropy ≤ max_anisotropy_max
fixed some bugs and fixed a variable that wasn't declared at the top