36 halp_meta(name,
"Cubemap Loader")
37 halp_meta(category,
"Visuals/3D")
38 halp_meta(c_name,
"cubemap_loader")
39 halp_meta(description,
"Load an environment image into a cubemap and scene skybox contribution.")
42 "https://ossia.io/score-docs/processes/cubemap-loader.html")
43 halp_meta(uuid,
"b8d4f9e2-6c3a-4b0f-9e4d-2a7f0c5b3d6e")
51 struct image_t : halp::file_port<"Image", halp::mmap_file_view>
58 "Images (*.png *.jpg *.jpeg *.bmp *.tga *.webp *.tif *.tiff)");
59 static std::function<void(
CubemapLoader&)> process(file_type data)
62 if(!data.bytes.empty())
65 reinterpret_cast<const uchar*
>(data.bytes.data()),
66 (
int)data.bytes.size());
68 if(img.isNull() && !data.filename.empty())
70 img = QImage(data.filename.data());
76 qWarning() <<
"CubemapLoader: failed to decode environment image"
77 << data.filename.data()
78 <<
"- unsupported or corrupt format (HDR/EXR float"
79 " formats are not supported)";
81 else if(img.format() != QImage::Format_RGBA8888)
82 img = img.convertToFormat(QImage::Format_RGBA8888);
84 self.m_loadedImage = std::move(img);
85 self.m_imageChanged =
true;
90 struct : halp::enum_t<CubemapLayout,
"Layout">
92 void update(
CubemapLoader& self) { self.m_imageChanged =
true; }
95 struct : halp::spinbox_i32<
"Resolution", halp::range{16, 8192, 512}>
97 void update(CubemapLoader& self) { self.m_imageChanged =
true; }
107 halp::gpu_cubemap_output<
"Cubemap"> cubemap;
117 halp_meta(name,
"Scene");
118 ossia::scene_spec scene;
125 std::shared_ptr<ossia::scene_state> m_sceneState;
126 int64_t m_sceneVersion{0};
127 void* m_lastPublishedHandle{};
130 QRhiTexture* m_cubemapTex{};
131 QRhiTexture* m_equirectTex{};
132 QRhiSampler* m_equirectSampler{};
137 QRhiTextureRenderTarget* renderTarget{};
138 QRhiRenderPassDescriptor* renderPass{};
141 QRhiGraphicsPipeline* m_equirectPipeline{};
142 QRhiShaderResourceBindings* m_equirectSrb{};
143 QRhiBuffer* m_equirectUbo{};
144 QRhiBuffer* m_quadVbuf{};
149 quint32 m_equirectUboStride{0};
152 bool m_imageChanged{
true};
153 QImage m_loadedImage;
155 void operator()() { }
172 void runInitialPasses(
177 bool createCubemapTexture(QRhi& rhi,
int faceSize);
178 void releaseCubemapTexture();
188 void uploadCrossOrStrip(QRhiResourceUpdateBatch* res);
189 void renderEquirectangular(
191 QRhiResourceUpdateBatch*& res);
196 QImage extractFace(
int faceIndex)
const;