← Back to Pull requests

Reduce pro-camera bokeh grain with a depth-guided resolve #115

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Oct 25, 2026 13:17 UTC
Author

What this changes

Reduce grain in the pro camera's defocused backgrounds and bokeh with a 5 x 5 resolve guided by depth and blur radius. Filtering fades in between blur radii of 1 and 3 pixels, preserving focused detail and foreground silhouettes. The existing nearest-sampled gather, 128-tap default and lens model stay unchanged; exposure and ACEScct encoding run after the resolve.

This affects the existing OpenBFME camera addition only. It adds one compute pass and an RGBA16F intermediate (about 15.8 MiB at 1080p). No simulation state or retail behaviour changes; the existing gather attribution is retained and the new code is GPL-3.0.
<img width="1472" height="960" alt="comparison" src="https://github.com/user-attachments/assets/972362ae-7717-4856-a763-1284e26d0e5d" />

How it was checked

  • Godot 4.7.2 Forward+ / Vulkan, Radeon RX 7900 XT: pro_camera_test.gd and new pro_camera_bokeh_test.gd pass on the final rebased branch.

  • Generated checkerboard, isolated lights and focused foreground: background RMS against a dense 2,048-tap reference drops from 0.00658 to 0.00139. Focused interior and silhouette match stopped-down output (RMS 0.0 on this GPU); viewport resizing passes. The reference uses the same resolve, so this measures sampling stability, not optical ground truth.

  • The grain regression fails with the original shader and passes with this change. Headless lens checks pass with GPU checks explicitly skipped (77).

  • Mandatory staged-file commit gate and git diff --check pass. No full C++ build or engine suite: changes are limited to the rendering script, its generated-scene test and documentation.

  • Local public-tree audit could not pass its Windows .gitmodules check; the tested base produced the same two diagnostics. CI still needs to confirm the public-tree audit.
  • GPU scene times, original versus this change (same scene, 128 taps; average of two run medians, 180 measured frames after 60 warm-up frames):

    | Internal resolution | Original | With resolve | Added |
    | --- | ---: | ---: | ---: |
    | 1920 x 1080 | 7.92 ms | 8.49 ms | 0.57 ms |
    | 2560 x 1440 | 15.36 ms | 15.94 ms | 0.58 ms |

    These are a mostly defocused generated scene on one GPU, not whole-game FPS. No in-game or moving-camera benchmark is claimed. The resolve can soften bokeh boundaries slightly and leaves some residual grain; it does not use temporal history.

    Checklist

  • Ran the commit gate on staged changes and through the installed pre-commit hook.

  • No STOPS changes; stop-count update not applicable.

  • No game assets, retail-derived captures, personal paths or install logs committed. Test images are generated at runtime.

  • New code may be published under GPL-3.0; existing source attribution retained.

  • Rendering-only OpenBFME addition; no retail simulation behaviour changed.
  • <!-- greptile_comment -->

    <!-- greptile_summary -->

    <h2><a href="https://app.greptile.com/api/retrigger?id=87649768"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a><a href="https://app.greptile.com/openbfme/github/Open-BFME/openbfme-godot/-/pull/115"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img alt="View in Greptile" src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2" align="right"></picture></a>Confidence Score: 4/5</h2>

    <!-- greptile-risk -->

    The PR appears safe to merge, with two non-blocking gaps in the new regression test.

    <h2>Findings</h2>

    1. <img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top">&nbsp;Disabled blur passes the test <a href="https://github.com/Open-BFME/openbfme-godot/pull/115#discussion_r4370986202">▶</a>
    2. <img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top">&nbsp;Resize check misses broken rendering <a href="https://github.com/Open-BFME/openbfme-godot/pull/115#discussion_r4370986204">▶</a>

    <details><summary>Fix with agent prompt</summary>

    `

    ### Issue 1
    godot/tests/pro_camera_bokeh_test.gd:113-116
    Both `after` and `reference` use the same effect. If a future change skips the gather in both renders, `background_error` becomes zero and this check passes. The focused checks also pass in that case. Add a check that the defocused background differs from stopped-down output, alongside the existing upper bound against the dense reference.
    
    ### Issue 2
    godot/tests/pro_camera_bokeh_test.gd:131-133
    This assertion checks the viewport image's size, not whether the effect's intermediate images followed the resize. `_capture` reads the viewport texture, which becomes 800 × 450 even if the effect stops drawing. Compare the resized result with a fresh effect at that size and check that blur remains visible, or directly check the intermediate image sizes.
    
    ---
    
    For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
    
    `

    </details>

    <h3>Summary</h3>

    Adds a depth- and blur-guided 5 × 5 resolve after the existing gather.

  • Defocused backgrounds look less grainy without softening focused detail.
  • <details open><summary><h3>Diagram</h3></summary>

    %%{init: {'theme': 'neutral'}}%%
    flowchart LR
      A[Frame copy] --> B{Depth of field enabled?}
      B -->|Yes| C[Tile reach and blur gather]
      C --> D[Separate blur image]
      D --> E[Depth-guided resolve]
      B -->|No| F[Read frame copy]
      E --> G[Exposure and optional log encoding]
      F --> G
      G --> H[Write frame]
    

    </details>

    <!-- greptile_confidence_score:4 -->

    <sub>Reviews (1) · Last reviewed commit: "Reduce pro-camera bokeh grain with a dep..." · Reviewed by Greptile</sub>

    <!-- /greptile_comment -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: greptile-apps[bot] Review duration: 11m
    All Vouch review confidence checks passed
    Residual risk 0.31 = Change Risk (0.52) × (1 − Review Confidence (0.40)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 72% · Reviewer familiarity: 35%
    39%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #115"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 39.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 39.8% · Lower = rushed or shallow review
    39.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 31.3% · Safe to merge
    31.3%