-
-
Notifications
You must be signed in to change notification settings - Fork 14
Materials
Radik edited this page Jan 1, 2025
·
29 revisions
This plugin adds almost full VMT/VTF file support with some extensions. VMT files will be imported as regular StandardMaterial3D except some cases.
"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.gdshader" // By specifying this VMT becomes a ShaderMaterial instead of StandardMaterial3D
$nextpass "res://path_to_next_pass_shader.gdshader" // Adds VMTShaderBasedMaterial into the `next_pass` property
}Create a singleton class named VMTExtend in @tool mode and define a function with a name of the property you need.
@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;This is a basic ShaderMaterial but also it passes texture parameters into a specified shader.
shader_type spatial;
uniform sampler2D albedo_texture; // Comes from VMT
uniform sampler2D emission_texture; // Comes from VMT
void fragment() {
ALBEDO = texture(albedo_texture, UV).rgb;
EMISSION = texture(emission_texture, UV).rgb;
}