score
Home
Classes
Namespaces
Files
Loading...
Searching...
No Matches
SceneResourceRoute.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
11
namespace
Threedim
12
{
13
14
// Level 1 of the "resource → scene field" routing design. Takes a GPU
15
// texture handle from any upstream producer (CSF shader output, video,
16
// ISF post-pass, asset loader, …) and stamps it onto a named field of
17
// `scene_spec`. The emitted scene_spec is a partial contribution with
18
// only that one field populated — `merge_scenes` overlays it onto the
19
// rest of the scene_state the ScenePreprocessor receives from other
20
// producers, so this node composes freely with EnvironmentLoader /
21
// CubemapLoader / further SceneResourceRoute instances.
22
//
23
// Core use case is IBL wiring: an irradiance-convolution, GGX-prefilter
24
// or BRDF-LUT shader's output plugs in here and lands on
25
// `scene_environment.{irradiance_map, prefiltered_map, brdf_lut}` with
26
// no per-target glue code. Shadow-map generation passes will target
27
// `scene_state.shadow_cascades.shadow_map_array` the same way.
28
//
29
// Pattern mirrors CubemapComposer / InjectTexture: CPU-side producer,
30
// port-driven rebuild + handle-change detection in operator()().
31
enum class
SceneResourceTarget :
int
32
{
33
Skybox,
// scene_environment.skybox_texture
34
IrradianceMap,
// scene_environment.irradiance_map
35
PrefilteredMap,
// scene_environment.prefiltered_map
36
BRDFLut,
// scene_environment.brdf_lut
37
ShadowMapArray,
// scene_state.shadow_cascades.shadow_map_array
38
};
39
40
class
SceneResourceRoute
41
{
42
public
:
43
halp_meta(name,
"Scene Resource Route"
)
44
halp_meta(category,
"Visuals/3D/Scene"
)
45
halp_meta(c_name,
"scene_resource_route"
)
46
halp_meta(authors,
"ossia team"
)
47
halp_meta(
48
manual_url,
49
"https://ossia.io/score-docs/processes/scene-resource-route.html"
)
50
halp_meta(uuid,
"c2f7a341-8e69-4b0d-b3f8-2d7e4c5a9f1b"
)
51
52
struct
ins
53
{
54
// Accepts any GPU texture kind — 2D, cubemap, array. Downstream
55
// consumer shaders (classic_pbr_ibl, classic_pbr_shadowed) declare
56
// their own sampler shape (samplerCube / sampler2DArray / sampler2D)
57
// and it's the authoring's responsibility to match the two.
58
halp::gpu_texture_input<
"Texture"
> texture;
59
60
// Port-driven rebuild: target changes fire rebuild(); upstream
61
// handle flips are caught by operator()() since the halp GPU-texture
62
// input doesn't emit a port-update event when only the native
63
// handle swaps.
64
struct : halp::enum_t<SceneResourceTarget,
"Target Field"
>
65
{
66
void
update(
SceneResourceRoute
& n) { n.rebuild(); }
67
} target;
68
} inputs;
69
70
struct
outs
71
{
72
struct
73
{
74
halp_meta(name,
"Scene"
);
75
ossia::scene_spec scene;
76
uint8_t dirty{0};
77
} scene_out;
78
} outputs;
79
80
void
rebuild();
81
void
operator()();
82
83
// Cached output scene_state — stable identity across frames (so
84
// downstream scene-identity caches stay hot) and mutated in place on
85
// target / handle changes.
86
std::shared_ptr<ossia::scene_state> m_state;
87
int64_t m_version{0};
88
void
* m_cached_handle{};
89
SceneResourceTarget m_cached_target{SceneResourceTarget::Skybox};
90
uint8_t m_pending_dirty{0xFF};
91
};
92
93
}
Threedim::SceneResourceRoute
Definition
SceneResourceRoute.hpp:41
Threedim::SceneResourceRoute::ins
Definition
SceneResourceRoute.hpp:53
Threedim::SceneResourceRoute::outs
Definition
SceneResourceRoute.hpp:71