Garry's Mod Wiki

Garry's Mod Wiki

  render.MaterialOverrideByIndex( number index = nil, IMaterial material = nil )

Description

Similar to render.MaterialOverride, but overrides the materials per index. For simple entities you may want to just use Entity:SetSubMaterial.

render.MaterialOverride overrides effects of this function.

Arguments

1 number index = nil
The index of the material to override, in range of 0 to 31. nil will reset all overrides.
2 IMaterial material = nil
The material to override with, nil will reset the override for given index.

Example

Example on overwriting only one of the model's materials.

function ENT:Initialize() if ( CLIENT ) then return end -- Set the model to one with multiple materials. self:SetModel( "models/props_phx/construct/windows/window1x1.mdl" ) end local matForOverride = Material( "phoenix_storms/stripes" ) function ENT:Draw( flags ) -- Override only a certain submaterial (the glass texture) render.MaterialOverrideByIndex( 3, matForOverride ) -- Draw the model as usual self:DrawModel( flags ) -- Reset all material overrides render.MaterialOverrideByIndex() end
Output:
image.png

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...