Garry's Mod Wiki

Garry's Mod Wiki

  render.MaterialOverride( IMaterial or nil material = nil )

Description

Sets the render material override for all next calls of Entity:DrawModel. Also overrides render.MaterialOverrideByIndex.

See render.WorldMaterialOverride, render.BrushMaterialOverride and render.ModelMaterialOverride for similar functions.

In certain scenarios such as during entity's shadow pass, using this function can cause unexpected side effects. See example below on how to deal with this.

Arguments

1 IMaterial or nil material = nil
The material to use as override, use nil to disable.

Example

Deal with shadow passes during entity rendering. This usually only applies to opaque renders (so not to ENT:DrawTranslucent).

local matForOverride = Material( "phoenix_storms/stripes" ) function ENT:Draw( flags ) -- If the model is currently rendering in the shadow pass, do not overwrite any materials and just render the model(s) normally. -- In this case we just render the model without any material overrides and returning early. if ( ( bit.band( flags, STUDIO_SSAODEPTHTEXTURE ) != 0 || bit.band( flags, STUDIO_SHADOWDEPTHTEXTURE ) != 0 ) ) then self:DrawModel( flags ) return end -- The rest of your code. For example: render.MaterialOverride( matForOverride ) self:DrawModel( flags ) render.MaterialOverride() end

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...