Fix a bug of using material.