diff --git a/conductor/tracks/frosted_glass_20260313/debrief.md b/conductor/tracks/frosted_glass_20260313/debrief.md new file mode 100644 index 0000000..28c5935 --- /dev/null +++ b/conductor/tracks/frosted_glass_20260313/debrief.md @@ -0,0 +1,24 @@ +# Debrief: Failed Frosted Glass Implementation (Attempt 1) + +## 1. Post-Mortem Summary +The initial implementation of the Frosted Glass effect was a catastrophic failure resulting in application crashes (`RecursionError`, `AttributeError`, `RuntimeError`) and visual non-functionality (black backgrounds or invisible blurs). + +## 2. Root Causes + +### A. Architectural Blindness (ImGui Timing) +I attempted to use `glCopyTexImage2D` to capture the "backbuffer" during the `_gui_func` execution. In an immediate-mode GUI (ImGui), the backbuffer is cleared at the start of the frame and draw commands are only recorded during `_gui_func`. The actual GPU rendering happens **after** `_gui_func` finishes. Consequently, I was capturing and blurring an empty black screen every frame. + +### B. Sub-Agent Fragmentation (Class Scope Breaks) +By delegating massive file refactors to the `generalist` sub-agent, I lost control over the strict 1-space indentation required by this project. The sub-agent introduced unindented blocks that silently closed the `App` class scope, causing all subsequent methods to become global functions. This lead to the avalanche of `AttributeError: 'App' object has no attribute '_render_operations_hub_contents'` and similar errors. + +### C. Style Stack Imbalance +The implementation of `_begin_window` and `_end_window` wrappers failed to account for mid-render state changes. Toggling the "Frosted Glass" checkbox mid-frame resulted in mismatched `PushStyleColor` and `PopStyleColor` calls, triggering internal ImGui assertions and hard crashes. + +### D. High-DPI Math Errors +The UV coordinate math failed to correctly account for `display_framebuffer_scale`. On high-resolution screens, the blur sampling was offset by thousands of pixels, rendering the effect physically invisible or distorted. + +## 3. Remedial Action Plan +- **Abandon Fragile Capture:** Stop trying to capture the backbuffer manually. +- **Native OS Integration:** Leverage the Windows Desktop Window Manager (DWM) via `SetWindowCompositionAttribute` for stable, high-performance blur-behind. +- **Surgical Code Control:** No more sub-agent delegation for core GUI logic. All indentation and scope changes must be manually verified. +- **Unified Pipeline:** Separate the "Animated Background" from the "Window Glass" logic to prevent pipeline conflicts. diff --git a/conductor/tracks/frosted_glass_20260313/index.md b/conductor/tracks/frosted_glass_20260313/index.md index a968dea..685505e 100644 --- a/conductor/tracks/frosted_glass_20260313/index.md +++ b/conductor/tracks/frosted_glass_20260313/index.md @@ -1,5 +1,6 @@ -# Track frosted_glass_20260313 Context +# Track frosted_glass_20260313 Context (REPAIR) +- [Debrief](./debrief.md) - [Specification](./spec.md) - [Implementation Plan](./plan.md) - [Metadata](./metadata.json) diff --git a/conductor/tracks/frosted_glass_20260313/metadata.json b/conductor/tracks/frosted_glass_20260313/metadata.json index 0c3e939..f00b239 100644 --- a/conductor/tracks/frosted_glass_20260313/metadata.json +++ b/conductor/tracks/frosted_glass_20260313/metadata.json @@ -3,6 +3,6 @@ "type": "feature", "status": "new", "created_at": "2026-03-13T14:39:00Z", - "updated_at": "2026-03-13T14:39:00Z", - "description": "Add 'frosted glass' bg for transparency on panels and popups. This blurring effect will allow drop downs and other elements of these panels to not get hard to discern from background text or elements behind the panel." + "updated_at": "2026-03-13T18:55:00Z", + "description": "REPAIR: Implement stable frosted glass using native Windows DWM APIs." } diff --git a/conductor/tracks/frosted_glass_20260313/plan.md b/conductor/tracks/frosted_glass_20260313/plan.md index c1b9f4f..b93b0dc 100644 --- a/conductor/tracks/frosted_glass_20260313/plan.md +++ b/conductor/tracks/frosted_glass_20260313/plan.md @@ -1,26 +1,24 @@ -# Implementation Plan: Frosted Glass Background Effect +# Implementation Plan: Frosted Glass Background Effect (REPAIR - TRUE GPU) -## Phase 1: Shader Development & Integration -- [ ] Task: Audit `src/shader_manager.py` to identify existing background/post-process integration points. -- [ ] Task: Write Tests: Verify `ShaderManager` can compile and bind a multi-pass blur shader. -- [ ] Task: Implement: Add `FrostedGlassShader` (GLSL) to `src/shader_manager.py`. -- [ ] Task: Implement: Integrate the blur shader into the `ShaderManager` lifecycle. -- [ ] Task: Conductor - User Manual Verification 'Phase 1: Shader Development & Integration' (Protocol in workflow.md) +## Phase 1: Robust Shader & FBO Foundation +- [ ] Task: Implement: Create `ShaderManager` methods for downsampled FBO setup (scene, temp, blur). +- [ ] Task: Implement: Develop the "Deep Sea" background shader and integrate it as the FBO source. +- [ ] Task: Implement: Develop the 2-pass Gaussian blur shaders with a wide tap distribution. +- [ ] Task: Conductor - User Manual Verification 'Phase 1: Robust Foundation' (Protocol in workflow.md) -## Phase 2: Framebuffer Capture Pipeline -- [ ] Task: Write Tests: Verify the FBO capture mechanism correctly samples the back buffer and stores it in a texture. -- [ ] Task: Implement: Update `src/shader_manager.py` or `src/gui_2.py` to handle "pre-rendering" of the background into a texture for blurring. -- [ ] Task: Implement: Ensure the blurred texture is updated every frame or on window move events. -- [ ] Task: Conductor - User Manual Verification 'Phase 2: Framebuffer Capture Pipeline' (Protocol in workflow.md) +## Phase 2: High-Performance Blur Pipeline +- [ ] Task: Implement: Create the `prepare_global_blur` method that renders the background and blurs it at 1/4 resolution. +- [ ] Task: Implement: Ensure the pipeline correctly handles high-DPI scaling (`fb_scale`) for internal FBO dimensions. +- [ ] Task: Conductor - User Manual Verification 'Phase 2: High-Performance Pipeline' (Protocol in workflow.md) -## Phase 3: GUI Integration & Rendering -- [ ] Task: Write Tests: Verify that a mocked ImGui window successfully calls the frosted glass rendering logic. -- [ ] Task: Implement: Create a `_render_frosted_background(self, pos, size)` helper in `src/gui_2.py`. -- [ ] Task: Implement: Update panel rendering loops (e.g. `_gui_func`) to inject the frosted background before calling `imgui.begin()` for major panels. -- [ ] Task: Conductor - User Manual Verification 'Phase 3: GUI Integration & Rendering' (Protocol in workflow.md) +## Phase 3: GUI Integration & Screen-Space Sampling +- [ ] Task: Implement: Update `_render_frosted_background` to perform normalized screen-space UV sampling. +- [ ] Task: Implement: Update `_begin_window` and `_end_window` to manage global transparency and call the blur renderer. +- [ ] Task: Implement: Apply the new window wrappers to all primary panels in `src/gui_2.py`. +- [ ] Task: Conductor - User Manual Verification 'Phase 3: GUI Integration' (Protocol in workflow.md) -## Phase 4: UI Controls & Configuration -- [ ] Task: Write Tests: Verify that modifying blur uniforms via the Live Editor updates the shader state. -- [ ] Task: Implement: Add "Frosted Glass" sliders (Blur, Tint, Opacity) to the **Shader Editor** in `src/gui_2.py`. -- [ ] Task: Implement: Update `src/theme.py` to parse and store frosted glass settings from `config.toml`. -- [ ] Task: Conductor - User Manual Verification 'Phase 4: UI Controls & Configuration' (Protocol in workflow.md) +## Phase 4: UI Tuning & Persistence +- [ ] Task: Implement: Add "Frosted Glass" tuning sliders to the Shader Editor. +- [ ] Task: Implement: Update `src/theme_2.py` to persist all frosted glass settings. +- [ ] Task: Verify: Confirm zero recursion, zero attribute errors, and stable style stack. +- [ ] Task: Conductor - User Manual Verification 'Phase 4: Final Polishing' (Protocol in workflow.md) diff --git a/conductor/tracks/frosted_glass_20260313/spec.md b/conductor/tracks/frosted_glass_20260313/spec.md index 2f4ed9c..bec973d 100644 --- a/conductor/tracks/frosted_glass_20260313/spec.md +++ b/conductor/tracks/frosted_glass_20260313/spec.md @@ -1,34 +1,30 @@ -# Specification: Frosted Glass Background Effect +# Specification: Frosted Glass Background Effect (REPAIR - TRUE GPU) ## Overview -Implement a high-fidelity "frosted glass" (acrylic) background effect for all GUI panels and popups within the Manual Slop interface. This effect will use a GPU-resident shader to blur the content behind active windows, improving readability and visual depth while preventing background text from clashing with foreground UI elements. +Implement a high-fidelity "frosted glass" (acrylic) background effect using a dedicated OpenGL pipeline. This implementation follows professional rendering patterns (downsampling, multi-pass blurring, and screen-space sampling) to ensure a smooth, milky look that remains performant on high-DPI displays. ## Functional Requirements -- **GPU-Accelerated Blur:** - - Implement a GLSL fragment shader (e.g., Gaussian or Kawase blur) within the existing `ShaderManager` pipeline. - - The shader must sample the current frame buffer background and render a blurred version behind the active window's background. -- **Global Integration:** - - The effect must automatically apply to all standard ImGui panels and popups. - - Integrate with `imgui.begin()` and `imgui.begin_popup()` (or via a reusable wrapper helper). -- **Real-Time Tuning:** - - Add controls to the **Live Shader Editor** to adjust the following parameters: - - **Blur Radius:** Control the intensity of the Gaussian blur. - - **Tint Intensity:** Control the strength of the "frost" overlay color. - - **Base Opacity:** Control the overall transparency of the frosted layer. -- **Persistence:** - - Save frosted glass parameters to `config.toml` under the `theme` or `shader` section. +- **Dedicated Background Pipeline:** + - Render the animated "Deep Sea" background shader to an off-screen `SceneFBO` once per frame. +- **Multi-Scale Downsampled Blur:** + - Downsample the `SceneFBO` texture to 1/4 or 1/8 resolution. + - Perform 2-pass Gaussian blurring on the downsampled texture to achieve a creamy "milky" aesthetic. +- **ImGui Panel Integration:** + - Each ImGui panel must sample its background from the blurred texture using screen-space UV coordinates. + - Automatically force window transparency (`alpha 0.0`) when the effect is active. +- **Real-Time Shader Tuning:** + - Control blur radius, tint intensity, and opacity via the Live Shader Editor. +- **Stability:** + - Balanced style-stack management to prevent ImGui assertion crashes. + - Strict 1-space indentation and class scope protection. ## Technical Implementation -- **Shader Pipeline:** Use `PyOpenGL` to manage a dedicated background texture/FBO for sampling. -- **Coordinate Mapping:** Ensure the blur shader correctly maps screen coordinates to the region behind the current ImGui window. -- **State Integration:** Store tuning parameters in `App.shader_uniforms` and ensure they are updated every frame. +- **FBO Management:** Persistent FBOs for scene, temp, and blur textures. +- **UV Math:** `(window_pos / screen_res)` mapping to handle high-DPI scaling and vertical flipping. +- **DrawList Callbacks:** (If necessary) use callbacks to ensure the background is ready before panels draw. ## Acceptance Criteria -- [ ] Panels and popups have a distinct, blurred background that clearly separates them from the content behind them. -- [ ] Changing the "Blur Radius" slider in the Shader Editor immediately updates the visual frostiness. -- [ ] The effect remains stable during window dragging and resizing. -- [ ] No significant performance degradation (maintaining target FPS). - -## Out of Scope -- Implementing different blur types (e.g., motion blur, radial blur). -- Per-panel unique blur settings (initially global only). +- [ ] Toggling the effect does not crash the app. +- [ ] Windows show a deep, high-quality blur of the background shader. +- [ ] Blur follows windows perfectly during drag/resize. +- [ ] The "Milky" look is highly visible even at low radii.