载入中...
搜索中...
未找到
AmbientOcclusion.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include <string>
6#include <glm/mat4x4.hpp>
7
8namespace eve::graphics {
9
10class Canvas;
11class Graphics;
12class Shader;
13class Texture;
14
30public:
32 explicit AmbientOcclusion(Graphics *gfx);
35
38
40 void setQuality(const std::string &quality);
42 std::string getQuality() const { return quality_; }
43
45 void setMode(const std::string &mode);
47 std::string getMode() const { return mode_; }
48
53 void setCamera(float eyeX, float eyeY, float eyeZ, float targetX, float targetY, float targetZ,
54 float upX, float upY, float upZ, float fovYDeg, float aspect, float nearZ,
55 float farZ);
56
58 void setInvViewProj(const glm::mat4 &invViewProj);
59
61 void setRadius(float radius);
63 void setBias(float bias);
65 void setIntensity(float intensity);
67 void setPower(float power);
69 void setThickness(float thickness);
70
72 float getRadius() const;
74 float getBias() const;
76 float getIntensity() const;
78 float getPower() const;
79
81 bool hasParam(const std::string &name) const;
83 void setFloat(const std::string &name, float value);
85 float getFloat(const std::string &name) const;
86
89 int getSampleCount() const;
91 float getDownscale() const { return downscale_; }
92
97 int resolutionFor(int fullSize) const;
98
103 void compute(Graphics *gfx, Texture *linearDepth);
105 void computeTo(Graphics *gfx, Texture *linearDepth, Canvas *dest);
106
108 void blur(Graphics *gfx, Texture *aoMap);
110 void blurTo(Graphics *gfx, Texture *aoMap, Canvas *dest);
111
116 void applyOverlay(Graphics *gfx, Texture *aoMap);
118 void applyOverlayTo(Graphics *gfx, Texture *aoMap, Canvas *dest);
119
127 void applyFromDepth(Graphics *gfx, Texture *hwDepth);
129 void applyFromDepthTo(Graphics *gfx, Texture *linearDepth, Canvas *dest);
131 void applyFromGBuffer(Graphics *gfx, Texture *hwDepth, Texture *worldNormal);
132
137 Texture *newLinearDepthTexture(Graphics *gfx, int width, int height,
139 float (*depth01)(int x, int y, void *userdata), void *userdata);
140
142 Shader *getShader() const;
144 Shader *getSsaoShader() const { return ssaoShader_; }
146 Shader *getHbaoShader() const { return hbaoShader_; }
148 Shader *getGtaoShader() const { return gtaoShader_; }
150 Shader *getBlurShader() const { return blurShader_; }
152 Shader *getOverlayShader() const { return overlayShader_; }
154 Shader *getFromDepthShader() const { return fromDepthShader_; }
155
156private:
157 void applyQualityDefaults();
158 void uploadComputeCommon(Shader *shader, int width, int height);
159 void drawFullscreen(Graphics *gfx, Texture *source, Shader *shader);
160 Shader *activeComputeShader() const;
161
162 Graphics *gfx_ = nullptr;
163 Shader *ssaoShader_ = nullptr;
164 Shader *hbaoShader_ = nullptr;
165 Shader *gtaoShader_ = nullptr;
166 Shader *blurShader_ = nullptr;
167 Shader *overlayShader_ = nullptr;
168 Shader *fromDepthShader_ = nullptr;
169 std::string quality_ = "medium";
170 std::string mode_ = "ssao";
171 float downscale_ = 2.f;
172 glm::mat4 invViewProj_{1.f};
173 float nearZ_ = 0.1f;
174 float farZ_ = 100.f;
175 float radius_ = 0.75f;
176 float bias_ = 0.025f;
177 float intensity_ = 1.f;
178 float power_ = 1.5f;
179 float thickness_ = 0.5f;
180};
181
182} // namespace eve::graphics
double value
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float thickness
Definition CaveMesh.cpp:83
#define EVENGINE_API_BACKENDS
Definition Export.h:108
std::uint32_t height
std::uint32_t width
std::string name
OnnxCompute * compute
float radius
Shader * shader
float power
Definition RockMesh.cpp:23
float bias
float targetX
const UnitySourceAsset & source
Screen-space ambient occlusion.
AmbientOcclusion & operator=(const AmbientOcclusion &)=delete
Shader * getSsaoShader() const
Returns the ssao shader.
std::string getQuality() const
Returns the quality.
Shader * getBlurShader() const
Returns the blur shader.
AmbientOcclusion(const AmbientOcclusion &)=delete
std::string getMode() const
Returns the mode.
Shader * getGtaoShader() const
Returns the gtao shader.
~AmbientOcclusion()
Ambient occlusion.
Shader * getFromDepthShader() const
Returns the from depth shader.
float getDownscale() const
Returns the downscale.
Shader * getHbaoShader() const
Returns the hbao shader.
Shader * getOverlayShader() const
Returns the overlay shader.
Canvas public API.
Definition Canvas.h:17
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