2#include <score_plugin_gfx_export.h>
14struct camera_component;
26 float projection[16]{};
27 float viewProjection[16]{};
28 float cameraPosition[4]{};
29 float renderSize[4]{};
32static_assert(
sizeof(
CameraUBOData) == 240,
"CameraUBO layout must match shader");
36inline constexpr int64_t cameraAuxByteSize(std::size_t cameraCount)
noexcept
40 return (int64_t)((cameraCount < 1 ? 1 : cameraCount) *
sizeof(
CameraUBOData));
43inline void writeMat4(
float dst[16],
const QMatrix4x4& src)
45 std::memcpy(dst, src.constData(), 16 *
sizeof(
float));
61inline void setReverseZPerspective(
62 QMatrix4x4& out,
float fovYDeg,
float aspect,
float nearPlane,
66 if(nearPlane == farPlane || aspect == 0.f)
69 const float radians = (fovYDeg * 0.5f) *
float(M_PI / 180.0);
70 const float sine = std::sin(radians);
73 const float cotan = std::cos(radians) / sine;
74 const float clip = farPlane - nearPlane;
76 out(0, 0) = cotan / aspect;
78 out(2, 2) = (farPlane + nearPlane) / clip;
79 out(2, 3) = (2.f * farPlane * nearPlane) / clip;
96inline void setReverseZOrthographic(
97 QMatrix4x4& out,
float halfWidth,
float halfHeight,
float nearPlane,
101 if(nearPlane == farPlane || halfWidth == 0.f || halfHeight == 0.f)
104 const float clip = farPlane - nearPlane;
105 out(0, 0) = 1.f / halfWidth;
106 out(1, 1) = 1.f / halfHeight;
107 out(2, 2) = 2.f / clip;
108 out(2, 3) = (farPlane + nearPlane) / clip;
117enum class CameraProjectionMode :
int
128SCORE_PLUGIN_GFX_EXPORT
130 CameraUBOData& out,
const ossia::camera_component& cam,
131 const QMatrix4x4& worldTransform, QSize renderSize,
float timeSeconds,
132 float aspectOverride = -1.f);
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
Definition CameraMath.hpp:24