Material

From Garry's Mod
Revision as of 19:16, 28 August 2016 by Jvs (Talk | contribs)
Jump to: navigation, search
 Material( )

Contents

Description

Either returns the material with the given name, or loads the material interpreting the first argument as the path.

To set a Lua material created with CreateMaterial, just prepend a "!" to the material name.

Arguments

string materialName

The material name/path.

Arguments

string pngParameters

A string containing keywords which will be used to add material parameters.

NOTE

Only works with .png files.

Possible values are: vertexlitgeneric unlitgeneric nocull alphatest mips noclamp smooth

Returns

IMaterial

Generated material

Returns

number

How long it took for the function to run

Examples

Example

Creates a PNG material with noclamp and smooth parameters set

local wave = Material("vgui/wave.png", "noclamp smooth")


Examples

Example

Acquires and uses one of the Post-Processing Materials to make the screen darker and more saturated

local mat_color = Material( "pp/colour" )  -- used outside of the hook for performance

hook.Add("RenderScreenspaceEffects", "ColorExample", function()
	render.UpdateScreenEffectTexture()

	mat_color:SetTexture( "$fbtexture", render.GetScreenEffectTexture() )

	mat_color:SetFloat( "$pp_colour_addr", 0 )
	mat_color:SetFloat( "$pp_colour_addg", 0 )
	mat_color:SetFloat( "$pp_colour_addb", 0 )
	mat_color:SetFloat( "$pp_colour_mulr", 0 )
	mat_color:SetFloat( "$pp_colour_mulg", 0 )
	mat_color:SetFloat( "$pp_colour_mulb", 0 )
	mat_color:SetFloat( "$pp_colour_brightness", 0 )
	mat_color:SetFloat( "$pp_colour_contrast", 0.5 )
	mat_color:SetFloat( "$pp_colour_colour", 5 )

	render.SetMaterial( mat_color )
	render.DrawScreenQuad()
end )


Personal tools
Navigation