What is a matproxy?

What is a matproxy? From what I can tell, they are “functions” of some sort that change the internal values of a certain material. But how do they work?

I know they are used in the changing of colors for the physgun/player model.

They can be called through Lua obviously, but only materials with specific code in the .vmt will work with them.

Here’s an example of the breen vmt:
http://glua.me/bin/?path=/materials/models/breen/players_sheet.vmt

And here’s where the material’s proxy color is set:
http://glua.me/bin/?path=/lua/matproxy/player_color.lua

A material proxy is invoked per entity per material(given the material has a proxy) so you have the chance to adjust the material parameters per entity in an easy manner

https://developer.valvesoftware.com/wiki/Material_Proxy