mirror of
https://codeberg.org/icewind/vmt-parser.git
synced 2026-06-03 20:14:06 +02:00
water wip
This commit is contained in:
parent
12793d367c
commit
aac06e896b
5 changed files with 143 additions and 0 deletions
|
|
@ -1,9 +1,11 @@
|
|||
mod lightmappedgeneric;
|
||||
mod unlitgeneric;
|
||||
mod water;
|
||||
|
||||
pub use crate::material::unlitgeneric::UnlitGenericMaterial;
|
||||
pub use lightmappedgeneric::LightMappedGenericMaterial;
|
||||
use serde::{Deserialize, Serialize};
|
||||
pub use water::WaterMaterial;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum Material {
|
||||
|
|
@ -11,4 +13,6 @@ pub enum Material {
|
|||
LightMappedGeneric(LightMappedGenericMaterial),
|
||||
#[serde(rename = "unlitgeneric")]
|
||||
UnlitGeneric(UnlitGenericMaterial),
|
||||
#[serde(rename = "water")]
|
||||
Water(WaterMaterial),
|
||||
}
|
||||
|
|
|
|||
52
src/material/water.rs
Normal file
52
src/material/water.rs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
use crate::{default_scale, default_scale3, TextureTransform, Vec3};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct WaterMaterial {
|
||||
/// Usually referred to as a "sludge-layer", acts as a layer on top of the surface of the $AboveWater Material.
|
||||
#[serde(rename = "$basetexture")]
|
||||
pub base_texture: String,
|
||||
/// Tells this material is used for models and not brushes.
|
||||
#[serde(rename = "$abovewater", default)]
|
||||
pub above_water: bool,
|
||||
/// Required parameter. This is the material (not texture) to use when underneath the water’s surface. The bottom material must have $reflecttexture, $abovewater and $envmap disabled, but can otherwise do whatever it wants.
|
||||
#[serde(rename = "$bottommaterial")]
|
||||
pub bottom_material: Option<String>,
|
||||
/// Applies a refracting screen overlay when the camera is underwater. Generally used with effects\water_warp01. Requires $abovewater to be 0.
|
||||
#[serde(rename = "$underwaterover")]
|
||||
pub underwater_overlay: Option<String>,
|
||||
/// Specifies a texture that will provide three-dimensional lighting information for a material for DX8.
|
||||
#[serde(rename = "$bumpmap")]
|
||||
pub bump_map: Option<String>,
|
||||
/// A Du/dv map for DirectX 8 rendering ($bumpmap), and a bump map for DirectX 9 and above ($normalmap).
|
||||
#[serde(rename = "$normalmap")]
|
||||
pub normal_map: Option<String>,
|
||||
#[serde(rename = "$dudvframe", default)]
|
||||
pub du_dv_frame: u32,
|
||||
/// Frame to start the animated du/dv map and bump map on, respectively
|
||||
#[serde(rename = "$bumpframe", default)]
|
||||
pub dump_frame: u32,
|
||||
/// Transforms the bump map texture.
|
||||
#[serde(rename = "$bumptransform", default)]
|
||||
pub bump_transform: TextureTransform,
|
||||
/// Tints the results of projected textures on the water. The flashlight mainly affects the brigthness of the fog in the water.
|
||||
#[serde(rename = "$flashlighttint", default = "default_scale")]
|
||||
pub flash_light_tint: f32,
|
||||
|
||||
/// Enable volumetric fog for the water.
|
||||
#[serde(rename = "$fogenable", default)]
|
||||
pub fog_enable: bool,
|
||||
/// Color of the water’s volumetric fog. Generally this value should match the color used in the bottom material.
|
||||
#[serde(rename = "$fogenable", default = "default_scale3")]
|
||||
pub fog_color: Vec3,
|
||||
/// Distance in units/inches from the eye at which water fog starts.
|
||||
#[serde(rename = "$fogstart", default)]
|
||||
pub fog_start: f32,
|
||||
/// Distance in units/inches from the eye at which water fog ends.
|
||||
#[serde(rename = "$fogend", default)]
|
||||
pub fog_end: f32,
|
||||
/// Enable volumetric fog for the water.
|
||||
#[serde(rename = "$lightmapwaterfog", default)]
|
||||
pub light_map_water_fog: bool,
|
||||
// todo: https://developer.valvesoftware.com/wiki/Water_(shader) from reflection onward
|
||||
}
|
||||
65
tests/data/water_murky.vmt
Normal file
65
tests/data/water_murky.vmt
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
"Water"
|
||||
{
|
||||
|
||||
|
||||
"%keywords" "tf"
|
||||
// $forcecheap 1
|
||||
|
||||
"%tooltexture" "dev/tfwater_normal"
|
||||
"%compilewater" 1
|
||||
"$abovewater" 1
|
||||
// "$nofresnel" "1"
|
||||
|
||||
$underwateroverlay "effects/water_warp"
|
||||
"$envmap" "env_cubemap"
|
||||
"$refracttexture" "_rt_WaterRefraction"
|
||||
"$refractamount" ".12"
|
||||
// "$refracttint" "{88 192 44}"
|
||||
"$refractblur" "1"
|
||||
|
||||
|
||||
|
||||
"$scale" "[1 1]"
|
||||
|
||||
"$basetexture" "swamp/water/water_murky"
|
||||
// "$bumpmap" "water/water_dudv"
|
||||
"$normalmap" "water/tfwater001_normal"
|
||||
|
||||
"$surfaceprop" "water"
|
||||
"$bottommaterial" "swamp/water/water_murky_beneath.vmt"
|
||||
"$bumpframe" "0"
|
||||
|
||||
"$fogenable" 1
|
||||
"$fogcolor" "{35 32 20}"
|
||||
"$fogstart" "0"
|
||||
"$fogend" "170"
|
||||
|
||||
"$temp" "[0 0]"
|
||||
"$curr" 0.0
|
||||
"$curr2" 0.0
|
||||
|
||||
|
||||
"Proxies"
|
||||
{
|
||||
"AnimatedTexture"
|
||||
{
|
||||
"animatedtexturevar" "$normalmap"
|
||||
"animatedtextureframenumvar" "$bumpframe"
|
||||
"animatedtextureframerate" 30.00
|
||||
}
|
||||
|
||||
|
||||
"TextureScroll"
|
||||
{
|
||||
"texturescrollvar" "$bumptransform"
|
||||
"texturescrollrate" .01
|
||||
"texturescrollangle" 10.00
|
||||
}
|
||||
"WaterLOD"
|
||||
{
|
||||
// fixme! This has to be here, or material loading barfs.
|
||||
"dummy" 0
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ use vmt_parser::from_str;
|
|||
|
||||
#[test_case("tests/data/concretefloor003.vmt")]
|
||||
#[test_case("tests/data/mvm_backpack.vmt")]
|
||||
#[test_case("tests/data/water_murky.vmt")]
|
||||
fn test_serde(path: &str) {
|
||||
let raw = read_to_string(path).unwrap();
|
||||
match from_str(&raw) {
|
||||
|
|
|
|||
21
tests/snapshots/parse__tests__data__water_murky.vmt.snap
Normal file
21
tests/snapshots/parse__tests__data__water_murky.vmt.snap
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
source: tests/parse.rs
|
||||
expression: result
|
||||
---
|
||||
water(WaterMaterial(
|
||||
r#$basetexture: "swamp/water/water_murky",
|
||||
r#$abovewater: true,
|
||||
r#$bottommaterial: Some("swamp/water/water_murky_beneath.vmt"),
|
||||
r#$underwaterover: None,
|
||||
r#$bumpmap: None,
|
||||
r#$normalmap: Some("water/tfwater001_normal"),
|
||||
r#$dudvframe: 0,
|
||||
r#$bumpframe: 0,
|
||||
r#$bumptransform: "center 0.5 0.5 scale 1 1 rotate 0 translate 0 0",
|
||||
r#$flashlighttint: 1.0,
|
||||
r#$fogenable: true,
|
||||
r#$fogenable: Vec3((1.0, 1.0, 1.0)),
|
||||
r#$fogstart: 0.0,
|
||||
r#$fogend: 170.0,
|
||||
r#$lightmapwaterfog: false,
|
||||
))
|
||||
Loading…
Add table
Add a link
Reference in a new issue