https://github.com/galaco/vmt
Golang package for parsing .vmt Valve Material files
https://github.com/galaco/vmt
counter-strike material parser source-engine team-fortress-2 valve vmt vtf
Last synced: 6 months ago
JSON representation
Golang package for parsing .vmt Valve Material files
- Host: GitHub
- URL: https://github.com/galaco/vmt
- Owner: Galaco
- License: unlicense
- Created: 2019-09-17T22:41:02.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-10-28T01:06:47.000Z (over 3 years ago)
- Last Synced: 2025-04-04T11:13:33.671Z (10 months ago)
- Topics: counter-strike, material, parser, source-engine, team-fortress-2, valve, vmt, vtf
- Language: Go
- Homepage:
- Size: 19.5 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://godoc.org/github.com/galaco/vmt)
[](https://goreportcard.com/badge/github.com/galaco/vmt)
[](https://golangci.com)
[](https://circleci.com/gh/galaco/vmt/tree/master)
[](https://codecov.io/gh/galaco/vmt)
# 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.
```go
var fs *filesystem.Filesystem // create this elsewhere
result := vmt.NewProperties()
mat,err := vmt.FromFilesystem("metal/metal_01.vmt", fs, result)
```
##### From a stream
```go
stream,_ := os.Open("metal/metal_01.vmt")
result := vmt.NewProperties()
mat,err := vmt.FromStream(stream, result)
```
##### From existing github.com/galaco/keyvalues
```go
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:
```go
package foo
type CustomShader struct {
MyProperty string `vmt:$myproperty`
}
```