Revision Difference
Material_Parameters#546284
<cat>Dev</cat>
This page describes possible values for the second parameter of the <page>Global.Material</page> function when importing .png or .jpg textures, as well as some specific material key-values being set in that process.
For a list of all flags that can be controlled by settings the $flags int, see https://developer.valvesoftware.com/wiki/Material_Flags
Possible values are:
Value | Description |
------|-------------|
| vertexlitgeneric | Makes the created material a `VertexLitGeneric`, so it can be applied to models. Default shader is `UnlitGeneric` |
| nocull | Sets the [$nocull](https://developer.valvesoftware.com/wiki/$nocull) to 1 in the created material. |
| alphatest | Sets the [$alphatest](https://developer.valvesoftware.com/wiki/$alphatest) to 1 in the created material instead of [$vertexalpha](https://developer.valvesoftware.com/wiki/$vertexalpha) being set to 1. |
| mips | Generates [Mipmaps](https://en.wikipedia.org/wiki/Mipmap) for the imported texture, or sets **No Level Of Detail** and **No Mipmaps** if unset. |
| mips | Generates [Mipmaps](https://en.wikipedia.org/wiki/Mipmap) for the imported texture, or sets **No Level Of Detail** and **No Mipmaps** if unset. This adjusts the material's dimensions to a power of 2. |
| noclamp | Makes the image able to tile when used with non standard UV maps or <page>surface.DrawTexturedRectUV</page>. Sets the CLAMPS and CLAMPT flags if unset. |
| smooth | If set does nothing, if unset - enables Point Sampling (Texture Filtering) on the material as well as adds the **No Level Of Detail** flag to it. |
| ignorez | If set, the material will be given `$ignorez` flag, which is necessary for some rendering operations, such as render targets and 3d2d |
# Additional Notes
When you call <page>Global.Material</page> with a file extension, the engine creates a material and a new texture from that file.
The created texture will have its size set to the closest [power of two](https://en.wikipedia.org/wiki/Power_of_two) size.
The material is given the following parameters by default:
```
"UnlitGeneric"
{
"$basetexture" "<set to the newly created texture>"
"$vertexcolor" "1"
"$realwidth" "X" // The width of the actual png/jpg file
"$realheight" "X" // The height of the actual png/jpg file
// Custom parameters
"$nocull" "1" // Only set if nocull parameter is given
"$alphatest" "1" // Only set if alphatest parameter is given
"vertexalpha" "1" // Only set if alphatest parameter is NOT given
}
```
## vertexlitgeneric
<image src="vertexlitgeneric.png" alt="500px"/>
This is used in the VMT of most models that need correct lighting and shadows.
You don't really need to worry about it for 2D textures though, since they don't need lighting.
The other commonly used option is **unlitgeneric**, which makes the model have no lighting at all, similar to typing **mat_fullbright 1** in the console.
It is unknown why it exists for 2D textures though, probably just for usage with <page>Global.Mesh</page>.
## nocull
<image src="nocull.png" alt="500px"/>
This makes the back of the texture get drawn all the time.
If you're working in <page>cam.Start3D2D</page> then it can help if you want a double sided texture.
## alphatest
<image src="alphatest.png" alt="500px"/>
This makes the material have an alpha of either 0 or 1, instead of a range between those values.
It makes the alpha edges look very hard, but it can fix some transparency related problems.
It can be used to allow alpha in stencils. If you're trying to use a material in a stencil with an alpha channel, use alphatest.
[It also allows the flashlight cast shadows from the material](https://developer.valvesoftware.com/wiki/$translucent#Flickering_and_reversed_depth).
## mips
<image src="mips.png" alt="500px"/>
This makes low-res versions of the texture that it swaps out as it gets smaller.
It can help improve performance, and you usually can't see the difference.
This can improve smoothing if you're scaling down the texture a lot.
## noclamp
<image src="noclamp.png" alt="500px"/>
This allows the texture to tile, so if you want a repeating pattern then it can help.
<page>surface.DrawTexturedRectUV</page> will help you draw a pattern.
It also stops the edges getting stretched, which can make it look smoother.
## smooth
<image src="smooth.png" alt="500px"/>
This stops point sampling, which makes textures look like Minecraft.
It makes the texture look smoother when you scale it.