Loading...
Searching...
No Matches
ExtractTexture.hpp
1#pragma once
2#include <halp/controls.hpp>
3#include <halp/geometry.hpp>
4#include <halp/meta.hpp>
5#include <halp/texture.hpp>
6
7#include <Gfx/Graph/RenderList.hpp>
8
9namespace Threedim
10{
11
12// Sibling to ExtractBuffer2 (name-based buffer extractor) but for
13// texture auxiliaries. Reads `inputs.geometry.mesh.auxiliary_textures`
14// (populated by the halp/ossia bridge from `ossia::geometry::
15// auxiliary_textures` — which ScenePreprocessor fills with skybox,
16// irradiance_map, prefiltered_map, brdf_lut, shadow_map_array,
17// base_color_array, metal_rough_array, normal_array, emissive_array,
18// *_Dyn0..N, and any producer-injected texture) and re-publishes the
19// named entry on a standalone gpu_texture_output.
20//
21// Runtime-detects the texture shape (2D / TextureArray / Cubemap /
22// 3D) from QRhiTexture::flags() and stamps it into the output port's
23// `kind` field so downstream nodes / shader bindings know how to bind
24// (sampler2D / sampler2DArray / samplerCube / sampler3D). Width,
25// height, and layer-or-depth count come along from pixelSize() /
26// arraySize() / depth().
27//
28// Primary use case: post-processing shaders that depend on scene
29// aux textures without going through the scene cable themselves. E.g.
30// the shaderlib/depth set wants `camera` + `camera_prev` UBOs
31// (extract via ExtractBuffer2) and sometimes a depth-texture aux
32// (this node).
34{
35public:
36 halp_meta(name, "Extract texture (by name)")
37 halp_meta(category, "Visuals/Utilities")
38 halp_meta(c_name, "extract_texture_by_name")
39 halp_meta(authors, "ossia team")
40 halp_meta(
41 manual_url, "https://ossia.io/score-docs/processes/extract-texture.html")
42 halp_meta(uuid, "4d8f2a6b-7c19-4e05-a3d8-1b6f5e9c2a48")
43
44 struct ins
45 {
46 struct
47 {
48 halp_meta(name, "Geometry");
49 halp::dynamic_gpu_geometry mesh;
50 float transform[16]{};
51 bool dirty_mesh = false;
52 bool dirty_transform = false;
53 } geometry;
54
55 struct : halp::lineedit<"Name", "skybox">
56 {
57 halp_meta(symbol, "name")
58 } name;
59 } inputs;
60
61 struct
62 {
63 halp::gpu_texture_output<"Texture"> texture;
64 } outputs;
65
66 void init(score::gfx::RenderList& renderer, QRhiResourceUpdateBatch& res);
67 void update(
68 score::gfx::RenderList& renderer, QRhiResourceUpdateBatch& res,
70 void release(score::gfx::RenderList& r);
71 void operator()() { }
72
73private:
74 // Last-known resolved values — used to skip work when nothing changed.
75 void* m_lastHandle{};
76 std::string m_lastName;
77};
78
79}
Definition ExtractTexture.hpp:34
List of nodes to be rendered to an output.
Definition RenderList.hpp:30
Definition ExtractTexture.hpp:45
Definition TinyObj.hpp:27
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:103