载入中...
搜索中...
未找到
GlobalIllumination.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include <string>
6#include <cstdint>
7#include <glm/mat4x4.hpp>
8#include <glm/vec3.hpp>
9
10namespace eve::graphics {
11
12class Canvas;
13class Graphics;
14class Shader;
15class Texture;
16
31public:
33 explicit GlobalIllumination(Graphics *gfx);
36
39
41 void setQuality(const std::string &quality);
43 std::string getQuality() const { return quality_; }
44
49 void setCamera(float eyeX, float eyeY, float eyeZ, float targetX, float targetY, float targetZ,
50 float upX, float upY, float upZ, float fovYDeg, float aspect, float nearZ,
51 float farZ);
52
54 void setInvViewProj(const glm::mat4 &invViewProj);
56 void setWorldNormalTexture(Texture *worldNormal) { worldNormal_ = worldNormal; }
58 void setAlbedoTexture(Texture *albedo) { albedo_ = albedo; }
60 void setTemporalMotionTexture(Texture *motionDepth) { temporalMotionDepth_ = motionDepth; }
62 void setDepthPyramid(Texture *atlas, int levels) {
63 depthPyramid_ = atlas;
64 depthPyramidLevels_ = levels;
65 }
67 void invalidateHistory() { historyValid_ = false; }
68
70 void setRadius(float radius);
72 void setIntensity(float intensity);
74 void setThickness(float thickness);
76 void setResolutionScale(float scale);
78 void setLightDirection(float dx, float dy, float dz);
80 void setLightColor(float r, float g, float b);
81
83 float getRadius() const { return radius_; }
85 float getIntensity() const { return intensity_; }
87 float getThickness() const { return thickness_; }
89 float getResolutionScale() const { return resolutionScale_; }
90
92 bool hasParam(const std::string &name) const;
94 void setFloat(const std::string &name, float value);
96 float getFloat(const std::string &name) const;
97
99 int getSampleCount() const;
102 return quality_ == "ultra" ? 3 : quality_ == "high" ? 2 : quality_ == "medium" ? 1 : 0;
103 }
104
110 void applyFromDepth(Graphics *gfx, Texture *packedAlbedo);
112 void applyFromDepthTo(Graphics *gfx, Texture *packedAlbedo, Canvas *dest);
114 void applyFromSceneTo(Graphics *gfx, Texture *color, Texture *hwDepth, Canvas *dest);
116 void applyFromSceneTo(Graphics *gfx, Texture *color, Texture *hwDepth);
119 Canvas *getWorkingCanvas();
124 Texture *getWorkingTexture();
126 void applyFromScene(Graphics *gfx, Texture *color, Texture *hwDepth);
127
130 Shader *getShader() const { return ssgi_; }
131
132private:
133 void applyQualityDefaults();
134 void uploadUniforms(int width, int height);
135 void drawFullscreen(Graphics *gfx, Texture *source, Shader *shader, Texture *hwDepth = nullptr);
136 Canvas *getGiCanvas();
137 void ensureHistory(int width, int height);
138 void resolveTemporal(Graphics *gfx, Texture *current);
139
140 Graphics *gfx_ = nullptr;
141 Shader *ssgi_ = nullptr;
142 Shader *temporal_ = nullptr;
143 std::string quality_ = "medium";
144 glm::mat4 invViewProj_{1.f};
145 float nearZ_ = 0.1f;
146 float farZ_ = 100.f;
147 float radius_ = 1.25f;
148 float intensity_ = 0.45f;
149 float thickness_ = 0.2f;
150 float temporalCurrentWeight_ = 0.16f;
151 float spatialFilterStrength_ = 0.5f;
152 float resolutionScale_ = 1.f;
153 glm::vec3 lightDir_{0.4f, 1.f, 0.3f};
154 glm::vec3 lightColor_{1.f, 1.f, 1.f};
155 Canvas *giCanvas_ = nullptr;
156 Texture *worldNormal_ = nullptr;
157 Texture *albedo_ = nullptr;
158 Texture *temporalMotionDepth_ = nullptr;
159 Texture *depthPyramid_ = nullptr;
160 int depthPyramidLevels_ = 0;
161 Canvas *historyA_ = nullptr;
162 Canvas *historyB_ = nullptr;
163 Canvas *historyRead_ = nullptr;
164 Canvas *historyWrite_ = nullptr;
165 Canvas *spatialA_ = nullptr;
166 Canvas *spatialB_ = nullptr;
167 glm::mat4 previousViewProj_{1.f};
168 glm::vec3 previousEye_{0.f};
169 glm::vec3 previousForward_{0.f, 0.f, -1.f};
170 float previousFovY_ = 0.f;
171 float previousAspect_ = 1.f;
172 bool historyValid_ = false;
173 bool viewProjValid_ = false;
174 bool cameraValid_ = false;
175 int historyWidth_ = 0;
176 int historyHeight_ = 0;
177 uint32_t samplingFrame_ = 0;
178};
179
180} // namespace eve::graphics
double value
float thickness
Definition CaveMesh.cpp:83
graphics::Texture * albedo
#define EVENGINE_API_BACKENDS
Definition Export.h:108
tensor::Graph g
Definition GpuGraph.cpp:7
double r
std::uint32_t height
std::uint32_t width
std::array< float, 3 > scale
std::string name
MeleePoint3 b
Definition MeleeHit.cpp:41
float radius
Shader * shader
double current
float dz
float dy
float dx
float targetX
const UnitySourceAsset & source
Canvas public API.
Definition Canvas.h:17
Screen-space single-bounce GI (SSGI). @lifetime All texture arguments are borrowed for the duration o...
float getIntensity() const
Returns the intensity.
void invalidateHistory()
Discard temporal GI history after a render-chain discontinuity.
void setTemporalMotionTexture(Texture *motionDepth)
Set packed linear-depth and motion texture used by temporal GI resolve.
~GlobalIllumination()
Global illumination.
std::string getQuality() const
Returns the quality.
GlobalIllumination & operator=(const GlobalIllumination &)=delete
float getResolutionScale() const
Returns the resolution scale.
GlobalIllumination(const GlobalIllumination &)=delete
float getRadius() const
Returns the radius.
void setDepthPyramid(Texture *atlas, int levels)
Set the shared horizontally packed RG min/max depth hierarchy.
Shader * getShader() const
Returns the shader.
void setWorldNormalTexture(Texture *worldNormal)
Set the GBuffer world-normal texture used for guided GI sampling.
int getSpatialPassCount() const
Number of explicit A-trous prefilter passes for the active quality.
float getThickness() const
Return world-space GI hit thickness.
void setAlbedoTexture(Texture *albedo)
Set receiver albedo used for energy-conserving diffuse GI response.
Custom GPU program.
Definition Shader.h:39
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
glm::mat4 invViewProj
glm::vec4 color