载入中...
搜索中...
未找到
IGraphics3D.h
浏览该文件的文档.
1#pragma once
2
3// Narrow 3D-rendering interface of the Graphics backend.
4// Consumers (voxel, model3d render paths, scene preview) depend on this
5// instead of the full graphics::Graphics god class. All methods are pure
6// virtual; the concrete backend implements them.
7
8#include "graphics/Color.h"
9
10#include <glm/mat4x4.hpp>
11#include <glm/vec3.hpp>
12
13#include <cstdint>
14#include <string>
15
16namespace eve::graphics {
17
19enum class SkinInfluenceLimit : int { One = 1, Two = 2, Four = 4 };
20struct PbrSurface;
21
22
23class Texture;
24
27 static constexpr int kMaxProbes = 2;
29 struct Probe {
30 Texture *cubemap = nullptr;
31 glm::vec3 center{0.f};
32 glm::vec3 extent{0.f};
33 float intensity = 0.f;
34 float blendDistance = 0.f;
35 int priority = 0;
36 };
38 int count = 0;
39};
40
41class Canvas;
42class Camera3D;
43class Mesh;
45class Shader;
47struct Lighting3DPack;
48struct ShadowUpload;
49
52public:
54 virtual ~IGraphics3D() = default;
55
57 virtual void render3D() = 0;
59 virtual void renderScene3DToCanvas(Canvas *canvas, Camera3D *camera) = 0;
61 virtual void setDirectionalLight(float dx, float dy, float dz, float r = 1.f, float g = 1.f,
62 float b = 1.f) = 0;
64 virtual void drawScene3DRGBA(float x, float y, float w, float h, float r = 1.f, float g = 1.f,
65 float b = 1.f, float a = 1.f) = 0;
67 virtual void drawCanvasRGBA(Canvas *canvas, float x, float y, float w, float h, float r = 1.f,
68 float g = 1.f, float b = 1.f, float a = 1.f) = 0;
69
71 virtual void begin3DFrame() = 0;
73 virtual void begin3DFrameToCanvas(Canvas *canvas) = 0;
75 virtual void end3DFrameToCanvas() = 0;
76
83 virtual void drawPrimitiveScene(const PrimitiveSceneCanvas3D &canvas) = 0;
84
86 virtual void setMesh3DViewProj(const glm::mat4 &viewProj) = 0;
88 virtual void setMesh3DView(const glm::mat4 &view) = 0;
90 virtual void setMesh3DClip(float nearZ, float farZ) = 0;
91
93 virtual void drawMesh(Mesh *mesh, const glm::mat4 &model, Texture *texture,
94 const Color &tint) = 0;
96 virtual void drawMeshShader(Mesh *mesh, const glm::mat4 &model, Texture *texture,
97 const Color &tint, Shader *shader) = 0;
98
108 virtual void setMesh3DMaterial(float metallic, float roughness) = 0;
114 [[nodiscard]] virtual Result<void> setMesh3DPbrSurface(const PbrSurface* surface) {
115 if (!surface) return Result<void>::success();
118 DiagnosticCode::Unsupported, "extended PBR material rendering is unavailable on this backend"));
119 }
120
122 virtual void setMesh3DTexCellBomb(float cellScale, float strength, float rotAmount = 1.f) = 0;
124 virtual void setMesh3DParallax(float scale, float minLayers = 8.f, float maxLayers = 32.f) = 0;
126 virtual void setMesh3DLighting(const Lighting3DPack &pack) = 0;
130 virtual void setMesh3DLight(const glm::vec3 &dir, const glm::vec3 &color) = 0;
132 virtual void setMesh3DCameraPos(const glm::vec3 &eye) = 0;
134 virtual void setCloudShadows(float strength, float worldCell, float time, float windSpeed,
135 float windAngle, float coverage, float detail) = 0;
137 virtual void setMesh3DEnv(Texture *cube, float intensity) = 0;
139 virtual void setMesh3DEnvProbe(const glm::vec3 &center, const glm::vec3 &extent) = 0;
141 virtual void setMesh3DReflectionProbes(const ReflectionProbeUpload &upload) = 0;
143 virtual void setMesh3DShadows(const ShadowUpload &upload) = 0;
145 virtual void setMesh3DShadowReceive(bool receive) = 0;
148
150 virtual void beginShadowPass(int cascadeIndex) = 0;
152 virtual void drawMeshShadow(Mesh *mesh, const glm::mat4 &lightMVP, bool doubleSided = true) = 0;
154 virtual void drawMeshShadowAlpha(Mesh *mesh, const glm::mat4 &lightMVP,
155 Texture *albedo = nullptr, bool doubleSided = true,
156 float lodWeight = 1.f, bool lodFadeReverse = false,
157 bool lodDither = false) = 0;
159 virtual void endShadowPass() = 0;
160
162 virtual void beginGBufferPass(int width, int height) = 0;
164 virtual void drawMeshGBuffer(Mesh *mesh, const glm::mat4 &mvp, const glm::mat4 &model,
165 float nearZ, float farZ, Texture *albedo = nullptr,
166 float tintR = 1.f, float tintG = 1.f, float tintB = 1.f,
167 float motionX = 0.f, float motionY = 0.f,
168 float roughness = 0.45f, float metallic = 0.f) = 0;
170 virtual void drawMeshGBufferAlpha(Mesh *mesh, const glm::mat4 &mvp, const glm::mat4 &model,
171 float nearZ, float farZ, Texture *albedo = nullptr,
172 float tintR = 1.f, float tintG = 1.f,
173 float tintB = 1.f, float motionX = 0.f,
174 float motionY = 0.f, float roughness = 0.45f,
175 float metallic = 0.f) = 0;
177 virtual void endGBufferPass() = 0;
178
180 virtual void drawVoxelFaceInstances(const uint32_t *packed, int count, float originX,
181 float originY, float originZ, const std::string &faceDir,
182 Texture *atlas, int tilesPerRow = 16,
183 const uint32_t *ao = nullptr) = 0;
184};
185
186} // namespace eve::graphics
float w
Definition AnimClip.cpp:738
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
graphics::Texture * albedo
tensor::Graph g
Definition GpuGraph.cpp:7
glm::vec4 tint
glm::mat4 mvp
double r
int h
std::uint32_t height
std::uint32_t width
std::array< float, 3 > scale
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
float roughness
bool doubleSided
Texture * normal
float metallic
bool lodFadeReverse
glm::vec3 eye
Mesh * mesh
float lodWeight
glm::mat4 viewProj
Shader * shader
glm::mat4 view
glm::mat4 model
float dz
float dy
float dx
std::uint32_t count
V3 dir
Definition TreeMesh.cpp:150
std::uint32_t depth
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:164
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
EVENGINE_API_BACKENDS public API.
Canvas public API.
Definition Canvas.h:17
3D frame / mesh / light / shadow rendering surface.
Definition IGraphics3D.h:51
virtual void setMesh3DSceneDepth(Texture *depth)=0
Sets the mesh 3 d scene depth.
virtual void setMesh3DView(const glm::mat4 &view)=0
Sets the mesh 3 d view.
virtual void render3D()=0
Renders 3 d.
virtual void setMesh3DHeightTexture(Texture *height)=0
Sets the mesh 3 d height texture.
virtual void setMesh3DReflectionProbes(const ReflectionProbeUpload &upload)=0
Sets the mesh 3 d reflection probes.
virtual Result< void > setMesh3DPbrSurface(const PbrSurface *surface)
Copy a validated extended surface for subsequent draws; null resets to legacy shading.
virtual void setMesh3DEnvProbe(const glm::vec3 &center, const glm::vec3 &extent)=0
Sets the mesh 3 d env probe.
virtual void setMesh3DSceneColor(Texture *color)=0
Sets the mesh 3 d scene color.
virtual void setMesh3DLighting(const Lighting3DPack &pack)=0
Sets the mesh 3 d lighting.
virtual void endShadowPass()=0
Ends shadow pass.
virtual void drawPrimitiveScene(const PrimitiveSceneCanvas3D &canvas)=0
Submits an owning frame-local primitive canvas into the active 3D pass.
virtual ~IGraphics3D()=default
Releases IGraphics3D resources.
virtual void setMesh3DMaterial(float metallic, float roughness)=0
Sets the mesh 3 d material.
virtual void setMesh3DEnv(Texture *cube, float intensity)=0
Sets the mesh 3 d env.
virtual void drawScene3DRGBA(float x, float y, float w, float h, float r=1.f, float g=1.f, float b=1.f, float a=1.f)=0
Draws scene 3 drgba.
virtual void setMesh3DCameraPos(const glm::vec3 &eye)=0
Sets the mesh 3 d camera pos.
virtual void beginGBufferPass(int width, int height)=0
Begins g buffer pass.
virtual void end3DFrameToCanvas()=0
Ends 3 d frame to canvas.
virtual void setCloudShadows(float strength, float worldCell, float time, float windSpeed, float windAngle, float coverage, float detail)=0
Sets the cloud shadows.
virtual void drawMeshShadowAlpha(Mesh *mesh, const glm::mat4 &lightMVP, Texture *albedo=nullptr, bool doubleSided=true, float lodWeight=1.f, bool lodFadeReverse=false, bool lodDither=false)=0
Queue an alpha-cutout caster with explicit face-culling policy.
virtual void drawMeshGBuffer(Mesh *mesh, const glm::mat4 &mvp, const glm::mat4 &model, float nearZ, float farZ, Texture *albedo=nullptr, float tintR=1.f, float tintG=1.f, float tintB=1.f, float motionX=0.f, float motionY=0.f, float roughness=0.45f, float metallic=0.f)=0
Draws mesh g buffer.
virtual void begin3DFrameToCanvas(Canvas *canvas)=0
Begins 3 d frame to canvas.
virtual void endGBufferPass()=0
Ends g buffer pass.
virtual void setMesh3DShadowReceive(bool receive)=0
Sets the mesh 3 d shadow receive.
virtual void drawCanvasRGBA(Canvas *canvas, float x, float y, float w, float h, float r=1.f, float g=1.f, float b=1.f, float a=1.f)=0
Draws canvas rgba.
virtual void setMesh3DViewProj(const glm::mat4 &viewProj)=0
Sets the mesh 3 d view proj.
virtual void drawVoxelFaceInstances(const uint32_t *packed, int count, float originX, float originY, float originZ, const std::string &faceDir, Texture *atlas, int tilesPerRow=16, const uint32_t *ao=nullptr)=0
Draws voxel face instances.
virtual void setDirectionalLight(float dx, float dy, float dz, float r=1.f, float g=1.f, float b=1.f)=0
Sets the directional light.
virtual void setMesh3DLight(const glm::vec3 &dir, const glm::vec3 &color)=0
Sets the mesh 3 d light.
virtual void setMesh3DClusteredLighting(const ClusteredLightingUpload &upload)=0
Sets the mesh 3 d clustered lighting.
virtual void drawMesh(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint)=0
Draws mesh.
virtual void setMesh3DSkinInfluenceLimit(SkinInfluenceLimit count)=0
Select the influence limit consumed by subsequent mesh draws.
virtual void setMesh3DClip(float nearZ, float farZ)=0
Sets the mesh 3 d clip.
virtual void drawMeshGBufferAlpha(Mesh *mesh, const glm::mat4 &mvp, const glm::mat4 &model, float nearZ, float farZ, Texture *albedo=nullptr, float tintR=1.f, float tintG=1.f, float tintB=1.f, float motionX=0.f, float motionY=0.f, float roughness=0.45f, float metallic=0.f)=0
Draws mesh g buffer alpha.
virtual void drawMeshShadow(Mesh *mesh, const glm::mat4 &lightMVP, bool doubleSided=true)=0
Queue an opaque caster with explicit face-culling policy.
virtual void begin3DFrame()=0
Begins 3 d frame.
virtual void setMesh3DNormalTexture(Texture *normal)=0
Sets the mesh 3 d normal texture.
virtual void beginShadowPass(int cascadeIndex)=0
Begins shadow pass.
virtual void setMesh3DTexCellBomb(float cellScale, float strength, float rotAmount=1.f)=0
Sets the mesh 3 d tex cell bomb.
virtual void renderScene3DToCanvas(Canvas *canvas, Camera3D *camera)=0
Renders scene 3 d to canvas.
virtual void drawMeshShader(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint, Shader *shader)=0
Draws mesh shader.
virtual void setMesh3DShadows(const ShadowUpload &upload)=0
Sets the mesh 3 d shadows.
virtual void setMesh3DParallax(float scale, float minLayers=8.f, float maxLayers=32.f)=0
Sets the mesh 3 d parallax.
GPU mesh handle (+ optional CPU morph targets).
Definition Mesh.h:25
Frame-local scene recorder for 3D line primitives.
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
eve::Color Color
RGBA color used by every graphics draw call. Lives inside eve::graphics so including a graphics heade...
Definition Color.h:13
SkinInfluenceLimit
Number of strongest vertex influences retained by GPU skinning.
Definition IGraphics3D.h:19
CPU-built clustered lighting upload for one frame/camera. Point lights are clustered; directional lig...
Lighting3DPack public API.
Definition Light.h:172
Owning material parameter snapshot; texture pointers remain borrowed. Base color/metallic/roughness c...
Definition PbrSurface.h:218
ReflectionProbeUpload public API.
Definition IGraphics3D.h:26
ShadowUpload public API.
Definition Shadow.h:54
glm::vec4 color