CreateMaterial

From Garry's Mod
Jump to: navigation, search
 CreateMaterial( )

Contents

Description

Creates a new material with the specified name and shader.

NOTE

Materials created with this function can be used in Entity:SetMaterial and Entity:SetSubMaterial by prepending a "!" to their material name argument.

BUG

.pngs must be loaded with Material before being used with this function.

Issue Tracker: #1531

BUG

This does not work with patch materials.

Issue Tracker: #2511

BUG

This will not create a new material if another material object with the same name already exists.

Issue Tracker: #3103

Arguments

string name

The material name. Must be unique.

Arguments

string shaderName

The shader name. See Category: Shaders.

Arguments

table materialData

Key-value table that contains shader parameters and proxies.

NOTE

Unlike IMaterial:SetTexture, this table will not accept ITexture values. Instead, use the texture's name (see ITexture:GetName).

Returns

IMaterial

Created material

Examples

Example

Alternative to render.SetColorMaterial, mainly for use with Entity:SetMaterial

CreateMaterial( "colortexshp", "VertexLitGeneric", {
  ["$basetexture"] = "color/white",
  ["$model"] = 1,
  ["$translucent"] = 1,
  ["$vertexalpha"] = 1,
  ["$vertexcolor"] = 1
} )


Personal tools
Navigation