MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
NetworkTextureBuffer.hpp
Go to the documentation of this file.
1#pragma once
2
5
6namespace MayaFlux::Buffers {
7class UVFieldProcessor;
8}
9
10namespace MayaFlux::Buffers {
11
12/**
13 * @class NetworkTextureBuffer
14 * @brief NetworkGeometryBuffer extended with a GPU UV projection and texture sampling pass
15 *
16 * Inherits everything from NetworkGeometryBuffer and inserts a UVFieldProcessor
17 * as a postprocessor between geometry upload and rendering.
18 *
19 * Processing chain order per frame:
20 * 1. Default processor — NetworkGeometryProcessor (inherited, uploads vertices)
21 * 2. Postprocessor — UVFieldProcessor: writes UV at offset 28, optionally
22 * writes texture-sampled colour at offset 12
23 * 3. Final processor — RenderProcessor (inherited via setup_rendering)
24 *
25 * Usage is identical to NetworkGeometryBuffer plus UV configuration:
26 * @code
27 * auto tex = ImageReader::load_texture("noise.png");
28 * auto buffer = std::make_shared<NetworkTextureBuffer>(particles, tex);
29 * buffer->get_uv_processor()->set_projection(UVProjectionMode::CYLINDRICAL);
30 * buffer->get_uv_processor()->set_axis(glm::vec3(0.0F, 1.0F, 0.0F));
31 * buffer->get_uv_processor()->set_aux(2.0F);
32 * buffer->setup_processors(ProcessingToken::GRAPHICS_BACKEND);
33 * buffer->setup_rendering({ .target_window = window,
34 * .topology = PrimitiveTopology::POINT_LIST });
35 * @endcode
36 */
37class MAYAFLUX_API NetworkTextureBuffer : public NetworkGeometryBuffer {
38public:
39 /**
40 * @brief Create buffer from network with optional texture source
41 * @param network NodeNetwork providing geometry each frame
42 * @param texture Optional VKImage sampled in the UV compute pass
43 * @param binding_name Logical name for the geometry binding
44 * @param over_allocate_factor Buffer size multiplier for dynamic growth
45 */
46 explicit NetworkTextureBuffer(
47 std::shared_ptr<Nodes::Network::NodeNetwork> network,
48 std::shared_ptr<Core::VKImage> texture = nullptr,
49 const std::string& binding_name = "network_texture_geometry",
50 float over_allocate_factor = 2.0F);
51
52 ~NetworkTextureBuffer() override = default;
53
54 /**
55 * @brief Wire processors into the chain
56 *
57 * Calls NetworkGeometryBuffer::setup_processors, then adds
58 * UVFieldProcessor as a postprocessor.
59 */
60 void setup_processors(ProcessingToken token) override;
61
62 /**
63 * @brief Get the UV compute processor for configuration
64 */
65 [[nodiscard]] std::shared_ptr<UVFieldProcessor> get_uv_processor() const
66 {
67 return m_uv_processor;
68 }
69
70 /**
71 * @brief Replace the texture source at runtime
72 * @param image New VKImage (nullptr reverts to UV-only)
73 * @param config Sampler configuration
74 */
75 void set_texture(
76 std::shared_ptr<Core::VKImage> image,
77 const Portal::Graphics::SamplerConfig& config = {});
78
79private:
80 std::shared_ptr<UVFieldProcessor> m_uv_processor;
81};
82
83} // namespace MayaFlux::Buffers
IO::ImageData image
Specialized buffer for geometry from NodeNetwork instances.
std::shared_ptr< UVFieldProcessor > m_uv_processor
std::shared_ptr< UVFieldProcessor > get_uv_processor() const
Get the UV compute processor for configuration.
NetworkGeometryBuffer extended with a GPU UV projection and texture sampling pass.
ProcessingToken
Bitfield enum defining processing characteristics and backend requirements for buffer operations.