Unity3d Lens Distortion and unity3d Lens Distortion
1. Fisheye distortion fish eye lens
Interpretation from Baidu Baike: A fish eye lens is a focal length of 16mm or shorter and the angle of view is close to or equal to 180 °. It is an extreme wide-angle lens, which is commonly known as a fish eye lens. In order to maximize the photographic angle of view, the diameter of the front lens of this photographic lens is very short and is displayed as a parabolic convex toward the front of the lens, quite similar to the eyes of the fish, this is why the "fish eye lens" is named.
The key code is as follows:
float2 fisheye(float2 uv){float2n_uv = (uv - 0.5) * 2.0;float2 r_uv;r_uv.x = (1 - n_uv.y * n_uv.y) * _Intensity_y * (n_uv.x);r_uv.y = (1 - n_uv.x * n_uv.x) * _Intensity_x * (n_uv.y);return(uv* _scale - r_uv);}
The effect is as follows:
2. Barrel Distortion bucket Distortion
Barrel Distortion (Barrel Distortion), also known as Barrel Distortion, is the Distortion of the imaging image that is caused by the physical properties of the lens in the lens and the lens structure. When using a wide-angle lens or a wide-angle end of a zoom lens, we are most likely to detect barrel distortion. When there is a straight line in the image (especially a straight line near the edge of the Photo Frame), the barrel distortion is the easiest to detect. The bucket Distortion Rate of common consumer-level digital cameras is usually 1%.
The key code is as follows:
float2 barrel(float2 uv){ float2 h = uv.xy - float2(0.5, 0.5);float r2 = h.x * h.x + h.y * h.y;float f = 1.0 + r2 * (_distortion + _cubicDistortion * sqrt(r2));return f * _scale * h + 0.5;}
The effect is as follows:
3. Pincushion Distortion pillow Distortion
Under the correct shooting conditions, the image of a rectangular object should still be rectangular. However, due to a defect in some lenses, the rectangular object is taken into an image with four sides inside and concave as a pillow.Pillowcase Distortion. On the contrary, a bucket distortion occurs when an image is shot with four sides highlighted.
Occipital distortion, also known as orthodontic variation, is caused by the magnification of the edge part of the field of view, which is higher than that of the center part. That is, the magnification of a light with a large angle is higher than that of a light with a smaller angle.
Change the bucket distortion parameter to pillow distortion.
The effect is as follows:
All code has been uploaded to GitHub
------ By wolf96 http://blog.csdn.net/wolf96
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.