How to unload material function base on player distance

Hi,
for performance reason, i want to know if there is a way to unload or switch off some material functions when player is far?
pixel depth are runtime numbers, how to make it into a Boolean?
or there is another way to achieve this?
please help me. thank you