//! Fullscreen post-process effect assets under `assets/post_fx/`.

use serde::{Deserialize, Serialize};

/// Built-in effect kinds shipped with sample WGSL shaders.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum PostProcessEffectKind {
    #[default]
    Vignette,
    ChromaticAberration,
}

/// RON asset describing a fullscreen post effect.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PostProcessEffectAsset {
    pub label: String,
    pub kind: PostProcessEffectKind,
    /// WGSL path relative to `assets/`.
    pub shader: String,
    pub intensity: f32,
    pub radius: f32,
}

impl PostProcessEffectAsset {
    pub fn load_from_path(catalog_path: &str) -> Result<Self, String> {
        let text = std::fs::read_to_string(catalog_path)
            .map_err(|err| format!("could not read {catalog_path}: {err}"))?;
        ron::from_str(&text).map_err(|err| format!("invalid post FX RON in {catalog_path}: {err}"))
    }
}
