small fix, clamping material indices