Creating a Material: Difference between revisions
TomEdwards (talk | contribs) No edit summary |
TomEdwards (talk | contribs) No edit summary |
||
Line 5: | Line 5: | ||
== Creating a texture == | == Creating a texture == | ||
Any image file can be used as a texture, so long as both of its dimensions are a power of two: 2, 4, 8, 16, 256, 1024, and so on. Valve's world textures are ''generally'' 512x512, but you are at liberty to use whatever resolution you see fit. Higher resolutions lower performance but make an image sharper when viewed up close. | Any image file can be used as a texture, so long as both of its dimensions are a power of two: 2, 4, 8, 16, 256, 1024, and so on. Valve's world textures are ''generally'' 512x512, but you are at liberty to use whatever resolution you see fit. Higher resolutions lower performance but make an image sharper when viewed up close. Bear in mind that if you go ''too'' high quality may actually degrade because of the amount of resizing required. | ||
Additionally, different classes of object have different standard resolutions (e.g. character models' are very high). Check Valve's choices in <code>source materials.gcf</code> with [[GCFScape]] if you are ever confused. | |||
{{note|Textures should be saved in a lossless format like [[Wikipedia:Truevision TGA|TGA]] | {{note|Textures should be saved in a lossless format like [[Wikipedia:Truevision TGA|TGA]] pre-compile, to prevent unnecessary loss in quality.}} | ||
=== Converting the texture === | === Converting the texture === | ||
Texture(s) must be stored as [[Valve Texture Format]] files. The tool Valve provide for converting them to this format is [[Vtex|VTEX]], but its command-line design makes difficult to learn and unwieldy | |||
Instead, you should use the third-party tool [[VTFEdit]]. VTFEdit provides a graphical user interface, allows you to change a VTF file's properties ''without'' re-compiling it, accepts wide array of input formats, and is generally better in every regard. | |||
To import your texture with VTFEdit, use <code>File > Import</code> or press Ctrl+I. Select your image and you will be presented with the import options screen: | (The author of VTFEdit has also created VTF plug-ins that let you save to the format directly from [http://nemesis.thewavelength.net/index.php?p=39 Photoshop] and [http://nemesis.thewavelength.net/index.php?p=50 Paint.NET], but this tutorial will not cover them as not everyone uses those tools.) | ||
'''To import your texture with VTFEdit''', use <code>File > Import</code> or press {{key|Ctrl+I}}. Select your image and you will be presented with the import options screen: | |||
[[Image:Vtfedit importoptions.png|center|VTFEdit's import options screen]] | [[Image:Vtfedit importoptions.png|center|VTFEdit's import options screen]] | ||
Line 50: | Line 52: | ||
Source doesn't access textures directly. They must first be included in a '''[[material]]'''. | Source doesn't access textures directly. They must first be included in a '''[[material]]'''. | ||
Materials can be created in any text editor, but it's recommended that you use [http://notepad-plus.sourceforge.net/ Notepad++] in conjunction with the community-made [[Notepadpp VDF languages|syntax highlighting rules]]. '''You must save the material under your game or mod's <code>materials\</code> folder with the file extension <code>.vmt</code>.''' | Materials can be created in any text editor, but it's recommended that you use [http://notepad-plus.sourceforge.net/ Notepad++] in conjunction with the community-made [[Notepadpp VDF languages|syntax highlighting rules]]. '''You must save the material under your game or mod's <code>materials\</code> folder with the file extension "<code>.vmt</code>".''' | ||
===Syntax=== | ===Syntax=== | ||
Line 91: | Line 93: | ||
* [[:Category:List of Shader Parameters]] | * [[:Category:List of Shader Parameters]] | ||
* [[:Category:List of Shaders]] | * [[:Category:List of Shaders]] | ||
[[Category:Material System]] | [[Category:Material System]] | ||
[[Category:Tutorials]] | [[Category:Tutorials]] |
Revision as of 06:46, 15 July 2008
This tutorial is a step-by-step guide to creating a brand new material, including the creation of the material's texture.
Creating a texture
Any image file can be used as a texture, so long as both of its dimensions are a power of two: 2, 4, 8, 16, 256, 1024, and so on. Valve's world textures are generally 512x512, but you are at liberty to use whatever resolution you see fit. Higher resolutions lower performance but make an image sharper when viewed up close. Bear in mind that if you go too high quality may actually degrade because of the amount of resizing required.
Additionally, different classes of object have different standard resolutions (e.g. character models' are very high). Check Valve's choices in source materials.gcf
with GCFScape if you are ever confused.

Converting the texture
Texture(s) must be stored as Valve Texture Format files. The tool Valve provide for converting them to this format is VTEX, but its command-line design makes difficult to learn and unwieldy
Instead, you should use the third-party tool VTFEdit. VTFEdit provides a graphical user interface, allows you to change a VTF file's properties without re-compiling it, accepts wide array of input formats, and is generally better in every regard.
(The author of VTFEdit has also created VTF plug-ins that let you save to the format directly from Photoshop and Paint.NET, but this tutorial will not cover them as not everyone uses those tools.)
To import your texture with VTFEdit, use File > Import
or press Ctrl+I. Select your image and you will be presented with the import options screen:
General settings
These settings are the most important. There are three:
- Normal format
- The sub-format the texture should be stored in if it is opaque.
- Alpha format
- The sub-format the texture should be stored in if it has transparency.
- Texture type
- How this texture will be used; normally as an Animated Texture, even if it doesn't actually have animation.
If you're making a plain and simple world texture you won't need to change any of these. If you're making a texture with fine gradient detail however, you'll need to choose more suitable formats.
Mipmap settings
These settings define how the texture is scaled when viewed from far away, or when the game is running with medium or low texture detail. The only time you will realistically need to worry about it is when creating interface textures, for which you should disable the check box. This ensures that your menu images are always sharp and readable, even if the very lowest texture detail setting is being used.
Normal map settings
These (mis-labelled) settings allow you to automatically generate a bump map from your input image. You'll want to do this properly with an image editor for the material you ship, but the automated option is there regardless if you want quick results or a base to work from.
Configuring the VTF
See Valve Texture Format#Image_flags. These options can all be found in the checkbox list on the left-hand side of the VTFEdit window.
Creating a material
Source doesn't access textures directly. They must first be included in a material.
Materials can be created in any text editor, but it's recommended that you use Notepad++ in conjunction with the community-made syntax highlighting rules. You must save the material under your game or mod's materials\
folder with the file extension ".vmt
".
Syntax
A material file looks like this:
<shader> { <parameter> <value> ... }
LightmappedGeneric { $basetexture coast\shingle_01 $surfaceprop gravel }
There are many shaders to choose from, but most materials will use either LightmappedGeneric
(brushes) or VertexLitGeneric
(models). The third most common shader is UnlitGeneric
, which is used for UI materials and the occasional tool texture.
Parameters
- For a list of all documented shader parameters, see Category:List of Shader Parameters.
With a shader chosen you're onto parameters. There are hundreds of options for what to put in a material so this article will only cover the most common, which are accepted by more or less all shaders. They are:
