载入中...
搜索中...
未找到
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
18class Canvas;
19class Camera3D;
20class Mesh;
21class Shader;
22class Texture;
23struct ClusteredLightingUpload;
24struct Lighting3DPack;
25struct ShadowUpload;
26
29public:
30 virtual ~IGraphics3D() = default;
31
32 virtual void render3D() = 0;
33 virtual void renderScene3DToCanvas(Canvas *canvas, Camera3D *camera) = 0;
34 virtual void setDirectionalLight(float dx, float dy, float dz, float r = 1.f, float g = 1.f,
35 float b = 1.f) = 0;
36 virtual void drawScene3DRGBA(float x, float y, float w, float h, float r = 1.f, float g = 1.f,
37 float b = 1.f, float a = 1.f) = 0;
38 virtual void drawCanvasRGBA(Canvas *canvas, float x, float y, float w, float h, float r = 1.f,
39 float g = 1.f, float b = 1.f, float a = 1.f) = 0;
40
41 virtual void begin3DFrame() = 0;
42 virtual void begin3DFrameToCanvas(Canvas *canvas) = 0;
43 virtual void end3DFrameToCanvas() = 0;
44
45 virtual void setMesh3DViewProj(const glm::mat4 &viewProj) = 0;
46 virtual void setMesh3DView(const glm::mat4 &view) = 0;
47 virtual void setMesh3DClip(float nearZ, float farZ) = 0;
48
49 virtual void drawMesh(Mesh *mesh, const glm::mat4 &model, Texture *texture,
50 const Color &tint) = 0;
51 virtual void drawMeshShader(Mesh *mesh, const glm::mat4 &model, Texture *texture,
52 const Color &tint, Shader *shader) = 0;
53
56 virtual void setMesh3DSceneDepth(Texture *depth) = 0;
57 virtual void setMesh3DMaterial(float metallic, float roughness) = 0;
58 virtual void setMesh3DTexCellBomb(float cellScale, float strength, float rotAmount = 1.f) = 0;
59 virtual void setMesh3DParallax(float scale, float minLayers = 8.f, float maxLayers = 32.f) = 0;
60 virtual void setMesh3DLighting(const Lighting3DPack &pack) = 0;
61 virtual void setMesh3DClusteredLighting(const ClusteredLightingUpload &upload) = 0;
62 virtual void setMesh3DLight(const glm::vec3 &dir, const glm::vec3 &color) = 0;
63 virtual void setMesh3DCameraPos(const glm::vec3 &eye) = 0;
64 virtual void setCloudShadows(float strength, float worldCell, float time, float windSpeed,
65 float windAngle, float coverage, float detail) = 0;
66 virtual void setMesh3DEnv(Texture *cube, float intensity) = 0;
67 virtual void setMesh3DShadows(const ShadowUpload &upload) = 0;
68 virtual void setMesh3DShadowReceive(bool receive) = 0;
69
70 virtual void beginShadowPass(int cascadeIndex) = 0;
71 virtual void drawMeshShadow(Mesh *mesh, const glm::mat4 &lightMVP) = 0;
72 virtual void drawMeshShadowAlpha(Mesh *mesh, const glm::mat4 &lightMVP,
73 Texture *albedo = nullptr) = 0;
74 virtual void endShadowPass() = 0;
75
76 virtual void beginGBufferPass(int width, int height) = 0;
77 virtual void drawMeshGBuffer(Mesh *mesh, const glm::mat4 &mvp, const glm::mat4 &model,
78 float nearZ, float farZ, Texture *albedo = nullptr,
79 float tintR = 1.f, float tintG = 1.f, float tintB = 1.f) = 0;
80 virtual void drawMeshGBufferAlpha(Mesh *mesh, const glm::mat4 &mvp, const glm::mat4 &model,
81 float nearZ, float farZ, Texture *albedo = nullptr,
82 float tintR = 1.f, float tintG = 1.f,
83 float tintB = 1.f) = 0;
84 virtual void endGBufferPass() = 0;
85
86 virtual void drawVoxelFaceInstances(const uint32_t *packed, int count, float originX,
87 float originY, float originZ, const std::string &faceDir,
88 Texture *atlas, int tilesPerRow = 16,
89 const uint32_t *ao = nullptr) = 0;
90};
91
92} // namespace eve::graphics
int y
Definition Grass.cpp:135
float height
Definition Grass.cpp:235
int x
Definition Grass.cpp:135
int h
int w
float depth
uint32_t a
uint32_t b
float roughness
Texture * normal
Texture * albedo
float metallic
int width
glm::vec3 eye
Mesh * mesh
glm::mat4 viewProj
Shader * shader
glm::mat4 view
glm::mat4 model
image::ImageData::Colorf color
float scale
Definition TreeMesh.cpp:122
V3 dir
Definition TreeMesh.cpp:121
3D frame / mesh / light / shadow rendering surface.
Definition IGraphics3D.h:28
virtual void setMesh3DSceneDepth(Texture *depth)=0
virtual void setMesh3DView(const glm::mat4 &view)=0
virtual void render3D()=0
virtual void setMesh3DHeightTexture(Texture *height)=0
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)=0
virtual void setMesh3DLighting(const Lighting3DPack &pack)=0
virtual void endShadowPass()=0
virtual ~IGraphics3D()=default
virtual void setMesh3DMaterial(float metallic, float roughness)=0
virtual void setMesh3DEnv(Texture *cube, float intensity)=0
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
virtual void setMesh3DCameraPos(const glm::vec3 &eye)=0
virtual void beginGBufferPass(int width, int height)=0
virtual void end3DFrameToCanvas()=0
virtual void setCloudShadows(float strength, float worldCell, float time, float windSpeed, float windAngle, float coverage, float detail)=0
virtual void begin3DFrameToCanvas(Canvas *canvas)=0
virtual void endGBufferPass()=0
virtual void setMesh3DShadowReceive(bool receive)=0
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
virtual void setMesh3DViewProj(const glm::mat4 &viewProj)=0
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
virtual void setDirectionalLight(float dx, float dy, float dz, float r=1.f, float g=1.f, float b=1.f)=0
virtual void setMesh3DLight(const glm::vec3 &dir, const glm::vec3 &color)=0
virtual void drawMeshShadowAlpha(Mesh *mesh, const glm::mat4 &lightMVP, Texture *albedo=nullptr)=0
virtual void setMesh3DClusteredLighting(const ClusteredLightingUpload &upload)=0
virtual void drawMesh(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint)=0
virtual void setMesh3DClip(float nearZ, float farZ)=0
virtual void drawMeshShadow(Mesh *mesh, const glm::mat4 &lightMVP)=0
virtual void begin3DFrame()=0
virtual void setMesh3DNormalTexture(Texture *normal)=0
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)=0
virtual void beginShadowPass(int cascadeIndex)=0
virtual void setMesh3DTexCellBomb(float cellScale, float strength, float rotAmount=1.f)=0
virtual void renderScene3DToCanvas(Canvas *canvas, Camera3D *camera)=0
virtual void drawMeshShader(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint, Shader *shader)=0
virtual void setMesh3DShadows(const ShadowUpload &upload)=0
virtual void setMesh3DParallax(float scale, float minLayers=8.f, float maxLayers=32.f)=0
GPU mesh handle (+ optional CPU morph targets).
Definition Mesh.h:18
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
glm::vec4 Color
RGBA color used by every graphics draw call. Lives inside eve::graphics so including a graphics heade...
Definition Color.h:13
CPU-built clustered lighting upload for one frame/camera. Point lights are clustered; directional lig...