Skip to content

Fix subtitles distorted by BopVisualEffects post-processing - #14

Merged
Brollyy merged 4 commits into
masterfrom
copilot/fix-subtitles-layer-issue
Mar 23, 2026
Merged

Brollyy merged 4 commits into
masterfrom
copilot/fix-subtitles-layer-issue

Conversation

Copilot AI commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

The subtitle Canvas was being rendered through the game's main camera in ScreenSpaceCamera mode, causing BopVisualEffects post-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 dedicated BOP_SubtitleCameraHost overlay Camera with no post-processing components (clearFlags=Depth, cullingMask=0, depth=100). The subtitle canvas uses ScreenSpaceCamera mode pointing at this overlay camera. A new SetReferenceCamera() method copies the game camera's viewport rect to 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: Restores RefreshSubtitleCamera() 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.
// Before: canvas rendered through the game camera → BopVisualEffects applied
canvas.renderMode = RenderMode.ScreenSpaceCamera;
canvas.worldCamera = gameCamera;  // ← post-processing applied here

// After: canvas rendered through a dedicated overlay camera → no post-processing
canvas.renderMode = RenderMode.ScreenSpaceCamera;
canvas.worldCamera = overlayCamera;  // ← separate camera, no BopVisualEffects
// overlayCamera.rect is synced to gameCamera.rect → correct viewport in editor
Original prompt

This section details on the original issue you should resolve

<issue_title>Subtitles are impacted by BopVisualEffects</issue_title>
<issue_description>Likely the Canvas is on the wrong layer - should be on UI layer if possible, to not be affected by camera transform.</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 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.

…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 AI changed the title [WIP] Fix subtitles impacted by BopVisualEffects Fix subtitles distorted by BopVisualEffects post-processing Mar 18, 2026
Copilot AI requested a review from Brollyy March 18, 2026 05:59
@Brollyy

Brollyy commented Mar 18, 2026

Copy link
Copy Markdown
Owner

@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>

Copilot AI commented Mar 18, 2026

Copy link
Copy Markdown
Contributor Author

@copilot this fix doesn't work, since in the editor, the camera where we want to show the subtitles is not full-screen

Good catch. The ScreenSpaceOverlay approach was too coarse — it renders across the entire screen regardless of viewport.

The fix in adbb452 creates a dedicated BOP_SubtitleCameraHost camera for the subtitle canvas. This camera:

  • Has no post-processing components → BopVisualEffects doesn't affect it
  • Uses ScreenSpaceCamera mode → subtitles are confined to the camera's viewport rect
  • SetReferenceCamera() copies the game camera's rect to the overlay camera each time it's resolved → in the editor the subtitle viewport tracks the game view, not the full screen

The RefreshSubtitleCamera() loop is restored and now calls _overlay.SetReferenceCamera(resolvedCamera) instead of the old SetCamera(resolvedCamera).

@Brollyy
Brollyy requested a review from Copilot March 18, 2026 06:16
@Brollyy
Brollyy marked this pull request as ready for review March 18, 2026 06:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ScreenSpaceCamera targeting that overlay camera.
  • Adds viewport-rect syncing via TmpSubtitleOverlay.SetReferenceCamera() and updates SubtitleRuntimeController to 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_SubtitleText and 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.

Comment thread BopSubtitleReader/Core/TmpSubtitleOverlay.cs Outdated
Comment thread BopSubtitleReader/Core/TmpSubtitleOverlay.cs
Comment thread BopSubtitleReader/Core/TmpSubtitleOverlay.cs Outdated
Comment thread BopSubtitleReader/Core/SubtitleRuntimeController.cs
@Brollyy
Brollyy merged commit ed31fda into master Mar 23, 2026
6 checks passed
@Brollyy
Brollyy deleted the copilot/fix-subtitles-layer-issue branch March 23, 2026 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Subtitles are impacted by BopVisualEffects

3 participants