MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
RaymarchBuffer.hpp
Go to the documentation of this file.
1#pragma once
2
4
6
7namespace MayaFlux::Buffers {
8
9/**
10 * @class RaymarchBuffer
11 * @brief Proxy box bounding a scalar field, drawn by a fragment stage that
12 * integrates the field along the view ray.
13 *
14 * A MeshBuffer holding the box Kinesis::generate_box produces over a
15 * Lattice3D's bounds. MeshProcessor uploads it and links the index buffer,
16 * so the geometry path is the ordinary indexed mesh path with nothing
17 * special about it. The image is produced entirely in the fragment stage;
18 * the box only rasterises the pixels the march covers.
19 *
20 * Owns no field. The field arrives through RaymarchProcessor's source
21 * callable, so a VolumeGridBuffer running its own simulation chain is
22 * untouched and its field is read where it lies.
23 *
24 * Back faces are rasterised rather than front, and the fragment stage
25 * clips ray entry against the box, so the volume survives the observer
26 * moving inside its bounds.
27 */
28class MAYAFLUX_API RaymarchBuffer : public MeshBuffer {
29public:
30 /**
31 * @brief Construct proxy geometry over a lattice.
32 * @param lattice Extent the box spans and the field is stored over.
33 * @param source Callable resolving the field handle each cycle.
34 * @param field_bytes Byte size of one slot of that field.
35 */
37 Kinesis::Lattice3D lattice,
39 size_t field_bytes);
40
41 ~RaymarchBuffer() override = default;
42
43 /**
44 * @brief Attach MeshProcessor for upload and RaymarchProcessor for staging.
45 * @param token Processing domain, normally GRAPHICS_BACKEND.
46 */
47 void setup_processors(ProcessingToken token) override;
48
49 /**
50 * @brief Attach a RenderProcessor drawing the proxy box.
51 * @param config Render target. Shaders default to the raymarch pair.
52 *
53 * Culls front faces and disables depth writes: a proxy box that writes
54 * depth occludes every later volume at the same geometry.
55 */
56 void setup_rendering(const RenderConfig& config);
57
58 /** @brief The march staging stage, valid after setup_processors. */
59 [[nodiscard]] std::shared_ptr<RaymarchProcessor> march_processor() const { return m_march_processor; }
60
61 /** @brief The lattice the box spans. */
62 [[nodiscard]] const Kinesis::Lattice3D& get_lattice() const { return m_lattice; }
63
64private:
68
69 std::shared_ptr<RaymarchProcessor> m_march_processor;
70};
71
72} // namespace MayaFlux::Buffers
VKBuffer subclass that owns a MeshData and manages its GPU upload.
~RaymarchBuffer() override=default
std::shared_ptr< RaymarchProcessor > m_march_processor
RaymarchProcessor::FieldSource m_source
const Kinesis::Lattice3D & get_lattice() const
The lattice the box spans.
std::shared_ptr< RaymarchProcessor > march_processor() const
The march staging stage, valid after setup_processors.
Proxy box bounding a scalar field, drawn by a fragment stage that integrates the field along the view...
std::function< vk::Buffer()> FieldSource
Callable resolving the handle to sample this cycle.
ProcessingToken
Bitfield enum defining processing characteristics and backend requirements for buffer operations.
A regular subdivision of an AABB3D into a cell count per axis.
Definition Lattice.hpp:25
Unified rendering configuration for graphics buffers.