Add 2D focus positioning, fix rotation tracking, sync preview with effect
2D positioning: - Add positionX parameter to BlurParameters (was only Y before) - Update shader with uPositionX and uPositionY uniforms - Single-finger drag now moves focus center anywhere on screen - Update gradient mask generation for capture Rotation tracking: - Remove dampening from rotation gesture (1:1 tracking) - Rotate gesture now directly tracks finger movement - Preview effect rotates in sync with overlay Overlay and shader sync: - Both now use same positionX, positionY, angle parameters - Preview blur effect matches overlay visualization Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
e3e05af0b8
commit
e53155e8ee
5 changed files with 53 additions and 41 deletions
|
|
@ -10,7 +10,8 @@ uniform samplerExternalOES uTexture;
|
|||
|
||||
// Effect parameters
|
||||
uniform float uAngle; // Rotation angle in radians
|
||||
uniform float uPosition; // Center position of focus (0-1)
|
||||
uniform float uPositionX; // Horizontal center of focus (0-1)
|
||||
uniform float uPositionY; // Vertical center of focus (0-1)
|
||||
uniform float uSize; // Size of in-focus region (0-1)
|
||||
uniform float uBlurAmount; // Maximum blur intensity (0-1)
|
||||
uniform vec2 uResolution; // Texture resolution for proper sampling
|
||||
|
|
@ -19,15 +20,15 @@ varying vec2 vTexCoord;
|
|||
|
||||
// Calculate signed distance from the focus line
|
||||
float focusDistance(vec2 uv) {
|
||||
// Rotate coordinate system around center
|
||||
vec2 center = vec2(0.5, uPosition);
|
||||
vec2 rotated = uv - center;
|
||||
// Center point of the focus region
|
||||
vec2 center = vec2(uPositionX, uPositionY);
|
||||
vec2 offset = uv - center;
|
||||
|
||||
float cosA = cos(uAngle);
|
||||
float sinA = sin(uAngle);
|
||||
|
||||
// After rotation, measure vertical distance from center line
|
||||
float rotatedY = -rotated.x * sinA + rotated.y * cosA;
|
||||
// After rotation, measure perpendicular distance from center line
|
||||
float rotatedY = -offset.x * sinA + offset.y * cosA;
|
||||
|
||||
return abs(rotatedY);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue