citro3d/
fog.rs

1//! Fog/Gas unit configuration.
2
3/// Fog modes.
4#[repr(u8)]
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6#[doc(alias = "GPU_FOGMODE")]
7pub enum FogMode {
8    /// Fog/Gas unit disabled.
9    #[doc(alias = "GPU_NO_FOG")]
10    NoFog = ctru_sys::GPU_NO_FOG,
11
12    /// Fog/Gas unit configured in Fog mode.
13    #[doc(alias = "GPU_FOG")]
14    Fog = ctru_sys::GPU_FOG,
15
16    /// Fog/Gas unit configured in Gas mode.
17    #[doc(alias = "GPU_GAS")]
18    Gas = ctru_sys::GPU_GAS,
19}
20
21impl TryFrom<u8> for FogMode {
22    type Error = String;
23    fn try_from(value: u8) -> Result<Self, Self::Error> {
24        match value {
25            ctru_sys::GPU_NO_FOG => Ok(FogMode::NoFog),
26            ctru_sys::GPU_FOG => Ok(FogMode::Fog),
27            ctru_sys::GPU_GAS => Ok(FogMode::Gas),
28            _ => Err("invalid value for FogMode".to_string()),
29        }
30    }
31}
32
33/// Gas shading density source values.
34#[repr(u8)]
35#[derive(Debug, Clone, Copy, PartialEq, Eq)]
36#[doc(alias = "GPU_GASMODE")]
37pub enum GasMode {
38    /// Plain density.
39    #[doc(alias = "GPU_PLAIN_DENSITY")]
40    PlainDensity = ctru_sys::GPU_PLAIN_DENSITY,
41
42    /// Depth density.
43    #[doc(alias = "GPU_DEPTH_DENSITY")]
44    DepthDensity = ctru_sys::GPU_DEPTH_DENSITY,
45}
46
47impl TryFrom<u8> for GasMode {
48    type Error = String;
49    fn try_from(value: u8) -> Result<Self, Self::Error> {
50        match value {
51            ctru_sys::GPU_PLAIN_DENSITY => Ok(GasMode::PlainDensity),
52            ctru_sys::GPU_DEPTH_DENSITY => Ok(GasMode::DepthDensity),
53            _ => Err("invalid value for GasMode".to_string()),
54        }
55    }
56}
57
58/// Gas color LUT inputs.
59#[repr(u8)]
60#[derive(Debug, Clone, Copy, PartialEq, Eq)]
61#[doc(alias = "GPU_GASLUTINPUT")]
62pub enum GasLutInput {
63    /// Gas density used as input.
64    #[doc(alias = "GPU_GAS_DENSITY")]
65    Density = ctru_sys::GPU_GAS_DENSITY,
66
67    /// Light factor used as input.
68    #[doc(alias = "GPU_GAS_LIGHT_FACTOR")]
69    LightFactor = ctru_sys::GPU_GAS_LIGHT_FACTOR,
70}
71
72impl TryFrom<u8> for GasLutInput {
73    type Error = String;
74    fn try_from(value: u8) -> Result<Self, Self::Error> {
75        match value {
76            ctru_sys::GPU_GAS_DENSITY => Ok(GasLutInput::Density),
77            ctru_sys::GPU_GAS_LIGHT_FACTOR => Ok(GasLutInput::LightFactor),
78            _ => Err("invalid value for GasLutInput".to_string()),
79        }
80    }
81}
82
83/// Gas depth functions.
84#[repr(u8)]
85#[derive(Debug, Clone, Copy, PartialEq, Eq)]
86#[doc(alias = "GPU_GASDEPTHFUNC")]
87pub enum GasDepthFunction {
88    /// Never pass (0).
89    #[doc(alias = "GPU_GAS_NEVER")]
90    Never = ctru_sys::GPU_GAS_NEVER,
91
92    /// Always pass (1).
93    #[doc(alias = "GPU_GAS_ALWAYS")]
94    Always = ctru_sys::GPU_GAS_ALWAYS,
95
96    /// Pass if greater than (1-X).
97    #[doc(alias = "GPU_GAS_GREATER")]
98    Greater = ctru_sys::GPU_GAS_GREATER,
99
100    /// Pass if less than (X).
101    #[doc(alias = "GPU_GAS_LESS")]
102    Less = ctru_sys::GPU_GAS_LESS,
103}
104
105impl TryFrom<u8> for GasDepthFunction {
106    type Error = String;
107
108    fn try_from(value: u8) -> Result<Self, Self::Error> {
109        match value {
110            ctru_sys::GPU_GAS_NEVER => Ok(GasDepthFunction::Never),
111            ctru_sys::GPU_GAS_ALWAYS => Ok(GasDepthFunction::Always),
112            ctru_sys::GPU_GAS_GREATER => Ok(GasDepthFunction::Greater),
113            ctru_sys::GPU_GAS_LESS => Ok(GasDepthFunction::Less),
114            _ => Err("invalid value for GasDepthFunction".to_string()),
115        }
116    }
117}