Skip to main content

polyscope_core/
options.rs

1//! Configuration options for polyscope.
2
3use glam::Vec4;
4use serde::{Deserialize, Serialize};
5
6use crate::SsaoConfig;
7
8/// Global configuration options for polyscope.
9#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct Options {
11    /// Whether to automatically compute scene extents.
12    pub auto_compute_scene_extents: bool,
13
14    /// Whether to invoke user callback during rendering.
15    pub invoke_user_callback_for_nested_show: bool,
16
17    /// Whether to give focus to the polyscope window.
18    pub give_focus_on_show: bool,
19
20    /// Whether the ground plane is enabled.
21    pub ground_plane_enabled: bool,
22
23    /// Ground plane mode (shadow, tile, etc.).
24    pub ground_plane_mode: GroundPlaneMode,
25
26    /// Ground plane height (world coordinates).
27    pub ground_plane_height: f32,
28
29    /// Background color.
30    pub background_color: Vec4,
31
32    /// Whether to enable transparency.
33    pub transparency_enabled: bool,
34
35    /// Transparency mode.
36    pub transparency_mode: TransparencyMode,
37
38    /// Number of render passes for depth-peeling transparency (Pretty mode).
39    pub transparency_render_passes: u32,
40
41    /// SSAA (supersampling) factor.
42    pub ssaa_factor: u32,
43
44    /// Maximum frames per second (0 = unlimited).
45    pub max_fps: u32,
46
47    /// SSAO configuration.
48    pub ssao: SsaoConfig,
49}
50
51impl Default for Options {
52    fn default() -> Self {
53        Self {
54            auto_compute_scene_extents: true,
55            invoke_user_callback_for_nested_show: false,
56            give_focus_on_show: true,
57            ground_plane_enabled: true,
58            ground_plane_mode: GroundPlaneMode::ShadowOnly,
59            ground_plane_height: 0.0,
60            background_color: Vec4::new(1.0, 1.0, 1.0, 1.0),
61            transparency_enabled: true,
62            transparency_mode: TransparencyMode::Simple,
63            transparency_render_passes: 8,
64            ssaa_factor: 1,
65            max_fps: 60,
66            ssao: SsaoConfig::default(),
67        }
68    }
69}
70
71/// Mode for the ground plane rendering.
72#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
73pub enum GroundPlaneMode {
74    /// No ground plane.
75    None,
76    /// Ground plane with shadow only.
77    #[default]
78    ShadowOnly,
79    /// Ground plane with tile pattern.
80    Tile,
81    /// Ground plane with solid color.
82    SolidColor,
83}
84
85/// Mode for transparency rendering.
86#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
87pub enum TransparencyMode {
88    /// Simple transparency (order-dependent, default).
89    #[default]
90    Simple,
91    /// Depth-peeled transparency - correct front-to-back ordering via multiple passes.
92    Pretty,
93    /// No transparency.
94    None,
95}