Revision Difference
Global.CreateMaterial#514838
<function name="CreateMaterial" parent="Global" type="libraryfunc">⤶
<description>⤶
Creates a new material with the specified name and shader.⤶
⤶
<note>Materials created with this function can be used in <page>Entity:SetMaterial</page> and <page>Entity:SetSubMaterial</page> by prepending a "!" to their material name argument.</note>⤶
⤶
<bug issue="1531">.pngs must be loaded with <page>Global.Material</page> before being used with this function.</bug>⤶
⤶
<bug issue="2511">This does not work with [patch materials](https://developer.valvesoftware.com/wiki/Patch).</bug>⤶
⤶
<bug issue="3103">This will not create a new material if another material object with the same name already exists.</bug>⤶
</description>⤶
<realm>Client and Menu</realm>⤶
<args>⤶
<arg name="name" type="string">The material name. Must be unique.</arg>⤶
<arg name="shaderName" type="string">The shader name. See .</arg>⤶
<arg name="materialData" type="table">Key-value table that contains shader parameters and proxies.

* See: [List of Shader Parameters on Valve Developers Wiki](https://developer.valvesoftware.com/wiki/Category:List_of_Shader_Parameters) and each shader's page from .

<note>Unlike <page>IMaterial:SetTexture</page>, this table will not accept <page>ITexture</page> values. Instead, use the texture's name (see <page>ITexture:GetName</page>).</note></arg>⤶
</args>⤶
<rets>⤶
<ret name="" type="IMaterial">Created material</ret>⤶
</rets>⤶
</function>⤶
⤶
<example>⤶
<description>Alternative to <page>render.SetColorMaterial</page>, mainly for use with <page>Entity:SetMaterial</page></description>⤶
<code>⤶
CreateMaterial( "colortexshp", "VertexLitGeneric", {⤶
["$basetexture"] = "color/white",⤶
["$model"] = 1,⤶
["$translucent"] = 1,⤶
["$vertexalpha"] = 1,⤶
["$vertexcolor"] = 1⤶
} )⤶
</code>⤶
⤶
</example>