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));
46inline constexpr std::size_t
47cameraPackIndex(std::size_t slot, std::size_t count,
int active)
noexcept
49 const std::size_t a = active < 0 ? 0u : std::size_t(active);
50 return count == 0 ? 0u : (a + slot) % count;
53inline void writeMat4(
float dst[16],
const QMatrix4x4& src)
55 std::memcpy(dst, src.constData(), 16 *
sizeof(
float));
71inline void setReverseZPerspective(
72 QMatrix4x4& out,
float fovYDeg,
float aspect,
float nearPlane,
76 if(nearPlane == farPlane || aspect == 0.f)
79 const float radians = (fovYDeg * 0.5f) *
float(M_PI / 180.0);
80 const float sine = std::sin(radians);
83 const float cotan = std::cos(radians) / sine;
84 const float clip = farPlane - nearPlane;
86 out(0, 0) = cotan / aspect;
88 out(2, 2) = (farPlane + nearPlane) / clip;
89 out(2, 3) = (2.f * farPlane * nearPlane) / clip;
106inline void setReverseZOrthographic(
107 QMatrix4x4& out,
float halfWidth,
float halfHeight,
float nearPlane,
111 if(nearPlane == farPlane || halfWidth == 0.f || halfHeight == 0.f)
114 const float clip = farPlane - nearPlane;
115 out(0, 0) = 1.f / halfWidth;
116 out(1, 1) = 1.f / halfHeight;
117 out(2, 2) = 2.f / clip;
118 out(2, 3) = (farPlane + nearPlane) / clip;
127enum class CameraProjectionMode :
int
139SCORE_PLUGIN_GFX_EXPORT
141 CameraUBOData& out,
const ossia::camera_component& cam,
142 const QMatrix4x4& worldTransform, QSize renderSize,
float timeSeconds,
143 float aspectOverride = -1.f);
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
Definition CameraMath.hpp:24