载入中...
搜索中...
未找到
AmbientOcclusion.h
浏览该文件的文档.
1#pragma once
2
3#include <string>
4#include <glm/mat4x4.hpp>
5
6namespace eve::graphics {
7
8class Canvas;
9class Graphics;
10class Shader;
11class Texture;
12
28public:
29 explicit AmbientOcclusion(Graphics *gfx);
31
34
36 void setQuality(const std::string &quality);
37 std::string getQuality() const { return quality_; }
38
40 void setMode(const std::string &mode);
41 std::string getMode() const { return mode_; }
42
47 void setCamera(float eyeX, float eyeY, float eyeZ, float targetX, float targetY, float targetZ,
48 float upX, float upY, float upZ, float fovYDeg, float aspect, float nearZ,
49 float farZ);
50
51 void setInvViewProj(const glm::mat4 &invViewProj);
52
53 void setRadius(float radius);
54 void setBias(float bias);
55 void setIntensity(float intensity);
56 void setPower(float power);
57 void setThickness(float thickness);
58
59 float getRadius() const;
60 float getBias() const;
61 float getIntensity() const;
62 float getPower() const;
63
64 bool hasParam(const std::string &name) const;
65 void setFloat(const std::string &name, float value);
66 float getFloat(const std::string &name) const;
67
69 int getSampleCount() const;
70 float getDownscale() const { return downscale_; }
71
76 int resolutionFor(int fullSize) const;
77
82 void compute(Graphics *gfx, Texture *linearDepth);
83 void computeTo(Graphics *gfx, Texture *linearDepth, Canvas *dest);
84
86 void blur(Graphics *gfx, Texture *aoMap);
87 void blurTo(Graphics *gfx, Texture *aoMap, Canvas *dest);
88
93 void applyOverlay(Graphics *gfx, Texture *aoMap);
94 void applyOverlayTo(Graphics *gfx, Texture *aoMap, Canvas *dest);
95
103 void applyFromDepth(Graphics *gfx, Texture *hwDepth);
104 void applyFromDepthTo(Graphics *gfx, Texture *linearDepth, Canvas *dest);
105 void applyFromGBuffer(Graphics *gfx, Texture *hwDepth, Texture *worldNormal);
106
112 float (*depth01)(int x, int y, void *userdata), void *userdata);
113
114 Shader *getShader() const;
115 Shader *getSsaoShader() const { return ssaoShader_; }
116 Shader *getHbaoShader() const { return hbaoShader_; }
117 Shader *getGtaoShader() const { return gtaoShader_; }
118 Shader *getBlurShader() const { return blurShader_; }
119 Shader *getOverlayShader() const { return overlayShader_; }
120 Shader *getFromDepthShader() const { return fromDepthShader_; }
121
122private:
123 void applyQualityDefaults();
124 void uploadComputeCommon(Shader *shader, int width, int height);
125 void drawFullscreen(Graphics *gfx, Texture *source, Shader *shader);
126 Shader *activeComputeShader() const;
127
128 Graphics *gfx_ = nullptr;
129 Shader *ssaoShader_ = nullptr;
130 Shader *hbaoShader_ = nullptr;
131 Shader *gtaoShader_ = nullptr;
132 Shader *blurShader_ = nullptr;
133 Shader *overlayShader_ = nullptr;
134 Shader *fromDepthShader_ = nullptr;
135 std::string quality_ = "medium";
136 std::string mode_ = "ssao";
137 float downscale_ = 2.f;
138 glm::mat4 invViewProj_{1.f};
139 float nearZ_ = 0.1f;
140 float farZ_ = 100.f;
141 float radius_ = 0.75f;
142 float bias_ = 0.025f;
143 float intensity_ = 1.f;
144 float power_ = 1.5f;
145 float thickness_ = 0.5f;
146};
147
148} // namespace eve::graphics
std::string value
int y
Definition Grass.cpp:135
float height
Definition Grass.cpp:235
int x
Definition Grass.cpp:135
float thickness
int width
Shader * shader
const char * name
Definition RockMesh.cpp:21
float power
Definition RockMesh.cpp:23
Screen-space ambient occlusion.
void applyFromDepthTo(Graphics *gfx, Texture *linearDepth, Canvas *dest)
AmbientOcclusion & operator=(const AmbientOcclusion &)=delete
void applyFromDepth(Graphics *gfx, Texture *hwDepth)
One-pass SSAO overlay for the 3D swapchain path. Samples hardware D32 (Vulkan NDC z in ....
int resolutionFor(int fullSize) const
Downscale helper: returns floor(dim / downscale), at least 1. Callers create AO canvases at this size...
void setFloat(const std::string &name, float value)
void computeTo(Graphics *gfx, Texture *linearDepth, Canvas *dest)
void setCamera(float eyeX, float eyeY, float eyeZ, float targetX, float targetY, float targetZ, float upX, float upY, float upZ, float fovYDeg, float aspect, float nearZ, float farZ)
Camera for depth reconstruction (RH + ZO). Builds inv(viewProj) and near/far used by compute*.
void setMode(const std::string &mode)
"ssao" | "hbao" | "gtao".
AmbientOcclusion(const AmbientOcclusion &)=delete
void blurTo(Graphics *gfx, Texture *aoMap, Canvas *dest)
void setInvViewProj(const glm::mat4 &invViewProj)
bool hasParam(const std::string &name) const
void applyFromGBuffer(Graphics *gfx, Texture *hwDepth, Texture *worldNormal)
Texture * newLinearDepthTexture(Graphics *gfx, int width, int height, float(*depth01)(int x, int y, void *userdata), void *userdata)
Build an RGBA8 texture with linear depth in R (G=B=R, A=255). Owned by Graphics (same convention as V...
float getFloat(const std::string &name) const
void setQuality(const std::string &quality)
"low" | "medium" | "high" (unknown → medium).
void compute(Graphics *gfx, Texture *linearDepth)
Compute AO into the currently bound canvas / screen. Output RGB = AO (1=open), A = depth01.
void blur(Graphics *gfx, Texture *aoMap)
Bilateral blur of an AO map (RGB=AO, A=depth).
void applyOverlayTo(Graphics *gfx, Texture *aoMap, Canvas *dest)
void applyOverlay(Graphics *gfx, Texture *aoMap)
Darken the current target with AO: black + alpha=(1-ao)*intensity. Draw over an already-rendered scen...
Custom GPU program.
Definition Shader.h:30
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:17
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition AnimTrail.h:6