载入中...
搜索中...
未找到
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 "common/Result.h"
9#include "graphics/Color.h"
10
11// Incomplete glm types suffice for const-reference / pointer parameters.
12#include <glm/fwd.hpp>
13
14#include <cstdint>
15#include <string>
16
17namespace eve::graphics {
18
20enum class SkinInfluenceLimit : int { One = 1, Two = 2, Four = 4 };
21struct PbrSurface;
22
23class Texture;
24struct ReflectionProbeUpload;
25
26class Canvas;
27class Camera3D;
28class Mesh;
29class PrimitiveSceneCanvas3D;
30class Shader;
31struct ClusteredLightingUpload;
32struct Lighting3DPack;
33struct ShadowUpload;
34
37public:
39 virtual ~IGraphics3D() = default;
40
42 virtual void render3D() = 0;
44 virtual void renderScene3DToCanvas(Canvas *canvas, Camera3D *camera) = 0;
46 virtual void setDirectionalLight(float dx, float dy, float dz, float r = 1.f, float g = 1.f,
47 float b = 1.f) = 0;
49 virtual void drawScene3DRGBA(float x, float y, float w, float h, float r = 1.f, float g = 1.f,
50 float b = 1.f, float a = 1.f) = 0;
52 virtual void drawCanvasRGBA(Canvas *canvas, float x, float y, float w, float h, float r = 1.f,
53 float g = 1.f, float b = 1.f, float a = 1.f) = 0;
54
56 virtual void begin3DFrame() = 0;
58 virtual void begin3DFrameToCanvas(Canvas *canvas) = 0;
60 virtual void end3DFrameToCanvas() = 0;
61
68 virtual void drawPrimitiveScene(const PrimitiveSceneCanvas3D &canvas) = 0;
69
71 virtual void setMesh3DViewProj(const glm::mat4 &viewProj) = 0;
73 virtual void setMesh3DView(const glm::mat4 &view) = 0;
75 virtual void setMesh3DClip(float nearZ, float farZ) = 0;
76
78 virtual void drawMesh(Mesh *mesh, const glm::mat4 &model, Texture *texture,
79 const Color &tint) = 0;
81 virtual void drawMeshShader(Mesh *mesh, const glm::mat4 &model, Texture *texture,
82 const Color &tint, Shader *shader) = 0;
83
89 virtual void setMesh3DSceneDepth(Texture *depth) = 0;
91 virtual void setMesh3DSceneColor(Texture *color) = 0;
93 virtual void setMesh3DMaterial(float metallic, float roughness) = 0;
99 [[nodiscard]] virtual Result<void> setMesh3DPbrSurface(const PbrSurface* surface) {
100 if (!surface) return Result<void>::success();
103 DiagnosticCode::Unsupported, "extended PBR material rendering is unavailable on this backend"));
104 }
105
107 virtual void setMesh3DTexCellBomb(float cellScale, float strength, float rotAmount = 1.f) = 0;
109 virtual void setMesh3DParallax(float scale, float minLayers = 8.f, float maxLayers = 32.f) = 0;
111 virtual void setMesh3DLighting(const Lighting3DPack &pack) = 0;
115 virtual void setMesh3DLight(const glm::vec3 &dir, const glm::vec3 &color) = 0;
117 virtual void setMesh3DCameraPos(const glm::vec3 &eye) = 0;
119 virtual void setCloudShadows(float strength, float worldCell, float time, float windSpeed,
120 float windAngle, float coverage, float detail) = 0;
122 virtual void setMesh3DEnv(Texture *cube, float intensity) = 0;
124 virtual void setMesh3DEnvProbe(const glm::vec3 &center, const glm::vec3 &extent) = 0;
126 virtual void setMesh3DReflectionProbes(const ReflectionProbeUpload &upload) = 0;
128 virtual void setMesh3DShadows(const ShadowUpload &upload) = 0;
130 virtual void setMesh3DShadowReceive(bool receive) = 0;
133
135 virtual void beginShadowPass(int cascadeIndex) = 0;
137 virtual void drawMeshShadow(Mesh *mesh, const glm::mat4 &lightMVP, bool doubleSided = true) = 0;
139 virtual void drawMeshShadowAlpha(Mesh *mesh, const glm::mat4 &lightMVP,
140 Texture *albedo = nullptr, bool doubleSided = true,
141 float lodWeight = 1.f, bool lodFadeReverse = false,
142 bool lodDither = false) = 0;
144 virtual void endShadowPass() = 0;
145
147 virtual void beginGBufferPass(int width, int height) = 0;
153 virtual void drawMeshGBuffer(Mesh *mesh, const glm::mat4 &mvp, const glm::mat4 &model, float nearZ, float farZ,
154 Texture *albedo = nullptr, float tintR = 1.f, float tintG = 1.f, float tintB = 1.f,
155 float motionX = 0.f, float motionY = 0.f, float roughness = 0.45f,
156 float metallic = 0.f, float tintA = 1.f) = 0;
161 virtual void drawMeshGBufferAlpha(Mesh *mesh, const glm::mat4 &mvp, const glm::mat4 &model, float nearZ, float farZ,
162 Texture *albedo = nullptr, float tintR = 1.f, float tintG = 1.f,
163 float tintB = 1.f, float motionX = 0.f, float motionY = 0.f,
164 float roughness = 0.45f, float metallic = 0.f, float tintA = 1.f) = 0;
166 virtual void endGBufferPass() = 0;
167
169 virtual void drawVoxelFaceInstances(const uint32_t *packed, int count, float originX,
170 float originY, float originZ, const std::string &faceDir,
171 Texture *atlas, int tilesPerRow = 16,
172 const uint32_t *ao = nullptr) = 0;
173};
174
175} // namespace eve::graphics
double y
double x
float w
Definition AnimClip.cpp:738
float ao
graphics::Texture * albedo
float strength
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
ActionGuidePack pack
std::string coverage
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
float roughness
bool doubleSided
Texture * normal
float metallic
OceanMeshSettings mesh
glm::dvec2 center
glm::dvec3 dx
glm::dvec3 dz
OceanSprayView view
Texture * texture
bool lodFadeReverse
glm::vec3 eye
float lodWeight
glm::mat4 viewProj
Shader * shader
glm::mat4 model
Move-only, checked operation results for the common layer.
float dy
Definition Shadow.cpp:151
int count
V3 dir
Definition TreeMesh.cpp:151
std::uint32_t depth
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
EVENGINE_API_BACKENDS public API.
Canvas public API.
Definition Canvas.h:17
3D frame / mesh / light / shadow rendering surface.
Definition IGraphics3D.h:36
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, float tintA=1.f)=0
Queue a GBuffer surface using the currently bound PBR material when present.
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.
Definition IGraphics3D.h:99
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 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 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, float tintA=1.f)=0
Queue a masked GBuffer surface; bound PBR uses the material cutoff and tintA. @ownership Mesh and tex...
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 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:26
Frame-local scene recorder for 3D line primitives.
Custom GPU program.
Definition Shader.h:41
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:15
卡牌游戏 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:20
CPU-built clustered lighting upload for one frame/camera. Point lights are clustered; directional lig...
Lighting3DPack public API.
Definition Light.h:171
Owning material parameter snapshot; texture pointers remain borrowed. Base color/metallic/roughness c...
Definition PbrSurface.h:240
ReflectionProbeUpload public API.
ShadowUpload public API.
Definition Shadow.h:62
glm::vec4 color