Loading...
Searching...
No Matches
InjectTexture.hpp
1#pragma once
2#include <halp/controls.hpp>
3#include <halp/meta.hpp>
4#include <halp/texture.hpp>
5
6#include <ossia/dataflow/geometry_port.hpp>
7
8#include <cstdint>
9#include <memory>
10#include <string>
11
12namespace Threedim
13{
14
15// Mid-pipeline aux-texture injection. Takes a scene_spec passthrough
16// cable plus a live GPU texture from an upstream producer (video node,
17// ISF output, CSF image, etc.) and attaches it under a caller-supplied
18// name. ScenePreprocessor consumes `scene_state::inject_textures` and
19// writes matching `auxiliary_texture` entries onto its output
20// geometry — so the live handle flows to any downstream consumer
21// shader that declares an AUXILIARY texture entry with the same name.
22//
23// Texture handles are routed via halp::gpu_texture_input, which goes
24// through the Graph's TextureInlet / updateInputTexture() path — a
25// fundamentally different mechanism from InjectBuffer's
26// halp::gpu_buffer_input (which goes through bufferForInput / Output).
27// Hence the split into two distinct node types.
28//
29// Wiring:
30// VideoProducer → InjectTexture(name="base_color_dyn0")
31// → ScenePreprocessor → classic_pbr_full
33{
34public:
35 halp_meta(name, "Inject Texture")
36 halp_meta(category, "Visuals/3D/Scene")
37 halp_meta(c_name, "inject_texture")
38 halp_meta(description, "Attach a live GPU texture to a scene under a named auxiliary binding.")
39 halp_meta(authors, "ossia team")
40 halp_meta(
41 manual_url,
42 "https://ossia.io/score-docs/processes/inject-texture.html")
43 halp_meta(uuid, "3b8d2f7c-9a5e-4f1d-a4c6-6e2d9c4f8a1b")
44
45 struct ins
46 {
47 struct
48 {
49 halp_meta(name, "Scene In");
50 ossia::scene_spec scene;
51 uint8_t dirty{0};
52 } scene_in;
53
54 // Port-driven rebuild: aux_name triggers rebuild(). scene_in +
55 // texture handle changes detected in operator()() (no port-update
56 // event fires when a native handle is swapped).
57 // Live GPU texture from an upstream producer. Null handle → the
58 // injection is skipped (passthrough).
59 halp::gpu_texture_input<"Texture"> texture;
60
61 struct : halp::lineedit<"Aux name", "">
62 { void update(InjectTexture& n) { n.rebuild(); } } aux_name;
63 } inputs;
64
65 struct outs
66 {
67 struct
68 {
69 halp_meta(name, "Scene Out");
70 ossia::scene_spec scene;
71 uint8_t dirty{0};
72 } scene_out;
73 } outputs;
74
75 void rebuild();
76 void operator()();
77
78 std::shared_ptr<const ossia::scene_state> m_cached_out;
79 uint8_t m_pending_dirty{0xFF};
80 const ossia::scene_state* m_cached_in_state{};
81 // -2 is a sentinel no live input can produce (a null input reads as
82 // -1): it forces the first tick's rebuild without needing
83 // `!m_cached_out` as a trigger — a null cached output is legitimate
84 // whenever the input scene is null, and using it as a rebuild trigger
85 // re-dirties every tick of an unwired node.
86 int64_t m_cached_in_version{-2};
87 std::string m_cached_name;
88 void* m_cached_handle{};
89 int64_t m_version_counter{0};
90};
91
92}
Definition InjectTexture.hpp:33
Definition InjectTexture.hpp:46
Definition InjectTexture.hpp:66