载入中...
搜索中...
未找到
ReflectionProbeCapture.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include <array>
6#include <cstdint>
7#include <string>
8#include <vector>
9
10namespace eve::graphics {
11
12class Camera3D;
13class Canvas;
14class Graphics;
15class Mesh;
16class ReflectionProbeRegistry;
17class Texture;
18
27public:
29 explicit ReflectionProbeCapture(Graphics *gfx);
32
42 void configure(float x, float y, float z, int resolution = 128, float nearZ = 0.1f,
43 float farZ = 100.f);
44
46 void requestCapture();
52 void queueCapture();
53
59 bool update(int faceBudget = 1);
60
65 Canvas *getFaceCanvas(int face) const;
67 bool isCapturePending() const { return pending_; }
69 bool isRecaptureQueued() const { return recaptureAfterPublish_; }
71 bool isCaptureComplete() const { return revision_ > 0 && !pending_; }
73 uint32_t getRevision() const { return revision_; }
78 bool stageCapturedFaces();
83 Texture *getStagingCubemap() const { return stagingCubemap_; }
85 uint32_t getStagedRevision() const { return stagedRevision_; }
90 bool filterAndPublish(int sampleCount = 64);
95 Texture *getActiveCubemap() const { return activeCubemap_; }
97 uint32_t getPublishedRevision() const { return publishedRevision_; }
99 void setUpdateMode(const std::string &mode);
101 std::string getUpdateMode() const;
103 void setRefreshInterval(int frames);
105 int getRefreshInterval() const { return refreshInterval_; }
107 void setCaptureMask(int mask);
109 int getCaptureMask() const { return static_cast<int>(captureMask_); }
116 void setEnvironmentLighting(Texture *environment, float intensity = 1.f);
121 Texture *getEnvironmentLighting() const { return environmentLighting_; }
123 float getEnvironmentLightingIntensity() const { return environmentLightingIntensity_; }
131 void setSkyColor(float r, float g, float b, float intensity = 1.f);
139 void setSkyFaceColor(int face, float r, float g, float b);
145 void setSkyFaceTexture(int face, Texture *texture);
150 Texture *getSkyFaceTexture(int face) const;
152 void setSkyFaceTextureScale(int face, float scale);
154 float getSkyFaceTextureScale(int face) const;
156 float getSkyFaceColor(int face, int component) const;
158 float getSkyR() const { return skyR_[0]; }
160 float getSkyG() const { return skyG_[0]; }
162 float getSkyB() const { return skyB_[0]; }
164 float getSkyIntensity() const { return skyIntensity_; }
166 int getPendingFaceCount() const { return pending_ ? 6 - nextFace_ : 0; }
168 int getLastCapturedFaceCount() const { return lastCapturedFaceCount_; }
170 uint32_t getTotalCapturedFaceCount() const { return totalCapturedFaceCount_; }
172 int getLastFilterSampleCount() const { return lastFilterSampleCount_; }
174 void setGpuBudgetMs(float milliseconds);
176 float getGpuBudgetMs() const { return gpuBudgetMs_; }
181 void reportGpuDurationMs(float milliseconds);
183 float getSmoothedGpuDurationMs() const { return smoothedGpuDurationMs_; }
185 int getAdaptiveFaceBudget() const { return adaptiveFaceBudget_; }
187 int getAdaptiveFilterSamples() const { return adaptiveFilterSamples_; }
193 bool tickAdaptive();
199 bool tick(int faceBudget = 1, int filterSamples = 64);
209 void configureInfluence(float extentX, float extentY, float extentZ, float intensity = 1.f,
210 float blendDistance = 1.f, int priority = 0);
212 float getInfluenceExtentX() const { return influenceExtentX_; }
214 float getInfluenceExtentY() const { return influenceExtentY_; }
216 float getInfluenceExtentZ() const { return influenceExtentZ_; }
218 float getInfluenceIntensity() const { return influenceIntensity_; }
220 float getInfluenceBlendDistance() const { return influenceBlendDistance_; }
222 int getInfluencePriority() const { return influencePriority_; }
227 bool applyConfiguredToCamera(Camera3D *camera, int slot);
233 bool applyToCamera(Camera3D *camera, int slot, float extentX, float extentY, float extentZ,
234 float intensity = 1.f, float blendDistance = 1.f, int priority = 0);
236 int getResolution() const { return resolution_; }
238 float getCenterX() const { return centerX_; }
240 float getCenterY() const { return centerY_; }
242 float getCenterZ() const { return centerZ_; }
244 float getCaptureFarDistance() const { return farZ_; }
248 void setCaptureLodDistanceScale(float scale);
250 float getCaptureLodDistanceScale() const { return lodDistanceScale_; }
252 void setCaptureTransparent(bool enabled);
254 bool getCaptureTransparent() const { return captureTransparent_; }
256 void setCaptureClusteredLighting(bool enabled);
258 bool getCaptureClusteredLighting() const { return captureClusteredLighting_; }
259
260private:
262 void attachRegistry(ReflectionProbeRegistry *registry);
263 void detachRegistry(ReflectionProbeRegistry *registry);
264 void advanceRefreshPolicy();
265 void requestCaptureAfterPublish();
266 void ensureResources();
267 void captureFace(int face);
268
269 Graphics *gfx_ = nullptr;
270 Camera3D *camera_ = nullptr;
271 std::array<Canvas *, 6> faces_{};
272 Mesh *skyQuad_ = nullptr;
273 float centerX_ = 0.f;
274 float centerY_ = 0.f;
275 float centerZ_ = 0.f;
276 float nearZ_ = 0.1f;
277 float farZ_ = 100.f;
278 int resolution_ = 128;
279 int allocatedResolution_ = 0;
280 int nextFace_ = 0;
281 bool pending_ = true;
282 uint32_t revision_ = 0;
283 Texture *stagingCubemap_ = nullptr;
284 int stagingResolution_ = 0;
285 uint32_t stagedRevision_ = 0;
286 Texture *activeCubemap_ = nullptr;
287 uint32_t publishedRevision_ = 0;
288 int activeResolution_ = 0;
289 enum class UpdateMode { Static, OnDemand, TimeSliced, Realtime };
290 UpdateMode updateMode_ = UpdateMode::OnDemand;
291 int refreshInterval_ = 60;
292 uint32_t captureMask_ = 0xffffffffu;
293 Texture *environmentLighting_ = nullptr;
294 float environmentLightingIntensity_ = 0.f;
295 std::array<float, 6> skyR_{};
296 std::array<float, 6> skyG_{};
297 std::array<float, 6> skyB_{};
298 std::array<float, 6> captureSkyR_{};
299 std::array<float, 6> captureSkyG_{};
300 std::array<float, 6> captureSkyB_{};
301 std::array<Texture *, 6> skyFaceTextures_{};
302 std::array<Texture *, 6> captureSkyFaceTextures_{};
303 std::array<float, 6> skyFaceTextureScales_{{1.f, 1.f, 1.f, 1.f, 1.f, 1.f}};
304 std::array<float, 6> captureSkyFaceTextureScales_{{1.f, 1.f, 1.f, 1.f, 1.f, 1.f}};
305 float skyIntensity_ = 1.f;
306 float captureSkyIntensity_ = 1.f;
307 Texture *captureEnvironmentLighting_ = nullptr;
308 float captureEnvironmentLightingIntensity_ = 0.f;
309 bool recaptureAfterPublish_ = false;
310 float lodDistanceScale_ = 1.f;
311 float captureLodDistanceScale_ = 1.f;
312 bool captureTransparent_ = true;
313 bool snapshotCaptureTransparent_ = true;
314 bool captureClusteredLighting_ = true;
315 bool snapshotCaptureClusteredLighting_ = true;
316 int framesSincePublish_ = 0;
317 int lastCapturedFaceCount_ = 0;
318 uint32_t totalCapturedFaceCount_ = 0;
319 int lastFilterSampleCount_ = 0;
320 float gpuBudgetMs_ = 1.5f;
321 float smoothedGpuDurationMs_ = 0.f;
322 int adaptiveFaceBudget_ = 1;
323 int adaptiveFilterSamples_ = 64;
324 int underBudgetReports_ = 0;
325 float influenceExtentX_ = 1.f;
326 float influenceExtentY_ = 1.f;
327 float influenceExtentZ_ = 1.f;
328 float influenceIntensity_ = 1.f;
329 float influenceBlendDistance_ = 1.f;
330 int influencePriority_ = 0;
331 std::vector<ReflectionProbeRegistry *> registries_;
332};
333
334} // namespace eve::graphics
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float z
Definition AnimClip.cpp:738
int mask
int priority
#define EVENGINE_API_BACKENDS
Definition Export.h:108
tensor::Graph g
Definition GpuGraph.cpp:7
float camera[2]
double r
std::array< float, 3 > scale
MeleePoint3 b
Definition MeleeHit.cpp:41
double & milliseconds
Definition OnnxGpgpu.cpp:19
SimulationTick tick
EVENGINE_API_BACKENDS public API.
Canvas public API.
Definition Canvas.h:17
GPU mesh handle (+ optional CPU morph targets).
Definition Mesh.h:25
Incremental six-face HDR scene capture for a runtime reflection probe.
float getInfluenceExtentY() const
Return persistent influence half extent Y.
float getCaptureFarDistance() const
Return the capture far distance used for spatial dirty culling.
float getSkyB() const
Return the unscaled backup sky blue channel.
float getInfluenceExtentX() const
Return persistent influence half extent X.
float getSmoothedGpuDurationMs() const
Return the exponentially smoothed reported GPU duration.
float getSkyG() const
Return the unscaled backup sky green channel.
float getCenterY() const
Return probe world-space center Y.
int getRefreshInterval() const
Return the automatic refresh interval in frames.
uint32_t getPublishedRevision() const
Last capture revision atomically published for lighting.
uint32_t getRevision() const
Monotonic revision incremented after each complete six-face capture.
float getGpuBudgetMs() const
Return the adaptive capture GPU-time budget in milliseconds.
uint32_t getStagedRevision() const
Last capture revision fully copied into the staging cubemap.
bool isCapturePending() const
True while one or more faces still need capture.
int getInfluencePriority() const
Return persistent overlap-selection priority.
int getResolution() const
Current square face resolution.
uint32_t getTotalCapturedFaceCount() const
Total number of face renders performed by this capture object.
float getInfluenceExtentZ() const
Return persistent influence half extent Z.
float getCaptureLodDistanceScale() const
Return capture LOD distance scale.
bool isCaptureComplete() const
True after at least one complete six-face capture.
bool getCaptureTransparent() const
Return whether transparent/hair surfaces are captured.
float getInfluenceIntensity() const
Return persistent reflection intensity.
int getLastFilterSampleCount() const
Sample count used by the most recently published filter pass.
float getSkyR() const
Return the unscaled backup sky red channel.
bool isRecaptureQueued() const
True when changed capture inputs are queued behind the current revision.
float getCenterZ() const
Return probe world-space center Z.
float getSkyIntensity() const
Return the backup sky HDR multiplier.
int getCaptureMask() const
Return the object-layer mask visible to this reflection capture.
Texture * getEnvironmentLighting() const
Return the global environment texture used while capturing. @lifetime Returned texture is borrowed; i...
int getAdaptiveFilterSamples() const
Return the current adaptive filter sample count.
float getCenterX() const
Return probe world-space center X.
Texture * getStagingCubemap() const
Backend HDR staging cubemap; not yet filtered or safe for lighting. @lifetime Returned texture is Gra...
int getAdaptiveFaceBudget() const
Return the current adaptive cubemap-face budget.
float getInfluenceBlendDistance() const
Return persistent edge blend distance.
float getEnvironmentLightingIntensity() const
Return the global environment-lighting intensity used while capturing.
Texture * getActiveCubemap() const
Last fully filtered cubemap, safe to assign to Camera3D reflection probes. @lifetime Returned texture...
bool getCaptureClusteredLighting() const
Return whether probe captures can build clustered light tables.
int getLastCapturedFaceCount() const
Number of faces rendered by the most recent update call.
int getPendingFaceCount() const
Number of cubemap faces remaining in the current capture revision.
Scene-level stable selection of published reflection probes for a camera.
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:18
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
bool enabled