#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[non_exhaustive]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum DebugQuantity {
#[default]
Zero,
One,
CascadeIndex,
ShadowFactor,
ContactShadowFactor,
NdotL,
NormalBiasMagnitude,
AtlasUvX,
AtlasUvY,
TileUvX,
TileUvY,
BiasedDepth,
SurfaceDepth,
WorldNormalX,
WorldNormalY,
WorldNormalZ,
Roughness,
Metallic,
AoFactor,
DirectLightLuminance,
AmbientLuminance,
IblDiffuseLuminance,
IblSpecularLuminance,
EmissiveLuminance,
}
impl DebugQuantity {
pub fn index(self) -> u32 {
self as u32
}
pub fn all_variants() -> &'static [DebugQuantity] {
&[
DebugQuantity::Zero,
DebugQuantity::One,
DebugQuantity::CascadeIndex,
DebugQuantity::ShadowFactor,
DebugQuantity::ContactShadowFactor,
DebugQuantity::NdotL,
DebugQuantity::NormalBiasMagnitude,
DebugQuantity::AtlasUvX,
DebugQuantity::AtlasUvY,
DebugQuantity::TileUvX,
DebugQuantity::TileUvY,
DebugQuantity::BiasedDepth,
DebugQuantity::SurfaceDepth,
DebugQuantity::WorldNormalX,
DebugQuantity::WorldNormalY,
DebugQuantity::WorldNormalZ,
DebugQuantity::Roughness,
DebugQuantity::Metallic,
DebugQuantity::AoFactor,
DebugQuantity::DirectLightLuminance,
DebugQuantity::AmbientLuminance,
DebugQuantity::IblDiffuseLuminance,
DebugQuantity::IblSpecularLuminance,
DebugQuantity::EmissiveLuminance,
]
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[non_exhaustive]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum DebugOutputMode {
#[default]
Replace,
TintOverlay,
SplitScreen,
}
#[derive(Clone, Debug, Default)]
#[non_exhaustive]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DebugVis {
pub active: bool,
pub mode: DebugOutputMode,
pub channel_r: DebugQuantity,
pub channel_g: DebugQuantity,
pub channel_b: DebugQuantity,
pub scale: f32,
pub split_x: f32,
}
impl DebugVis {
pub fn new(
mode: DebugOutputMode,
channel_r: DebugQuantity,
channel_g: DebugQuantity,
channel_b: DebugQuantity,
scale: f32,
) -> Self {
Self {
active: true,
mode,
channel_r,
channel_g,
channel_b,
scale,
split_x: 0.5,
}
}
pub fn pack_mode(&self) -> u32 {
if !self.active {
return 0;
}
let r = self.channel_r.index() & 0x1f;
let g = self.channel_g.index() & 0x1f;
let b = self.channel_b.index() & 0x1f;
let m = match self.mode {
DebugOutputMode::Replace => 0u32,
DebugOutputMode::TintOverlay => 1u32,
DebugOutputMode::SplitScreen => 2u32,
};
(1u32 << 31) | (m << 15) | (b << 10) | (g << 5) | r
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[non_exhaustive]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum AtlasViewerCorner {
TopLeft,
TopRight,
BottomLeft,
#[default]
BottomRight,
}
#[non_exhaustive]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct EffectsDebug {
pub show_shadow_atlas: bool,
pub atlas_viewer_corner: AtlasViewerCorner,
pub atlas_viewer_scale: f32,
pub debug_vis: DebugVis,
pub force_cluster_fallback: bool,
pub cluster_stats_request: bool,
}
impl Default for EffectsDebug {
fn default() -> Self {
Self {
show_shadow_atlas: false,
atlas_viewer_corner: AtlasViewerCorner::BottomRight,
atlas_viewer_scale: 0.3,
debug_vis: DebugVis::default(),
force_cluster_fallback: false,
cluster_stats_request: false,
}
}
}