Fix aspect ratio correction for intermediate rotation angles
Apply screen aspect ratio correction to offset.y (screen X direction) instead of offset.x (screen Y direction) in both linear and radial mode distance calculations. This fixes angle distortion at non-90° rotations in portrait mode. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
a99b6f222f
commit
a3ce90a2fe
1 changed files with 10 additions and 3 deletions
|
|
@ -29,6 +29,12 @@ float linearFocusDistance(vec2 uv) {
|
||||||
vec2 center = vec2(uPositionY, 1.0 - uPositionX);
|
vec2 center = vec2(uPositionY, 1.0 - uPositionX);
|
||||||
vec2 offset = uv - center;
|
vec2 offset = uv - center;
|
||||||
|
|
||||||
|
// Correct for screen aspect ratio to make coordinate space square
|
||||||
|
// After transform: offset.x = screen Y direction, offset.y = screen X direction
|
||||||
|
// Scale offset.y to match the scale of offset.x (height units)
|
||||||
|
float screenAspect = uResolution.x / uResolution.y;
|
||||||
|
offset.y *= screenAspect;
|
||||||
|
|
||||||
// Adjust angle by +90 degrees to compensate for the coordinate transformation
|
// Adjust angle by +90 degrees to compensate for the coordinate transformation
|
||||||
// The position transform is a 90° CW rotation, so angles transform as θ + 90°
|
// The position transform is a 90° CW rotation, so angles transform as θ + 90°
|
||||||
float adjustedAngle = uAngle + 1.5707963;
|
float adjustedAngle = uAngle + 1.5707963;
|
||||||
|
|
@ -49,10 +55,11 @@ float radialFocusDistance(vec2 uv) {
|
||||||
vec2 center = vec2(uPositionY, 1.0 - uPositionX);
|
vec2 center = vec2(uPositionY, 1.0 - uPositionX);
|
||||||
vec2 offset = uv - center;
|
vec2 offset = uv - center;
|
||||||
|
|
||||||
// Adjust for aspect ratio to create ellipse
|
// Correct for screen aspect ratio to make coordinate space square
|
||||||
// Correct for screen aspect ratio first
|
// After transform: offset.x = screen Y direction, offset.y = screen X direction
|
||||||
|
// Scale offset.y to match the scale of offset.x (height units)
|
||||||
float screenAspect = uResolution.x / uResolution.y;
|
float screenAspect = uResolution.x / uResolution.y;
|
||||||
offset.x *= screenAspect;
|
offset.y *= screenAspect;
|
||||||
|
|
||||||
// Apply rotation
|
// Apply rotation
|
||||||
// Adjust angle by +90 degrees to compensate for the coordinate transformation
|
// Adjust angle by +90 degrees to compensate for the coordinate transformation
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue