Materials - H2xDev/GodotVMF GitHub Wiki

This plugin adds almost full VMT/VTF file support with some extensions. VMT files will be imported as regular StandardMaterial3D except some cases.

[!NOTE] If you create a Godot Material (*.tres) that has the same name and path as some *.vmt file then the importer will use the Godot's one instead.

You can convert all textures you need to VTF via VTFEdit Reloaded or you can use GodotVMF - Material Sync below

Additional properties for VMT for use in Godot

"LightmappedGeneric"
{
  $roughnesstexture "path_to_vtf"
  $metalnesstexture "path_to_vtf"
  $ambientocclusiontexture "path_to_vtf"
  $roughnessfactor 0.7
  $metallnessfactor 0.3
  $specularfactor 0.6
  $ambientocclusionlightaffect 0.43
  $detailblendmode 1 // See blend modes for detail textures of Godot Material
  $emissioncolor "0 255 0 255"
  $emissionenergy 10.3
  $emissionoperator 0 // 0 - add, 1 - multiply

  $shader "res://path_to_shader" // By specifying this VMT becomes a ShaderMaterial instead of StandardMaterial3D
  $nextpass "res://path_to_next_pass_shader" // Adds VMTShaderBasedMaterial into the `next_pass` property
}

Want to add support a new field for the material?

Create a singleton class named VMTExtend in @tool mode and define a function with a name of the property you need to have or override.

@tool
extends Node

func basetexture(material: Material, value: Variant):
  if "albedo_texture" not in material: return;
  material.albedo_texture = VTFLoader.get_texture(value);

func emissionenergy(material: Material, value: Variant):
  material.emission_energy_multiplier = value;

Shader materials

For ShaderMaterials (VMTs with $shader) all fields from VMT will be moved directly into uniforms:

shader_type spatial;

uniform sampler2D basetexture; // albedo
uniform sampler2D selfillummask; // emission map

void fragment() {
  ALBEDO = texture(basetexture, UV).rgb;
  EMISSION = texture(selfillummask, UV).rgb;
}

Material Sync

GodotVMF provides another one plugin called GodotVMF - Material Sync that automatically converts all godot materials placed in materials.target_folder into VMT/VTF to be able to see them in Hammer during development.

This plugin requires VTFCmd to work. Unpack the archive into your project folder (res://tools/vtfcmd for example), update the config file and turn the plugin on.

// vmf.config.json
{
    "vtfcmd": "res://tools/vtfcmd/VTFCmd.exe"
    ...
}