mirror of
https://codeberg.org/icewind/vmt-parser.git
synced 2026-06-03 20:14:06 +02:00
WorldVertexTransition
This commit is contained in:
parent
aac06e896b
commit
7cbbad871d
5 changed files with 152 additions and 1 deletions
|
|
@ -1,11 +1,13 @@
|
||||||
mod lightmappedgeneric;
|
mod lightmappedgeneric;
|
||||||
mod unlitgeneric;
|
mod unlitgeneric;
|
||||||
mod water;
|
mod water;
|
||||||
|
mod worldvertextransition;
|
||||||
|
|
||||||
pub use crate::material::unlitgeneric::UnlitGenericMaterial;
|
|
||||||
pub use lightmappedgeneric::LightMappedGenericMaterial;
|
pub use lightmappedgeneric::LightMappedGenericMaterial;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
pub use unlitgeneric::UnlitGenericMaterial;
|
||||||
pub use water::WaterMaterial;
|
pub use water::WaterMaterial;
|
||||||
|
pub use worldvertextransition::WorldVertexTransitionMaterial;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub enum Material {
|
pub enum Material {
|
||||||
|
|
@ -15,4 +17,6 @@ pub enum Material {
|
||||||
UnlitGeneric(UnlitGenericMaterial),
|
UnlitGeneric(UnlitGenericMaterial),
|
||||||
#[serde(rename = "water")]
|
#[serde(rename = "water")]
|
||||||
Water(WaterMaterial),
|
Water(WaterMaterial),
|
||||||
|
#[serde(rename = "worldvertextransition")]
|
||||||
|
WorldVertexTransition(WorldVertexTransitionMaterial),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
101
src/material/worldvertextransition.rs
Normal file
101
src/material/worldvertextransition.rs
Normal file
|
|
@ -0,0 +1,101 @@
|
||||||
|
use crate::{
|
||||||
|
default_detail_scale, default_scale, default_scale3, BlendMode, TextureTransform, Vec2, Vec3,
|
||||||
|
};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct WorldVertexTransitionMaterial {
|
||||||
|
/// The first texture in the blend.
|
||||||
|
#[serde(rename = "$basetexture")]
|
||||||
|
pub base_texture: String,
|
||||||
|
/// The second texture to blend to.
|
||||||
|
#[serde(rename = "$basetexture2")]
|
||||||
|
pub base_texture2: String,
|
||||||
|
/// Modulate the blending between materials using a special texture.
|
||||||
|
#[serde(rename = "$blendmodulatetexture")]
|
||||||
|
pub blend_modulate_texture: Option<String>,
|
||||||
|
/// Use this material as a decal.
|
||||||
|
#[serde(rename = "$decal", default)]
|
||||||
|
pub decal: bool,
|
||||||
|
/// Detail texturing.
|
||||||
|
#[serde(rename = "$detail")]
|
||||||
|
pub detail: Option<String>,
|
||||||
|
/// Links the surface to a set of physical properties.
|
||||||
|
#[serde(rename = "$surfaceprop")]
|
||||||
|
pub surface_prop: Option<String>,
|
||||||
|
|
||||||
|
/// Transforms the texture before use in the material. This does not affect lightmaps on the surface.
|
||||||
|
#[serde(rename = "$basetexturetransform", default)]
|
||||||
|
pub base_texture_transform: TextureTransform,
|
||||||
|
/// Independently scales the red, green and blue channels of an albedo.
|
||||||
|
#[serde(rename = "$color", default = "default_scale3")]
|
||||||
|
pub color: Vec3,
|
||||||
|
/// the number of units that each texel covers
|
||||||
|
#[serde(rename = "$decalscale", default = "default_scale")]
|
||||||
|
pub decal_scale: f32,
|
||||||
|
#[serde(rename = "$decalscale", default = "default_detail_scale")]
|
||||||
|
/// Fits the detail texture onto the material the given number of times
|
||||||
|
pub detail_scale: Vec2,
|
||||||
|
/// Controls the amount that the detail texture affects the base texture. The precise use of this depends on the blend factor; in most cases it acts similarly to $alpha. A value of 0 usually makes the detail texture have no effect, whilst a value of 1 applies the full effect.
|
||||||
|
#[serde(rename = "$detailblendfactor", default = "default_scale")]
|
||||||
|
pub detail_blend_factor: f32,
|
||||||
|
/// How to combine the detail material with the albedo.
|
||||||
|
#[serde(rename = "$detailblendmode", default)]
|
||||||
|
pub detail_blend_mode: BlendMode,
|
||||||
|
/// A separate VertexLitGeneric material to that will replace this one if the decal hits a model.
|
||||||
|
#[serde(rename = "$modelmaterial", default)]
|
||||||
|
pub model_material: Option<String>,
|
||||||
|
/// Disables texture filtering.
|
||||||
|
#[serde(rename = "$pointsamplemagfilter", default)]
|
||||||
|
pub point_sample_mag_filter: bool,
|
||||||
|
/// Mitigation for displacement texture stretching.
|
||||||
|
#[serde(rename = "$seamless_scale", default = "default_scale")]
|
||||||
|
pub seamless_scale: f32,
|
||||||
|
|
||||||
|
/// Scales the opacity of an entire material.
|
||||||
|
#[serde(rename = "$alpha", default = "default_scale")]
|
||||||
|
pub alpha: f32,
|
||||||
|
/// Specifies a mask to use to determine binary opacity.
|
||||||
|
#[serde(rename = "$alphatest", default)]
|
||||||
|
pub alpha_test: bool,
|
||||||
|
/// Vector-like edge filtering.
|
||||||
|
#[serde(rename = "$distancealpha", default)]
|
||||||
|
pub distance_alpha: bool,
|
||||||
|
/// Disables backface culling.
|
||||||
|
#[serde(rename = "$nocull", default)]
|
||||||
|
pub no_cull: bool,
|
||||||
|
/// Specifies that the material should be partially see-through.
|
||||||
|
#[serde(rename = "$translucent", default)]
|
||||||
|
pub translucent: bool,
|
||||||
|
|
||||||
|
/// bumpmap for the first texture.
|
||||||
|
#[serde(rename = "$bumpmap")]
|
||||||
|
pub bump_map: Option<String>,
|
||||||
|
/// bumpmap for the second texture.
|
||||||
|
#[serde(rename = "$bumpmap2")]
|
||||||
|
pub bump_map2: Option<String>,
|
||||||
|
/// Per-texel color modification via a warp texture.
|
||||||
|
#[serde(rename = "$lightwarptexture")]
|
||||||
|
pub light_wrap_texture: Option<String>,
|
||||||
|
/// Determines whether the surface is self-illuminated independent of environment lighting.
|
||||||
|
#[serde(rename = "$selfillum", default)]
|
||||||
|
pub self_illum: bool,
|
||||||
|
/// Flags the $bumpmap as being a self-shadowing bumpmap.
|
||||||
|
#[serde(rename = "$ssbump", default)]
|
||||||
|
pub ss_bump: bool,
|
||||||
|
|
||||||
|
/// Specular reflections.
|
||||||
|
#[serde(rename = "$envmap")]
|
||||||
|
pub env_map: Option<String>,
|
||||||
|
/// Diffuse reflections.
|
||||||
|
#[serde(rename = "$phong", default)]
|
||||||
|
pub phong: bool,
|
||||||
|
|
||||||
|
/// Prevents fog from overdrawing a material.
|
||||||
|
#[serde(rename = "$nofog", default)]
|
||||||
|
pub no_fog: bool,
|
||||||
|
|
||||||
|
/// Ignore z filtering
|
||||||
|
#[serde(rename = "$ignorez", default)]
|
||||||
|
pub ignore_z: bool,
|
||||||
|
}
|
||||||
10
tests/data/blendrocktograss002.vmt
Normal file
10
tests/data/blendrocktograss002.vmt
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
"WorldVertexTransition"
|
||||||
|
{
|
||||||
|
"$basetexture" "cp_mountainlab/nature/rockwall001"
|
||||||
|
"$basetexture2" "cp_mountainlab/nature/grass001"
|
||||||
|
"$blendmodulatetexture" "nature/grass_blendmask"
|
||||||
|
"$bumpmap" "nature/rockwall009_height-ssbump"
|
||||||
|
"$ssbump" "1"
|
||||||
|
"%keywords" "tf"
|
||||||
|
"$surfaceprop" "dirt"
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,7 @@ use vmt_parser::from_str;
|
||||||
#[test_case("tests/data/concretefloor003.vmt")]
|
#[test_case("tests/data/concretefloor003.vmt")]
|
||||||
#[test_case("tests/data/mvm_backpack.vmt")]
|
#[test_case("tests/data/mvm_backpack.vmt")]
|
||||||
#[test_case("tests/data/water_murky.vmt")]
|
#[test_case("tests/data/water_murky.vmt")]
|
||||||
|
#[test_case("tests/data/blendrocktograss002.vmt")]
|
||||||
fn test_serde(path: &str) {
|
fn test_serde(path: &str) {
|
||||||
let raw = read_to_string(path).unwrap();
|
let raw = read_to_string(path).unwrap();
|
||||||
match from_str(&raw) {
|
match from_str(&raw) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
---
|
||||||
|
source: tests/parse.rs
|
||||||
|
expression: result
|
||||||
|
---
|
||||||
|
worldvertextransition(WorldVertexTransitionMaterial(
|
||||||
|
r#$basetexture: "cp_mountainlab/nature/rockwall001",
|
||||||
|
r#$basetexture2: "cp_mountainlab/nature/grass001",
|
||||||
|
r#$blendmodulatetexture: Some("nature/grass_blendmask"),
|
||||||
|
r#$decal: false,
|
||||||
|
r#$detail: None,
|
||||||
|
r#$surfaceprop: Some("dirt"),
|
||||||
|
r#$basetexturetransform: "center 0.5 0.5 scale 1 1 rotate 0 translate 0 0",
|
||||||
|
r#$color: Vec3((1.0, 1.0, 1.0)),
|
||||||
|
r#$decalscale: 1.0,
|
||||||
|
r#$decalscale: Vec2((4.0, 4.0)),
|
||||||
|
r#$detailblendfactor: 1.0,
|
||||||
|
r#$detailblendmode: 1,
|
||||||
|
r#$modelmaterial: None,
|
||||||
|
r#$pointsamplemagfilter: false,
|
||||||
|
r#$seamless_scale: 1.0,
|
||||||
|
r#$alpha: 1.0,
|
||||||
|
r#$alphatest: false,
|
||||||
|
r#$distancealpha: false,
|
||||||
|
r#$nocull: false,
|
||||||
|
r#$translucent: false,
|
||||||
|
r#$bumpmap: Some("nature/rockwall009_height-ssbump"),
|
||||||
|
r#$bumpmap2: None,
|
||||||
|
r#$lightwarptexture: None,
|
||||||
|
r#$selfillum: false,
|
||||||
|
r#$ssbump: true,
|
||||||
|
r#$envmap: None,
|
||||||
|
r#$phong: false,
|
||||||
|
r#$nofog: false,
|
||||||
|
r#$ignorez: false,
|
||||||
|
))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue