In this section we're going to modify a material at runtime.
IStatObj, we can also clone our material to avoid making changes to all of the objects using it currently. To do so, call
IMaterialManager::CloneMaterial, which is accessible via
The first thing we need to do is obtain an instance of the material we want to edit. If we have an entity nearby, we can use
IEntity::GetMaterial as shown:
IMaterial *pMaterial = pEntity->GetMaterial();
IEntity::GetMaterial returns null if no custom material has been set. If this is the case, you might want to rely on a function such as
IMaterial instances can be used ...