lygia
/space
/perspective
)create a perspective matrix
Use:
<mat4> perspective(<float> fov, <float> aspect, <float> near, <float> far);
#ifndef FNC_PERSPECTIVE
#define FNC_PERSPECTIVE
mat4 perspective(float fov, float aspect, float near, float far) {
float f = 1.0 / tan(fov / 2.0);
float nf = 1.0 / (near - far);
return mat4(
f / aspect, 0.0, 0.0, 0.0,
0.0, f, 0.0, 0.0,
0.0, 0.0, (far + near) * nf, -1.0,
0.0, 0.0, (2.0 * far * near) * nf, 0.0
);
}
#endif
Use:
<mat4> perspective(<float> fov, <float> aspect, <float> near, <float> far);
#ifndef FNC_PERSPECTIVE
#define FNC_PERSPECTIVE
mat4 perspective(float fov, float aspect, float near, float far) {
float f = 1.0 / tan(fov / 2.0);
float nf = 1.0 / (near - far);
return mat4(
f / aspect, 0.0, 0.0, 0.0,
0.0, f, 0.0, 0.0,
0.0, 0.0, (far + near) * nf, -1.0,
0.0, 0.0, (2.0 * far * near) * nf, 0.0
);
}
#endif
LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.
Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).
It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository