Is it possible to change material's shader to apply it for model?

Hi, I want to apply an ice material to player model, there’s no good one in material list, but there’re some good materials but they have LightmappedGeneric shader what makes it impossible to apply to model.
Is there way to change shader in-game through Lua?

My guess would be to do as follows:

  • Open the “good material” VMT so you know what parameters to assign
  • Create a material using

CreateMaterial with shaderName as “VertexLitGeneric” (or whatever you need it to be), and materialData a table with the stuff contained in the VMT you opened above

  • Assign the newly created material

Essentially you are recreating the same material, just with a different shader

The downside with that is that CreateMaterial is only available clientside.

It might be better if you duplicate the VMT with a similar (or better) name and change only the shader. Save it on the server and make sure to send it to the client too, and then just use your new material like you would any other material!

In most cases, changing only the shader will work just fine.

CreateMaterial("frozentex", "VertexLitGeneric", {
	["$basetexture"] = "Models/Combine_soldier/Combine_elite",
	["$model"] = 1,

lua_run Entity(1):SetMaterial("!frozentex")

Doesn’t do anyting.

UPD. It works with PNG only

So it would have to be


I meant that. typo

Try calling SetMaterial on the client, not the server

Nah It has started working after I changed the name to frozentex1, seems like it doesn’t like to override already existed materials or kinda like that.