vmt_parser/material/
refract.rs

1use super::deserialize_path;
2use crate::{
3    default_detail_scale, default_scale, default_scale3, BlendMode, TextureTransform, Vec2, Vec3,
4};
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct RefractMaterial {
9    /// The pattern of refraction is defined by a normal map (DX9+) or DUDV map (DX8-). May be animated.
10    #[serde(rename = "$normalmap", deserialize_with = "deserialize_path")]
11    pub normal_map: String,
12    /// The pattern of refraction is defined by a normal map (DX9+) or DUDV map (DX8-). May be animated.
13    #[serde(rename = "$dudvmap", default, deserialize_with = "deserialize_path")]
14    pub du_dv_map: Option<String>,
15    /// If a second normal map is specified, it will be blended with the first one.
16    #[serde(rename = "$normalmap2", default, deserialize_with = "deserialize_path")]
17    pub normal_map2: Option<String>,
18    /// Use a texture instead of rendering the view for the source of the distorted pixels.
19    #[serde(
20        rename = "$basetexture",
21        default,
22        deserialize_with = "deserialize_path"
23    )]
24    pub base_texture: Option<String>,
25    /// Transforms the bump map texture.
26    #[serde(rename = "$bumptransform", default)]
27    pub bump_transform: TextureTransform,
28    /// Transforms the bump map texture.
29    #[serde(rename = "$bumptransform2", default)]
30    pub bump_transform2: TextureTransform,
31
32    #[serde(rename = "$refracttint", default = "default_scale3")]
33    pub refract_tint: Vec3,
34    /// Tints the colour of the refraction either uniformly or per-texel. Can be used in conjunction with $refracttint
35    #[serde(
36        rename = "$refracttinttexture",
37        default,
38        deserialize_with = "deserialize_path"
39    )]
40    pub refract_tint_texture: Option<String>,
41    /// Controls the strength of the refraction by multiplying the normal map intensity.
42    #[serde(rename = "$refractamount", default = "default_scale")]
43    pub refract_amount: f32,
44    /// Adds a blur effect. Valid values are 0, 1 and 2 (0 and 1 for DX8-).
45    #[serde(rename = "$bluramount", default)]
46    pub blur_amount: f32,
47
48    #[serde(rename = "$decalscale", default = "default_detail_scale")]
49    /// Fits the detail texture onto the material the given number of times
50    pub detail_scale: Vec2,
51    /// 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.
52    #[serde(rename = "$detailblendfactor", default = "default_scale")]
53    pub detail_blend_factor: f32,
54    /// How to combine the detail material with the albedo.
55    #[serde(rename = "$detailblendmode", default)]
56    pub detail_blend_mode: BlendMode,
57    /// A separate VertexLitGeneric material to that will replace this one if the decal hits a model.
58    #[serde(
59        rename = "$modelmaterial",
60        default,
61        deserialize_with = "deserialize_path"
62    )]
63    pub model_material: Option<String>,
64    /// Disables texture filtering.
65    #[serde(rename = "$pointsamplemagfilter", default)]
66    pub point_sample_mag_filter: bool,
67    /// Mitigation for displacement texture stretching.
68    #[serde(rename = "$seamless_scale", default = "default_scale")]
69    pub seamless_scale: f32,
70
71    /// Scales the opacity of an entire material.
72    #[serde(rename = "$alpha", default = "default_scale")]
73    pub alpha: f32,
74    /// Specifies a mask to use to determine binary opacity.
75    #[serde(rename = "$alphatest", default)]
76    pub alpha_test: bool,
77    /// Specifies a mask to use to determine binary opacity.
78    #[serde(rename = "$alphatestreference", default = "default_scale")]
79    pub alpha_test_reference: f32,
80    /// Vector-like edge filtering.
81    #[serde(rename = "$distancealpha", default)]
82    pub distance_alpha: bool,
83    /// Disables backface culling.
84    #[serde(rename = "$nocull", default)]
85    pub no_cull: bool,
86    /// Specifies that the material should be partially see-through.
87    #[serde(rename = "$translucent", default)]
88    pub translucent: bool,
89
90    /// Specifies a texture that will provide three-dimensional lighting information for a material.
91    #[serde(rename = "$bumpmap", default, deserialize_with = "deserialize_path")]
92    pub bump_map: Option<String>,
93    /// Per-texel color modification via a warp texture.
94    #[serde(
95        rename = "$lightwarptexture",
96        default,
97        deserialize_with = "deserialize_path"
98    )]
99    pub light_wrap_texture: Option<String>,
100    /// Determines whether the surface is self-illuminated independent of environment lighting.
101    #[serde(rename = "$selfillum", default)]
102    pub self_illum: bool,
103    /// Flags the $bumpmap as being a self-shadowing bumpmap.
104    #[serde(rename = "$ssbump", default)]
105    pub ss_bump: bool,
106
107    /// Specular reflections.
108    #[serde(rename = "$envmap", default, deserialize_with = "deserialize_path")]
109    pub env_map: Option<String>,
110    #[serde(rename = "$envmaptint", default = "default_scale3")]
111    pub env_map_tint: Vec3,
112}