Add focal X/Y coordinates to Zoom In and Zoom Out effects#27
Draft
Copilot wants to merge 3 commits into
Draft
Conversation
- Extend CameraZoomService to accept a focal point (NDC Vector2) per entry. Compute composite NDC translation as sum of per-entry focalNDC*(1-1/factor). Add CameraZoomOverlay MonoBehaviour (DefaultExecutionOrder 10) that applies the projection-matrix NDC shift in OnPreCull after CameraFlipOverlay (order 0), composing cleanly with flip effects and not conflicting with transform-based effects like Camera Shake. - Update ZoomInEffect and ZoomOutEffect to add focal_x=0.5 / focal_y=0.5 template properties, read them with a fallback (backwards compat), convert to NDC, and pass to CameraZoomService.SetFactor. - Add EntityExtensions.GetFloat(key, fallback) for reading optional properties absent in events created before this change. - Document focal_x/focal_y in docs/effects/README.md. Co-authored-by: Brollyy <12004018+Brollyy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add coordinates to zoom effects for flexible positioning
Add focal X/Y coordinates to Zoom In and Zoom Out effects
Mar 4, 2026
Brollyy
requested changes
Mar 4, 2026
| var zoomFactor = Mathf.Clamp(1f - _intensity * envelope, 0.01f, 1f); | ||
| CameraZoomService.SetFactor(_camera!, this, zoomFactor); | ||
|
|
||
| // Convert normalized screen coordinates [0, 1] to NDC [-1, 1]: |
Owner
There was a problem hiding this comment.
I don't see why we would need to use (0.5, 0.5) for users - (0, 0) for center makes more sense
Contributor
Author
There was a problem hiding this comment.
Changed in 31af111. Coordinate system is now (0, 0) = screen center, (±1, ±1) = screen corners (NDC space), with 0.0 as the default for both axes. The (x - 0.5) * 2 conversion was removed — values are now passed directly as NDC offsets.
- Template defaults changed from 0.5 to 0.0 - GetFloat fallbacks changed from 0.5f to 0.0f - Removed the (x - 0.5) * 2 conversion; values are now passed directly as NDC - Updated docs: (0,0) = center, ±1 = screen edges Co-authored-by: Brollyy <12004018+Brollyy@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Zoom effects previously always zoomed toward the screen center. This adds optional
focal_x/focal_yproperties so the zoom target can be any screen position, while defaulting to center for backwards compatibility.Approach
Focal-point offset is implemented as a projection-matrix NDC translation rather than a
transform.localPositionshift, which means:CameraFlipOverlay) via[DefaultExecutionOrder(10)]on the newCameraZoomOverlay, ensuring the focal shift is applied on top of any active flipPer-entry NDC contribution:
focalNDC × (1 − 1/factor)— keeps the focal point stationary as camera size changes. Contributions from concurrent zoom effects with different focal points are summed.Changes
CameraZoomService—SetFactorgains afocalNDCparameter (Vector2, defaults to(0,0)). AddsCameraZoomOverlayMonoBehaviour (one per camera) that applies the composite NDC translation inOnPreCulland resets inOnPostRender.ZoomInEffect/ZoomOutEffect— Addfocal_x/focal_ytemplate properties using NDC space:(0, 0)= screen center (default),(±1, ±1)= screen corners. Values are passed directly to the service with no conversion.EntityExtensions— AddsGetFloat(key, fallback)overload so old saved events withoutfocal_x/focal_ydefault to center zoom (0).docs/effects/README.md— Documentsfocal_x/focal_yfor both effects.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.