From Valve Developer Community
Jump to: navigation, search

material_modify_control is a point entity available in all Source Source games. It is used to modify arbitrary material properties in response to I/O events.

For the entity to work, its target material must have the MaterialModify or MaterialModifyAnimated proxy installed, and must be applied to an entity.

Compare this with the env_texturetoggle entity that can control brushes or overlays by targetname.

Bug.png Bug: The entity will not work unless it's parented to an object that's in the PVS and on-screen which has at least one face facing towards the viewer that's textured with the Material to Modify.

Instances of the Material to Modify on world geometry are controlled by the lowest-ID (first created in Hammer) material_modify_control, in addition to instances of the material on the material_modify_control's parent.


Material to modify (materialName) <string>
Path to the VMT file you want to modify, relative to materials/ folder. Without .vmt suffix.
Bug.png Bug: Does not work if the VMT is just in materials/. Should be in a subfolder, like materials/effects/ for example.
Bug.png Bug: (Confirmed to be the case in Counter-Strike: Global Offensive) When a Material has a $envmap with env_cubemap as the value this entity will appear to not work for that material. This is because VBSP will patch the original material and give it a different name that corresponds to the position of the closest cubemap to the brush face that has that material. This happens for every occurrence of the material. In order to make it work you can replace the env_cubemap in your material with the path to the generated image of the closest cubemap for example: env_cubemap "maps/yourmap/c124_28_-60"} (however that means you will have to do it for every occurrence of the material you want to change especially when you want them to use different cubemap images). This will make it so that VBSP will not try to patch the material and thus leave the original name. Another way is to just to directly specify the patched material name that is generated by VBSP which you can find after unpacking the map file.
Material variable to modify (materialVar) <string>
Name of the shader parameter you want to modify. Include $ symbol like how they are written in the VMT

Parent (parentname) <targetname>
Specifies a movement parent. An entity will maintain its initial offset from its parent. An attachment point can be added to the end of the name, separated by a comma.

Name (targetname) <string>
The targetname that other entities refer to this entity by.


SetMaterialVar <string>
Sets the chosen material parameter to the specified value.
This sets the material variable to the current time on the server.
StartAnimSequence <string>
Force an animated material with the MaterialModifyAnimated proxy to play a set of animation frames.
Format is: <Frame Start> <Frame End> <Frame Rate> <Loop>
<Loop> should be 1 or 0.
Tip.png Tip: Setting "Frame End" to -1 uses the last frame of the texture.
StartFloatLerp <string>
Force a material with the MaterialModifyAnimated proxy to linearly interpolate a material var between two floating point values.
Format is: <Start Value> <End Value> <Transition Time> <Loop>
<Loop> should be 1 or 0.
Note.png Note: For the linear interpolation to work correctly you need both MaterialModify and MaterialModifyAnimated proxies to be presented.

To do: There are some clarifications needed to be done about some quirks of this Input.

SetParent <string>
Move with this entity. See Entity Hierarchy (parenting).
SetParentAttachment <string>
Change this entity to attach to a specific attachment point on its parent. The entity will teleport so that the position of its root bone matches that of the attachment. Entities must be parented before being sent this input.
SetParentAttachmentMaintainOffset <string>
As above, but without teleporting. The entity retains its position relative to the attachment at the time of the input being received.
Removes this entity from the the movement hierarchy, leaving it free to move independently.

Removes this entity from the world.
Removes this entity and its children from the world.
Note.png Note: Entities already remove orphaned children upon being removed, but this input removes all children on the same frame, being marginally faster than Kill.
AddOutput <string>
Adds a keyvalue/output to this entity. It can be potentially very dangerous, use with care.
KV Format: <key> <value>
I/O Format: <output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire, -1 means infinite>
FireUser1 to FireUser4
Fire the OnUser outputs; see User Inputs and Outputs.
Use  !FGD
Same as a player invoking +use; may not do anything depending on the entity. Can also be invoked by firing an output that does not specify an input.
RunScriptFile <script> (in all games since Left 4 Dead 2)
Execute a VScript file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.
RunScriptCode <string> (in all games since Left 4 Dead 2)
Execute a string of VScript source code in the scope of the entity receiving the input. String quotation may be needed when fired via console.
Bug.png Bug: In Left 4 Dead 2, the code is executed in the script scope of the entity that fires the output, not the one receiving the input.
Warning.png Warning: Never try to pass string parameters to a script function with this input. It will corrupt the VMF structure because of the nested quotation marks, which then must be removed manually with a text editor.
CallScriptFunction <string> (in all games since Left 4 Dead 2) !FGD
Execute a VScript function in the scope of the receiving entity.
SetLocalOrigin <coordinates> (in all games since Alien Swarm) !FGD
Send this entity to a spot in the map. If the entity is parented to something, it will be offset from the parent by this amount.
SetLocalAngles <angles> (in all games since Alien Swarm) !FGD
Set this entity's angles.


OnUser1 to OnUser4
These outputs each fire in response to the firing of the like-numbered FireUser1 to FireUser4 Input; see User Inputs and Outputs.
OnKilled  (only in Left 4 Dead Left 4 Dead 2)
This output fires when the entity is killed and removed from the game.