Garry's Mod Wiki

Revision Difference

render.ModelMaterialOverride#561885

<function name="ModelMaterialOverride" parent="render" type="libraryfunc"> <description>Sets a material to override a model's default material. Similar to <page>Entity:SetMaterial</page> except it uses an <page>IMaterial</page> argument and it can be used to change materials on models which are part of the world geometry.</description>⤶ <description>⤶ Forces all future draw operations to use a specific <page>IMaterial</page>. ⤶ ⤶ Because this is independent of a specific <page>Entity</page>, it can be used to change materials on static models that are part of maps.⤶ </description>⤶ <realm>Client</realm> <args> <arg name="material" type="IMaterial">The material override.</arg>⤶ <arg name="material" type="IMaterial">⤶ The <page>IMaterial</page> that will be used for all upcoming draw operations, or `nil` to stop overriding. ⤶ </arg>⤶ </args> </function>⤶ ⤶ <example>⤶ <description>Sets the material of all opaque models to the red flashing "ERROR" texture.</description>⤶ <code>⤶ local error_mat = Material("models/error/new light1")⤶ ⤶ function GM:PreDrawOpaqueRenderables(bDrawingDepth, bDrawingSkybox)⤶ ⤶ render.ModelMaterialOverride(error_mat)⤶ ⤶ end⤶ </code>⤶ ⤶ </example></function>