StrataSource / Engine

Issue tracker for Strata Source
47 stars 2 forks source link

Relative texture paths in VMTs #393

Open vrad-exe opened 2 years ago

vrad-exe commented 2 years ago

Which component should be improved?

Other

Describe your feature suggestion in more detail

One feature I've always wished Source had (and which I was surprised it didn't the first time I made a material) is the ability to specify texture paths relative to the location of the VMT, instead of always relative to materials/. This would allow moving materials around between folders without having to manually update all the texture paths in them.

One way I imagine this working is similar to relative gameinfo search paths, with specific keys surrounded by pipes that could be used in VMTs and would be replaced by a relevant file path. The two I had in mind were:

So for example, the following VMT located at materials/models/some_props/prop1.vmt:

LightmappedGeneric
{
    $basetexture "|material_name|"
    $bumpmap "|material_dir|prop_normal_common"
}

would effectively behave as:

LightmappedGeneric
{
    $basetexture "models/some_props/prop1"
    $bumpmap "models/some_props/prop_normal_common"
}

Of course the big downside with this is that materials using this feature would no longer be backwards-compatible with other Source games. I don't think this is a huge concern though, since we add new graphical features you'd probably have to modify a lot of these materials by hand anyway if you wanted to port them to a non-Chaos game. It also could potentially cause issues with random things using pipe characters being interpreted as these, but I don't see that being a problem at all since pipes are a disallowed character in Windows filenames (which Source generally follows).

koerismo commented 2 years ago

./ could also stand in for |material_dir|

vrad-exe commented 2 years ago

Ah yeah, one advantage of the pipe replacement keys though is that they can be used in the middle of a line as well (or at least that should work...) So for example if I were using the Patch shader (which requires the full material path including materials/ and .vmt), I could do include "materials/|material_dir|base.vmt" or whatever.