51 halp_meta(name,
"Instancer")
52 halp_meta(category,
"Visuals/3D/Scene")
53 halp_meta(c_name,
"instancer")
54 halp_meta(description,
"Create GPU instances of a scene mesh using per-instance transforms, colors and custom data.")
55 halp_meta(authors,
"ossia team")
58 "https://ossia.io/score-docs/processes/instancer.html")
59 halp_meta(uuid,
"5e8a2c7f-9b4d-4e3a-a1c6-2d7f0b3e8c4a")
68 enum InstanceTransformMode
78 halp_meta(name,
"Scene In");
79 ossia::scene_spec scene;
83 halp::gpu_buffer_input<
"Transforms"> transforms;
84 halp::gpu_buffer_input<
"Colors"> colors;
85 halp::gpu_buffer_input<
"Custom"> custom;
95 halp_meta(name,
"Points");
96 halp::dynamic_gpu_geometry
mesh;
97 float transform[16]{};
98 bool dirty_mesh =
false;
99 bool dirty_transform =
false;
105 struct : halp::combobox_t<
"Format", TransformFormat>
109 std::string_view values[3]{
"mat4",
"trs",
"translation"};
112 void update(
Instancer& n) { n.rebuild(); }
115 struct : halp::spinbox_i32<
"Count", halp::irange{1, 1000000, 1}>
116 {
void update(
Instancer& n) { n.rebuild(); } } count;
122 {
void update(
Instancer& n) { n.rebuild(); } } position;
124 {
void update(
Instancer& n) { n.rebuild(); } } rotation;
126 {
void update(
Instancer& n) { n.rebuild(); } } scale;
128 struct : halp::combobox_t<
"Per-instance transform", InstanceTransformMode>
132 std::string_view values[2]{
"Full matrix",
"Translation only"};
135 void update(
Instancer& n) { n.rebuild(); }
143 halp_meta(name,
"Scene Out");
144 ossia::scene_spec scene;
156 void runInitialPasses(
172 QRhiBuffer* buffer{};
175 uint32_t components{};
180 uint32_t transform_kind{};
184 float proto_inverse_linear[16]{};
189 std::shared_ptr<ossia::scene_state> m_wrapped_state;
190 uint8_t m_pending_dirty{0xFF};
194 const ossia::scene_state* m_cached_in_state{};
203 int64_t byte_offset{};
207 static CachedView viewOf(
const halp::gpu_buffer& b)
noexcept
209 return {b.handle, (int64_t)b.byte_offset, (int64_t)b.byte_size};
211 CachedView m_cached_transforms{};
212 CachedView m_cached_colors{};
213 CachedView m_cached_custom{};
214 int32_t m_cached_count{-1};
215 int m_cached_format{-1};
219 void* m_cached_points_buf{};
220 int64_t m_cached_points_vertices{-1};
225 uintptr_t m_cached_points_fingerprint{};
226 int64_t m_version_counter{0};
229 ossia::gpu_slot_ref m_xform_ref{};
232 bool ensureBakeTarget(QRhiBuffer*& buf, quint32 bytes,
const char* name);
234 const BakeSource (&sources)[BakeSourceCount], uint32_t transform_kind,
235 uint32_t& count,
bool full,
const QMatrix4x4& proto);
240 QRhiBuffer* m_bakedTransforms{};
241 QRhiBuffer* m_bakedColors{};
242 QRhiBuffer* m_bakedCustom{};
243 QRhiBuffer* m_bakeParams{};
244 QRhiBuffer* m_bakeDummy{};
245 QRhiShaderResourceBindings* m_bakeSrb{};
246 QRhiComputePipeline* m_bakePipeline{};
247 bool m_bakeSrbDirty{
true};
248 bool m_warnedBakeFallback{};