Unity3d camera to orthogonal camera interpolation

Source: Internet
Author: User

In fact, the effect is not very good, because many effects of delayed illumination do not support orthogonal, many later effects will be blown up, need to use as appropriate

by interpolating the projection matrix to achieve

If the far cross section of the perspective camera and the cross section of the orthogonal camera are too far off, the interpolation is very strange and needs attention.

Effect:

Code:

usingUnityengine;usingSystem.Collections; Public classprojectionlerp:monobehaviour{[Range (0,0.9f)]     Public floatLerp;  Public floatNearclip =-0.1f;  Public floatSize =3f; voidUpdate () {varRatio = Screen.width/(float) Screen.height; varA = Matrix4x4.perspective ( $, ratio,0.1f, 5000f); varb = Matrix4x4.ortho (-size * ratio, size * ratio,-size, size, nearclip, 5000f); Camera.main.projectionMatrix=Lerp (A, B, lerp); } matrix4x4 Lerp (matrix4x4 A, matrix4x4 B,floatlerp) {        varresult =Newmatrix4x4 (); Result. Setrow (0, Vector4.lerp (A.getrow (0), B.getrow (0) , lerp)); Result. Setrow (1, Vector4.lerp (A.getrow (1), B.getrow (1) , lerp)); Result. Setrow (2, Vector4.lerp (A.getrow (2), B.getrow (2) , lerp)); Result. Setrow (3, Vector4.lerp (A.getrow (3), B.getrow (3) , lerp)); returnresult; }}

Unity3d camera to orthogonal camera interpolation

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.