G.SetMaterialOverride

From GMod Wiki

Jump to: navigation, search
Function
Syntax SetMaterialOverride( Material override )
Where is this used?
Description:
Sets the material to be used for rendering.
Returns: nil
Part of Library: Global Functions
Realm: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=G.SetMaterialOverride]G.SetMaterialOverride [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionMakes all models green and transparent.
Used onNewerClient.png
Code
 
local mat = Material("models/debug/debugwhite")
function MakeMyPlayersGreenAndTransparent()
	cam.Start3D( EyePos(), EyeAngles() )
		for k, v in pairs( ents.GetAll() ) do
			if ValidEntity( v ) && util.IsValidModel( v:GetModel() or "" ) then
				render.SuppressEngineLighting( true )
				render.SetColorModulation( 0, 1, 0 )
				render.SetBlend( 0.5 )
				SetMaterialOverride( mat )
 
				v:DrawModel()
 
				render.SuppressEngineLighting( false )
				render.SetColorModulation( 1, 1, 1 )
				render.SetBlend( 1 )
				SetMaterialOverride( 0 )
			end
		end
	cam.End3D()
end
hook.Add( "RenderScreenspaceEffects", "GreenAndTrans", MakeMyPlayersGreenAndTransparent )
 
OutputN/A


See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox