User Rating 0.0
Total Usage 0 times
Drop a PNG here or click to browse Max 20 MB • PNG, JPG, WebP
1.52
80
0.60
0.15
Presets:
Preview will appear here
Is this tool helpful?

Your feedback helps us improve.

About

Mapping a flat image onto a sphere requires solving the ray-surface intersection equation for every output pixel. A naive warp produces barrel distortion; a physically accurate approach traces refracted rays through a virtual glass sphere using Snell's law, where the refraction index n controls how light bends at the surface boundary. Getting this wrong produces flat-looking results indistinguishable from a cheap fisheye filter. This tool computes per-pixel surface normals, applies Phong specular reflection with configurable shininess exponent s, and uses bilinear interpolation to avoid aliasing artifacts at sub-pixel sample coordinates. The computation runs in a dedicated Web Worker thread so large images (up to 4096×4096) render without freezing your browser. Note: the model assumes a single point light source and uniform refractive medium. Real caustics and chromatic aberration are not simulated.

spherical effect png editor lens distortion sphere effect image distortion glass sphere refraction effect image editor

Formulas

For each output pixel at coordinates (x, y), we cast a ray from the camera and test intersection with a unit sphere. The parametric ray is:

P(t) = O + t D

where O is the ray origin and D is the normalized direction. The intersection discriminant is:

Δ = (D O)2 (|O|2 R2)

If Δ 0, the ray hits the sphere. At the hit point, the surface normal N equals the normalized position vector. The refracted direction follows Snell's law:

n1 sin(θ1) = n2 sin(θ2)

The refracted vector T is computed as:

T = η D + (η cos(θi) cos(θt)) N

where η = n1n2. The specular highlight uses the Phong model:

Ispec = ks (R V)s

where ks is specular intensity, R is the reflection of the light vector about the normal, V is the view direction, and s is the shininess exponent. Texture sampling uses bilinear interpolation across the four nearest integer pixel coordinates to avoid aliasing.

Reference Data

MaterialRefractive Index (n)Visual Effect
Vacuum / Air1.00No distortion (flat)
Water1.33Mild curvature
Crown Glass1.52Classic glass marble
Flint Glass1.62Dense optical glass
Crystal (Lead)1.80Strong refraction, sparkle
Cubic Zirconia2.15Gemstone-like bending
Diamond2.42Extreme distortion
Silicon3.50Inverted / mirrored
Germanium4.00Near-total internal reflection
Specular Exponent10 - 200Broad vs. sharp highlight spot
Ambient Light0.0 - 0.5Shadow depth on sphere edges
Small PNG (< 512px) - Renders in < 1s
Medium PNG (512-2048px) - Renders in 2 - 8s
Large PNG (2048-4096px) - Renders in 10 - 30s

Frequently Asked Questions

When the refractive index n exceeds approximately 2.0, refracted rays bend so sharply that they cross the optical axis before reaching the texture plane. This crossing produces an inverted (upside-down and mirrored) mapping of the source image, identical to viewing through a real glass sphere with high optical density. Diamond (n = 2.42) produces noticeable inversion.
The Phong specular exponent s controls the tightness of the highlight spot. At s = 10, the highlight is a broad, diffuse glow covering roughly 30% of the sphere surface. At s = 200, it contracts to a tiny, intense pinpoint simulating polished glass or metal. Real glass spheres typically fall between 50 and 120.
Rays that miss the sphere (discriminant Δ < 0) produce transparent pixels in the output PNG. The alpha channel is set to 0 for these pixels, preserving PNG transparency. You can optionally set a solid background color instead.
The algorithm computes a ray-sphere intersection, refraction vector, and bilinear texture sample for every single output pixel. A 4096×4096 image contains 16,777,216 pixels, each requiring approximately 15 - 20 floating-point operations. The Web Worker processes these sequentially. Doubling image dimensions quadruples render time.
Yes. The texture sampling reads all four channels (RGBA) from the source image. If a refracted ray samples a transparent region of the source, that transparency carries through to the output. Specular highlights are composited additively on top, so they appear even over transparent source regions.
In a real sphere, total internal reflection (TIR) occurs when the refracted ray inside the sphere hits the exit surface at an angle exceeding the critical angle θc = arcsin(1n). This tool handles TIR gracefully: when the discriminant for the exit refraction is negative, the pixel falls back to reflecting the environment (rendered as the ambient color), producing a darker ring near the sphere edges at high refractive indices.