vmt_parser/material/
eyerefract.rs

1use super::deserialize_path;
2use crate::{default_scale, Vec3};
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct EyeRefractMaterial {
7    /// Usually referred to as a "sludge-layer", acts as a layer on top of the surface of the $AboveWater Material.
8    #[serde(rename = "$iris", deserialize_with = "deserialize_path")]
9    pub iris: String,
10    /// A texture to specify the shape of the cornea, similar to a normal map. Influences lighting and dilation. The red and green channels are used for the normal mapping, the blue channel is a mask for parallax mapping (straight multiply), and the alpha channel seems to be a multiplier for lighting. Because the $iris is warped in various ways the normals will not match 1-to-1 with the base texture.
11    #[serde(rename = "$corneatexture", deserialize_with = "deserialize_path")]
12    pub cornea_texture: String,
13    /// Strength of the $corneatexture.
14    #[serde(rename = "$corneabumpstrength", default = "default_scale")]
15    pub cornea_bump_strength: f32,
16    /// How much the viewing angle should influence the positioning of the eye
17    #[serde(rename = "$parallaxstrength", default = "default_parallax_strength")]
18    pub parallax_strength: f32,
19    /// Dilates the pupil using the cornea texture to determine the shape of dilation. Default 0.5.
20    #[serde(rename = "$dilation", default = "default_dilation")]
21    pub dilation: f32,
22
23    /// 1-dimensional texture which remaps lighting colors.
24    #[serde(rename = "$lightwarptexture", deserialize_with = "deserialize_path")]
25    pub light_warp_texture: String,
26    /// Enables cubemap reflections. This shader has a specific cubemap made for it, engine/eye-reflection-cubemap-.vtf, but others can be used, including env_cubemap.
27    #[serde(rename = "$envmap", deserialize_with = "deserialize_path")]
28    pub env_map: String,
29    /// The opacity of the cubemap reflection. Does not affect the eye glint. Default 0.5.
30    #[serde(rename = "$glossiness", default = "default_dilation")]
31    pub glossiness: f32,
32
33    /// An ambient occlusion texture overlaid onto the entire eye
34    #[serde(rename = "$ambientoccltexture", deserialize_with = "deserialize_path")]
35    pub ambient_occlusion_texture: String,
36    /// Tints the $ambientoccltexture
37    #[serde(rename = "$ambientocclcolor", default = "default_occl_color")]
38    pub ambient_occlusion_color: Vec3,
39    /// Strength of the dynamic ambient occlusion.
40    #[serde(rename = "$ambientocclusion", default = "default_scale")]
41    pub ambiento_cclusion: f32,
42
43    /// Enables half-lambertian lighting
44    #[serde(rename = "$halflambert", default)]
45    pub half_lambert: bool,
46    /// Enables sphere raytracing. Each pixel is raytraced to allow sharper angles to look more accurate.
47    #[serde(rename = "$raytracesphere", default)]
48    pub ray_trace_sphere: bool,
49    /// Requires $raytracesphere 1. Causes pixels which don't hit the raytraced sphere to be transparent, instead of rendering the "non-raytraced" eye behind it.
50    #[serde(rename = "$spheretexkillcombo", default)]
51    pub sphere_tex_kill_combo: bool,
52    /// Requires $raytracesphere 1. Radius of the eyeball. Should be the diameter of the eyeball divided by 2
53    #[serde(rename = "$eyeballradius", default = "default_dilation")]
54    pub eye_ball_radius: f32,
55}
56
57fn default_parallax_strength() -> f32 {
58    0.25
59}
60
61fn default_dilation() -> f32 {
62    0.5
63}
64
65fn default_occl_color() -> Vec3 {
66    Vec3([0.33; 3])
67}