Repository navigation
Fix subtitles distorted by BopVisualEffects post-processing - #14
Conversation
…ects The canvas was being switched to ScreenSpaceCamera mode using the game's main camera, which has BopVisualEffects post-processing. This caused subtitles to be distorted by those effects. Changes: - TmpSubtitleOverlay: assign canvas to Unity's built-in UI layer (5), remove SetCamera() which was the path to ScreenSpaceCamera mode - SubtitleRuntimeController: remove RefreshSubtitleCamera() and its camera-tracking state (_cachedSubtitleCamera, _nextCameraResolveTime, CameraResolveIntervalSeconds); keep public ResolveSubtitleCamera() The canvas now permanently stays in ScreenSpaceOverlay mode, rendering directly to the screen without passing through any game camera. Co-authored-by: Brollyy <12004018+Brollyy@users.noreply.github.com>
|
@copilot this fix doesn't work, since in the editor, the camera where we want to show the subtitles is not full-screen |
…aceOverlay The ScreenSpaceOverlay fix didn't work in the Bits & Bops editor because the game camera is not full-screen - subtitles would appear over the entire screen rather than within the game viewport. New approach: create a dedicated BOP_SubtitleCameraHost camera that: - Has clearFlags=Depth (overlays without clearing background) - Has cullingMask=0 (renders no 3D scene objects, only the canvas) - Has depth=100 (renders after the main game camera) - Has no post-processing components (immune to BopVisualEffects) Canvas uses ScreenSpaceCamera mode with this overlay camera. RefreshSubtitleCamera() is restored to sync the overlay camera's viewport rect to the game camera's rect via SetReferenceCamera(), keeping subtitles within the game viewport in the editor. Co-authored-by: Brollyy <12004018+Brollyy@users.noreply.github.com>
Good catch. The The fix in
The |
There was a problem hiding this comment.
Pull request overview
This PR changes how subtitles are rendered so they’re no longer affected by BopVisualEffects post-processing, while still keeping subtitles confined to the game camera’s viewport in the editor (non-fullscreen game view).
Changes:
- Introduces a dedicated overlay camera host for subtitle UI rendering and switches the subtitle canvas to
RenderMode.ScreenSpaceCameratargeting that overlay camera. - Adds viewport-rect syncing via
TmpSubtitleOverlay.SetReferenceCamera()and updatesSubtitleRuntimeControllerto call it when resolving the active game camera.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
BopSubtitleReader/Core/TmpSubtitleOverlay.cs |
Creates a dedicated overlay camera and moves subtitle canvas rendering to ScreenSpaceCamera, adding viewport syncing. |
BopSubtitleReader/Core/SubtitleRuntimeController.cs |
Updates subtitle camera refresh logic to sync the overlay camera viewport against the resolved game camera. |
Comments suppressed due to low confidence (1)
BopSubtitleReader/Core/TmpSubtitleOverlay.cs:187
- Only the canvas root (
canvasObject) is assigned to the UI layer, but child objects created under it (e.g.,BOP_SubtitleTextand karaoke objects) remain on the default layer. If the overlay camera culls to UI-only (as it should), the text/children won’t render. Apply the UI layer to the full subtitle overlay hierarchy (or set layers as each child GameObject is created).
var canvasObject = new GameObject("BOP_SubtitleCanvas");
Object.DontDestroyOnLoad(canvasObject);
// Place on the UI layer so that game-world cameras cannot accidentally render it.
canvasObject.layer = 5; // Unity built-in "UI" layer
var canvas = canvasObject.AddComponent<Canvas>();
canvas.renderMode = RenderMode.ScreenSpaceCamera;
canvas.worldCamera = overlayCamera;
canvas.sortingOrder = 100;
_canvas = canvas;
var textObject = new GameObject("BOP_SubtitleText");
textObject.transform.SetParent(canvasObject.transform, false);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
…rectly after the changes.
The subtitle Canvas was being rendered through the game's main camera in
ScreenSpaceCameramode, causingBopVisualEffectspost-processing to be applied to subtitles. Additionally, the editor uses a non-full-screen game camera viewport, so the fix must keep subtitles confined to the game view rather than rendering over the entire screen.Changes
TmpSubtitleOverlay: Creates a dedicatedBOP_SubtitleCameraHostoverlayCamerawith no post-processing components (clearFlags=Depth,cullingMask=0,depth=100). The subtitle canvas usesScreenSpaceCameramode pointing at this overlay camera. A newSetReferenceCamera()method copies the game camera's viewportrectto the overlay camera so subtitles stay within the game view in the editor. Also assigns the canvas to Unity's built-in UI layer (5).SubtitleRuntimeController: RestoresRefreshSubtitleCamera()and its camera-tracking state (_cachedSubtitleCamera,_nextCameraResolveTime,CameraResolveIntervalSeconds). Now calls_overlay.SetReferenceCamera(resolvedCamera)instead of the old_overlay.SetCamera(resolvedCamera), syncing the overlay camera's viewport to the game camera's rect without routing rendering through the game camera.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.