载入中...
搜索中...
未找到
AntiAliasing.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include <cstdint>
6#include <string>
7#include <unordered_map>
8
9#include <glm/vec2.hpp>
10#include <glm/vec3.hpp>
11#include <glm/mat4x4.hpp>
12
13namespace eve::graphics {
14
15class Canvas;
16class Graphics;
17class Shader;
18class Texture;
19
34public:
36 explicit AntiAliasing(Graphics *gfx);
39
40 AntiAliasing(const AntiAliasing &) = delete;
42
44 void setQuality(const std::string &quality);
46 std::string getQuality() const { return quality_; }
47
49 void setMode(const std::string &mode);
51 std::string getMode() const { return mode_; }
52
54 bool hasParam(const std::string &name) const;
56 void setFloat(const std::string &name, float value);
58 float getFloat(const std::string &name) const;
59
65 float suggestScale() const;
66
69 int resolutionFor(int destSize) const;
70
75 void apply(Graphics *gfx, Texture *source);
77 void applyTemporalRect(Graphics *gfx, Texture *source, float x, float y, float width,
78 float height, float r = 1.f, float g = 1.f, float b = 1.f,
79 float a = 1.f);
81 void applyTemporal(Graphics *gfx, Texture *source, Texture *motion = nullptr);
86 Texture *resolveTemporal(Graphics *gfx, Texture *source, Texture *motion = nullptr);
87
92 Canvas *beginTemporalFrame(Texture *source, Texture *motion = nullptr);
97 Texture *getTemporalReadTexture() const;
99 void endTemporalFrame();
101 glm::vec2 prepareTemporalJitter(int width, int height);
103 void setTemporalCamera(const glm::vec3 &eye, const glm::vec3 &target, float fovYDeg);
105 void invalidateTemporalHistory();
107 void setTemporalViewProjection(const glm::mat4 &viewProjection, float nearZ, float farZ);
109 glm::vec2 prepareTemporalObjectMotion(const void *objectKey, const glm::mat4 &model);
111 void applyTo(Graphics *gfx, Texture *source, Canvas *dest);
112
114 void applyCanvas(Graphics *gfx, Canvas *source);
116 void applyCanvasTo(Graphics *gfx, Canvas *source, Canvas *dest);
117
119 void prepareSource(Texture *source);
120
123 Shader *getFxaaShader() const { return fxaa_; }
125 Shader *getSmaaShader() const { return smaa_; }
127 Shader *getSsaaShader() const { return ssaa_; }
129 Shader *getNfaaShader() const { return nfaa_; }
131 Shader *getTaaShader() const { return taa_; }
133 Shader *getShader() const;
134
135private:
136 void applyQualityDefaults();
137 void uploadScreenUniforms(Texture *source);
138 void drawFullscreen(Graphics *gfx, Texture *source, Shader *shader);
139 void applyFullscreenTo(Graphics *gfx, Texture *source, Canvas *dest, Texture *history,
140 bool hasHistory);
141 void ensureHistoryCanvases(int width, int height);
142 void swapHistoryBuffers();
143 void resetHistory();
144 Shader *shaderForMode() const;
145
146 Graphics *gfx_ = nullptr; // not owned
147 Shader *fxaa_ = nullptr; // owned by Graphics
148 Shader *smaa_ = nullptr;
149 Shader *ssaa_ = nullptr;
150 Shader *nfaa_ = nullptr;
151 Shader *taa_ = nullptr;
152 std::string quality_ = "medium";
153 std::string mode_ = "fxaa";
154
155 Canvas *taaHistoryA_ = nullptr;
156 Canvas *taaHistoryB_ = nullptr;
157 Canvas *historyRead_ = nullptr;
158 Canvas *historyWrite_ = nullptr;
159 bool taaHistoryValid_ = false;
160 int historyW_ = 0;
161 int historyH_ = 0;
162 uint32_t temporalFrameIndex_ = 0;
163 glm::vec2 temporalJitterNdc_{0.f};
164 glm::vec2 previousJitterNdc_{0.f};
165 glm::vec3 temporalEye_{0.f};
166 glm::vec3 temporalForward_{0.f, 0.f, -1.f};
167 float temporalFovY_ = 0.f;
168 bool temporalCameraValid_ = false;
169 glm::mat4 temporalViewProj_{1.f};
170 glm::mat4 previousViewProj_{1.f};
171 float temporalNearZ_ = 0.1f;
172 float temporalFarZ_ = 100.f;
173 bool temporalViewValid_ = false;
174 std::unordered_map<const void *, glm::mat4> temporalObjectHistory_;
175 std::unordered_map<const void *, glm::mat4> temporalObjectPending_;
176};
177
178} // namespace eve::graphics
LogicalId target
double value
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
#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::string name
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
glm::vec3 eye
Shader * shader
glm::mat4 model
const UnitySourceAsset & source
Classic image-space anti-aliasing.
Shader * getSmaaShader() const
Returns the smaa shader.
Shader * getNfaaShader() const
Returns the nfaa shader.
Shader * getSsaaShader() const
Returns the ssaa shader.
Shader * getTaaShader() const
Returns the taa shader.
std::string getQuality() const
Returns the quality.
~AntiAliasing()
Anti aliasing.
Shader * getFxaaShader() const
Returns the fxaa shader.
AntiAliasing & operator=(const AntiAliasing &)=delete
AntiAliasing(const AntiAliasing &)=delete
std::string getMode() const
Returns the mode.
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