DistortionMesh class
Polynomial radial distortion for VR lens correction. Based on Google Cardboard SDK distortion algorithm.
Uses a pre-computed mesh grid to warp the rendered image to counteract the lens barrel distortion of VR headsets.
Constructors
-
DistortionMesh({List<
double> coefficients = const [0.441, 0.156], int resolution = 40, double screenToLensDistance = 0.042, double interLensDistance = 0.06}) - DistortionMesh.cardboardV1()
-
Google Cardboard V1 preset.
factory
- DistortionMesh.cardboardV2()
-
Google Cardboard V2 preset.
factory
- DistortionMesh.none()
-
No distortion (flat).
factory
Properties
-
coefficients
→ List<
double> -
Distortion coefficients (K1, K2, ...).
final
-
distortedPoints
↔ List<
Offset> -
Pre-computed distorted UV coordinates.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
- interLensDistance → double
-
Inter-lens distance in meters.
final
-
originalPoints
↔ List<
Offset> -
latefinal
- resolution → int
-
Grid resolution (default 40x40 like Cardboard SDK).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- screenToLensDistance → double
-
Screen-to-lens distance in meters.
final
Methods
-
applyToCanvas(
Canvas canvas, Size viewportSize, {bool isLeftEye = true}) → void - Draws the distortion mesh on a canvas, warping the source viewport. Call this AFTER rendering the scene to apply lens correction.
-
distort(
double nx, double ny) → Offset - Applies polynomial radial distortion.
-
distortionFactor(
double rSquared) → double -
inverseDistort(
double radius) → double - Computes inverse distortion using Secant method. Given a distorted radius, finds the undistorted radius.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited