Add maximum texture unit detection