You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
differs from the .NET System.Numerics.Matrix4x4implementation:
publicstaticMatrix4x4CreatePerspectiveOffCenter(floatleft,floatright,floatbottom,floattop,floatnearPlaneDistance,floatfarPlaneDistance){if(nearPlaneDistance<=0.0f)thrownewArgumentOutOfRangeException("nearPlaneDistance");if(farPlaneDistance<=0.0f)thrownewArgumentOutOfRangeException("farPlaneDistance");if(nearPlaneDistance>=farPlaneDistance)thrownewArgumentOutOfRangeException("nearPlaneDistance");Matrix4x4result;result.M11=2.0f*nearPlaneDistance/(right-left);result.M12=result.M13=result.M14=0.0f;result.M22=2.0f*nearPlaneDistance/(top-bottom);result.M21=result.M23=result.M24=0.0f;result.M31=(left+right)/(right-left);result.M32=(top+bottom)/(top-bottom);// below is different**result.M33=farPlaneDistance/(nearPlaneDistance-farPlaneDistance);**result.M34=-1.0f;// below is different**result.M43=nearPlaneDistance*farPlaneDistance/(nearPlaneDistance-farPlaneDistance);**result.M41=result.M42=result.M44=0.0f;returnresult;}
In Unity M33 is: (far + near) * rcpdz
while System M33 is: result.M33 = farPlaneDistance / (nearPlaneDistance - farPlaneDistance);
In Unity M34 is: 2.0f * near * far * rcpdz
while System M43 is: result.M43 = nearPlaneDistance * farPlaneDistance / (nearPlaneDistance - farPlaneDistance);
Note that both matrices are transposed to each other; System Matrix can be thought of as rotating the coordinate system itself while Unity Matrix rotates the given vector.
The text was updated successfully, but these errors were encountered:
The Unity.Mathematics implementation of
PerspectiveOffCenter()
Linkdiffers from the .NET
System.Numerics.Matrix4x4
implementation:In Unity
M33
is:(far + near) * rcpdz
while System
M33
is:result.M33 = farPlaneDistance / (nearPlaneDistance - farPlaneDistance);
In Unity
M34
is:2.0f * near * far * rcpdz
while System
M43
is:result.M43 = nearPlaneDistance * farPlaneDistance / (nearPlaneDistance - farPlaneDistance);
Note that both matrices are transposed to each other; System Matrix can be thought of as rotating the coordinate system itself while Unity Matrix rotates the given vector.
The text was updated successfully, but these errors were encountered: