Several lens aberrations of Unity3d

Source: Internet
Author: User

1.Fisheye Distortion fish eye lens

Explanation from Baidu Encyclopedia: Fisheye 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, "fisheye lens" is its commonly known. In order to achieve the maximum photographic angle of view, the lens's front lens is short in diameter and protruding from the front of the lens, similar to the fish's eyes, hence the name "Fisheye Lens".

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 this:




2.Barrel Distortion Barrel-shaped distortion

Barrel distortion (barrel Distortion), also known as barrel distortion, is caused by the lens physical properties and lens group structure of the imaging picture is a barrel-shaped swelling distortion phenomenon. We are most likely to detect barrel distortion when using a wide-angle lens or with a zoom lens. Barrel distortion is most noticeable when there is a line in the picture (especially a straight line near the edge of the frame). Typical consumer-grade digital cameras have a barrel distortion rate of 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 * (_dist Ortion + _cubicdistortion * sqrt (R2)); return f * _scale * H + 0.5;}



The effect is this:



3.Pincushion Distortion Pillow Shape Distortion

Under the correct shooting conditions, the image of the rectangular object should still be rectangular. But some of the lens due to defects, the rectangular object into a four-sided concave shape like a pillow image, called the lens of this aberration is the occipital shape . On the contrary, the image is called barrel distortion.

The occipital distortion is also called positive distortion, because the magnification of the edge part of the field of view is higher than that of the center part, that is, the magnification of the light with large tilt angle is higher than that of the light with a small inclination angle.

the modification of the barrel distortion parameter is the shape of the occipital distortion .

The effect is this:



All code has been uploaded to GitHub

------by wolf96 http://blog.csdn.net/wolf96


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Several lens aberrations of Unity3d

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.