Skip to content
/ vmt Public

Golang package for parsing .vmt Valve Material files

License

Notifications You must be signed in to change notification settings

Galaco/vmt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

a6b4235 · Oct 28, 2022

History

21 Commits
Oct 18, 2021
Apr 20, 2021
Sep 17, 2019
Sep 17, 2019
May 10, 2021
Oct 27, 2019
Sep 26, 2019
Sep 25, 2022
Sep 26, 2019
Oct 27, 2019
Oct 27, 2019
Apr 20, 2021
Oct 8, 2019
Oct 27, 2019

Repository files navigation

GoDoc Go report card GolangCI CircleCI codecov

vmt

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).

Usage:

There are 3 ways to read material definitions using this package:

From a github.com/golang-source-engine/filesystem

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)
From a stream
stream,_ := os.Open("metal/metal_01.vmt")
result := vmt.NewProperties()
mat,err := vmt.FromStream(stream, result)
From existing github.com/galaco/keyvalues
var kv *keyvalues.KeyValue // create this elsewhere
result := vmt.NewProperties()
mat,err := vmt.FromKeyValues(kv, result)
Material Definitions

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`
}