Vmt is a parser for Valve Material Format (
.vmt
) files.
Vmt's in Source can be a little painful; large number of possible parameters, many being specific to a particular shader. This package exists to reduce the pain of parsing materials.
You can use either the Properties
struct provided, or a custom definition to only get the properties desired. Properties must
be correctly typed in whatever definition is used.
If there are parameters missing from the standard Properties
definition, please submit a PR to add them.
For now, nested properties are unsupported (e.g. Proxies
).
There are 3 ways to read material definitions using this package:
This is the recommended solution, as it is the only method of resolving a material that
uses the include
property.
var fs *filesystem.Filesystem // create this elsewhere
result := vmt.NewProperties()
mat,err := vmt.FromFilesystem("metal/metal_01.vmt", fs, result)
stream,_ := os.Open("metal/metal_01.vmt")
result := vmt.NewProperties()
mat,err := vmt.FromStream(stream, result)
var kv *keyvalues.KeyValue // create this elsewhere
result := vmt.NewProperties()
mat,err := vmt.FromKeyValues(kv, result)
If you've ever used the build-in json package, this should be familiar. See the Properties
struct in this package for the default material. However, you can define your own definition below:
package foo
type CustomShader struct {
MyProperty string `vmt:$myproperty`
}