载入中...
搜索中...
未找到
Graphics.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include <assimp/matrix4x4.h>
6#include <cstdint>
7#include <glm/mat4x4.hpp>
8#include <glm/vec2.hpp>
9#include <glm/vec3.hpp>
10#include <glm/vec4.hpp>
11#include <memory>
12#include <optional>
13#include <span>
14#include <string>
15#include <vector>
17#include "common/Module.h"
18#include "common/Result.h"
20#include "graphics/BlendMode.h"
21#include "graphics/Canvas.h"
22#include "graphics/Color.h"
23#include "graphics/Font.h"
30#include "graphics/IPostFX.h"
35
36struct aiMesh;
37
38namespace eve {
39class Subscription;
40}
41
42namespace eve::graphics {
43struct PbrSurface;
44struct ShaderResourceInputs;
45
46
47class AmbientOcclusion;
48class AntiAliasing;
49class Bloom;
50class DepthOfField;
51class Exposure;
52class DepthPyramid;
53class Camera3D;
54class Drawable;
55class GBuffer;
56class GlobalIllumination;
57class GrassField;
58namespace hair {
59class GroomInstance;
60}
61class Material;
62class Mesh;
63class PrimitiveScene;
64
71 int x = 0;
72 int y = 0;
73 int width = 0;
74 int height = 0;
75 std::span<const std::uint8_t> rgba;
76 std::size_t bytesPerRow = 0;
77};
78
87 std::uint32_t vertexCount = 0;
88 std::uint32_t indexCount = 0;
89 std::uint32_t vertexStride = 0;
90 std::uint32_t indexElementSize = 0;
91};
92class Outline;
93class Quad;
94class RenderControl;
95class Renderable2D;
96class AlphaMask;
97class DepthOfField;
98class MapFog;
100class Shader;
102class Texture;
103class Volumetric;
104class Water;
105class Waterfall;
109struct Lighting2DUBO;
110struct Lighting3DPack;
111struct ShadowUpload;
112struct TextureCreateInfo;
113struct TextureSampler;
114
116 public Canvas,
117 public IWindowSurfaceHost,
118 public IGraphics2D,
119 public IGraphics3D,
120 public ICanvasFactory,
121 public ICanvasTarget,
122 public IResourceFactory,
123 public ISolidRectRenderer,
124 public IPostFX,
125 public IFramePresentation {
126public:
129 Graphics();
131 ~Graphics() override;
132
136 virtual void reset();
137
139 virtual void clearScreen();
141 virtual void setBackgroundColorRGBA(float r, float g, float b, float a = 1.f);
143 virtual void drawSolidRectRGBA(float x, float y, float w, float h, float r, float g, float b, float a = 1.f);
145 virtual void drawTexturedRectRGBA(Texture *texture, float x, float y, float w, float h, float r, float g, float b,
146 float a = 1.f);
148 virtual void drawTexturedRectRotatedRGBA(Texture* texture, float cx, float cy, float w, float h, float degrees,
149 float r, float g, float b, float a = 1.f);
151 virtual void drawSolidRect(float x, float y, float w, float h, float r, float g, float b, float a = 1.f);
153 virtual void drawTexturedRect(Texture *texture, float x, float y, float w, float h, float r, float g, float b,
154 float a = 1.f);
156 void renderSprites();
158 Renderable2D *newSprite2D();
165 Texture *newTextureFromImageData(image::ImageData *data, bool repeatU = false,
166 bool repeatV = false);
168 Texture *newTextureFromImageData(image::ImageData *data, const TextureCreateInfo &info);
169
178 [[nodiscard]] eve::Result<void> updateTextureFromImageData(Texture* texture, image::ImageData* data);
179
184 Texture* newTextureWithSampler(image::ImageData* data, bool repeatU, bool repeatV, bool generateMipmaps,
185 float maxAnisotropy, const std::string& filter, const std::string& mipmap,
186 float lodBias = 0.f);
187
196 virtual void setTextureSampler(Texture *texture, const std::string &filter, const std::string &mipmap,
197 float maxAnisotropy, float lodBias);
198
200 virtual void present() = 0;
201
203 virtual std::string getBackendName() const = 0;
204
214 virtual bool supportsRuntimeGlslCompilation() const { return false; }
224 [[nodiscard]] std::weak_ptr<const void> resourceLifetime() const;
230 [[nodiscard]] Result<eve::Subscription> onResourcesRetiring(std::function<void()> callback) const;
231
232
238 virtual bool supportsGBufferPost() const { return true; }
239
240 // ---- GPU-driven rendering (stage 1): capability-gated seam ----
241 // Backends without the GPU-driven path (WebGPU, software) return false and
242 // RenderSystem3D falls back to the legacy per-draw path.
243
245 virtual bool supportsDeferredLighting() const { return false; }
246
252 virtual void drawDeferredLighting() {}
253
255 virtual bool supportsGpuDriven3D() const { return false; }
256
262 virtual bool supportsRayTracing() const { return false; }
263
265 virtual RayTracingCaps rayTracingCaps() const { return {}; }
266
268 virtual bool gpuDrivenEnabled() const { return false; }
269
271 virtual void gpuDrivenSetEnabled(bool enabled) { (void)enabled; }
272
274 virtual uint32_t gpuDrivenMeshRecord(Mesh* mesh) {
275 (void)mesh;
277 }
278
281 (void)material;
283 }
284
293 (void)material;
295 return Result<void>::failure(Diagnostic::error(
296 DiagnosticCode::Unsupported, "GPU-driven material records are unavailable on this backend"));
297 }
298
305 (void)material;
306 return false;
307 }
308
310 virtual uint32_t gpuDrivenReflectionProbeSlot(Texture *cubemap) {
311 (void)cubemap;
313 }
314
315 // ---- GPU-resident 2D particles ---------------------------------------
316
318 virtual bool supportsGpuParticles() const { return false; }
319
321 virtual bool canSubmitGpuParticles() const { return false; }
322
325 (void)capacity;
327 }
328
331
334
338 const GpuParticleSpawn* spawns, std::uint32_t spawnCount) {
339 (void)handle;
340 (void)update;
341 (void)spawns;
342 (void)spawnCount;
343 return false;
344 }
345
348 (void)handle;
349 (void)draw;
350 return false;
351 }
352
355 (void)handle;
356 return {};
357 }
358
366 (void)instances;
367 (void)instanceCount;
368 return false;
369 }
370
379 (void)batch;
380 return GpuResidentSubmitStatus::Unsupported;
381 }
382
383 // ---- GPU-driven rendering (stage 2): GPU cull seam ----
384 // Backends without the compute cull chain return false / no-op; the
385 // renderer then falls back to gpuDrivenSubmitOpaque (stage 1) or legacy.
386
388 virtual bool gpuDrivenCullEnabled() const { return false; }
389
391 virtual bool gpuDrivenScenePassPending() const { return false; }
392
394 virtual bool gpuDrivenCullBegin(const GpuInstance *instances, uint32_t instanceCount) {
395 (void)instances;
396 (void)instanceCount;
397 return false;
398 }
399
401 virtual void gpuDrivenCullEmit(const glm::mat4& viewProj, const glm::vec3& eye, float fovYDeg, float nearZ,
402 float farZ) {
403 (void)viewProj;
404 (void)eye;
405 (void)fovYDeg;
406 (void)nearZ;
407 (void)farZ;
408 }
409
411 virtual void gpuDrivenOpenScenePass() {}
412
414 virtual void gpuDrivenDrawOpaque() {}
415
416 // ---- GPU-driven rendering (stage 3): visibility buffer + resolve seam ----
417 // Backends without the resolve path return false / no-op; the renderer
418 // keeps using gpuDrivenDrawOpaque (forward shading).
419
421 virtual bool gpuDrivenResolveWanted() const { return false; }
422
424 virtual void gpuDrivenRecordVisPass() {}
425
427 virtual void gpuDrivenResolve() {}
428
429 // ---- GPU-driven rendering (stage 3): virtual-geometry seam ----
430 // Backends without VG support return kInvalidGpuDrivenSlot / false; the
431 // renderer then draws the mesh through the normal GPU-driven path.
432
434 virtual std::uint32_t gpuDrivenVgUpload(const GpuVgAssetUpload &asset) {
435 (void)asset;
437 }
438
440 virtual std::uint32_t gpuDrivenVgAssetId(Mesh *mesh) const {
441 (void)mesh;
443 }
444
446 virtual bool gpuDrivenVgAttachToMesh(Mesh *mesh, std::uint32_t vgAssetId) {
447 (void)mesh;
448 (void)vgAssetId;
449 return false;
450 }
451
458 virtual bool gpuDrivenVgSetInstance(std::uint32_t vgAssetId, const glm::mat4 &model,
459 std::uint32_t materialId) {
460 (void)vgAssetId;
461 (void)model;
462 (void)materialId;
463 return false;
464 }
465
467 virtual void gpuDrivenVgComputeSection(const glm::mat4& viewProj, const glm::vec3& eye, float fovYDeg, float nearZ,
468 float farZ) {
469 (void)viewProj;
470 (void)eye;
471 (void)fovYDeg;
472 (void)nearZ;
473 (void)farZ;
474 }
475
480 virtual void initWithWindow(void *nativeWindow) = 0;
481
491 virtual void initHeadless(int width, int height);
492
494 virtual bool isHeadless() const { return false; }
495
499 virtual void setViewportSize(int width, int height, int pixelwidth, int pixelheight) = 0;
500
502 int getWidth() const { return width; }
504 int getHeight() const { return height; }
506 int getPixelWidth() const { return pixelWidth; }
508 int getPixelHeight() const { return pixelHeight; }
509
511 double getCurrentDPIScale() const { return (width > 0) ? double(pixelWidth) / double(width) : 1.0; }
513 double getScreenDPIScale() const { return getCurrentDPIScale(); }
514
521 [[nodiscard]] std::shared_ptr<PrimitiveScene> getPrimitiveScene() const noexcept { return primitiveScene_; }
522
524 virtual void drawSolidRect(float x, float y, float w, float h, const Color &color,
525 BlendMode blend = BlendMode::Alpha) = 0;
526
528 virtual void drawSolidRectRotated(float cx, float cy, float w, float h, float degrees, const Color& color,
529 BlendMode blend = BlendMode::Alpha) = 0;
530
535 virtual Texture *newTexture(int width, int height, const uint8_t *rgba, bool repeatU = false,
536 bool repeatV = false) = 0;
537
542 virtual Texture* newTexture(int width, int height, const uint8_t* rgba, const TextureCreateInfo& info) = 0;
543
548 virtual Texture *newCubemap(int faceSize, const uint8_t *rgbaFaces) = 0;
549
554 virtual Texture *newCubemap(int faceSize, const uint8_t *rgbaFaces,
555 const TextureCreateInfo &info) = 0;
556
562 virtual Texture *newHDRCubemap(int faceSize) {
563 (void)faceSize;
564 return nullptr;
565 }
566
572 virtual bool copyHDRCanvasToCubemapFace(Canvas *source, Texture *cubemap, int face) {
573 (void)source;
574 (void)cubemap;
575 (void)face;
576 return false;
577 }
578
590 virtual bool copyHDRCanvasesToCubemap(Canvas* const* sources, int faceCount, Texture* cubemap) {
591 if (!sources || faceCount < 1 || faceCount > 6) return false;
592 for (int face = 0; face < faceCount; ++face)
593 if (!copyHDRCanvasToCubemapFace(sources[face], cubemap, face)) return false;
594 return true;
595 }
596
601 virtual bool filterHDRReflectionCubemap(Texture *cubemap, int sampleCount = 64) {
602 (void)cubemap;
603 (void)sampleCount;
604 return false;
605 }
606
609
612
623 virtual bool updateTexture(Texture *texture, int width, int height, const uint8_t *rgba) = 0;
624
645 int width, int height) {
646 (void)texture;
647 (void)source;
648 (void)width;
649 (void)height;
652 "Resident texture upload is unavailable",
653 "graphics.updateTextureFromResidentRgba8"));
654 }
655
670 [[nodiscard]] virtual eve::Result<void> updateTextureRegion(Texture* texture, int x, int y, int width, int height,
671 std::span<const std::uint8_t> rgba,
672 std::size_t bytesPerRow = 0) = 0;
673
683 [[nodiscard]] virtual eve::Result<void> updateTextureRegions(Texture* texture,
684 std::span<const TextureRegionUpload> regions) = 0;
685
690 virtual void setTextureSampler(Texture *texture, const TextureSampler &sampler) = 0;
691
693 virtual float getMaxAnisotropy() const = 0;
694
700 virtual Texture *newTextureFromFile(const std::string &filename) = 0;
705 Texture *newTextureFromFileRepeated(const std::string &filename, bool repeatU, bool repeatV);
706
712 void ensureFileTexturesReady();
713
715 virtual bool reloadTextureFromFile(const std::string &filename) = 0;
716
733 virtual bool releaseTexture(Texture *texture) {
734 (void)texture;
735 return false;
736 }
737
741 virtual void drawTexturedRect(Texture* texture, float x, float y, float w, float h, const Color& color) = 0;
742
744 virtual void drawTexturedRectShader(Texture* texture, Shader* shader, float x, float y, float w, float h,
745 const Color& color) = 0;
746
748 virtual void drawTexturedRectUV(Texture* texture, float x, float y, float w, float h, float u0, float v0, float u1,
749 float v1, const Color& color) = 0;
750
752 virtual void drawTexturedRectShaderUV(Texture* texture, Shader* shader, float x, float y, float w, float h,
753 float u0, float v0, float u1, float v1, const Color& color,
754 bool rotatedUV = false, BlendMode blend = BlendMode::Alpha) = 0;
755
760 virtual void drawTexturedRectShaderUVRotated(Texture* texture, Shader* shader, float cx, float cy, float w, float h,
761 float degrees, float u0, float v0, float u1, float v1,
762 const Color &color, bool rotatedUV = false,
763 BlendMode blend = BlendMode::Alpha) = 0;
764
769 virtual void drawTexturedRectShaderDepth(Texture* color, Texture* depth, Shader* shader, float x, float y, float w,
770 float h, const Color& tint) = 0;
771
774 float x, float y, float w, float h, const Color& tint) = 0;
775
778 Shader* shader, float x, float y, float w, float h, const Color& tint) = 0;
779
782 Texture* specular, Shader* shader, float x, float y, float w, float h,
783 const Color &tint) = 0;
784
793 enum class SceneColorDistortionStatus { Queued, Unavailable };
794
797 float w, float h, float degrees, float u0,
798 float v0, float u1, float v1,
799 float strengthPixels, float opacity,
800 bool rotatedUV = false) {
801 return SceneColorDistortionStatus::Unavailable;
802 }
803
808 virtual void drawTexturedRectLitUV(Texture *albedo, Texture *normal, float x, float y, float w, float h, float u0,
809 float v0, float u1, float v1, const Color &color,
810 BlendMode blend = BlendMode::Alpha) = 0;
811
817 virtual void drawTexturedRectLitUVRotated(Texture *albedo, Texture *normal, float cx, float cy, float w, float h,
818 float degrees, float u0, float v0, float u1, float v1, const Color &color,
819 BlendMode blend = BlendMode::Alpha) = 0;
820
822 virtual void setLighting2D(const Lighting2DUBO &ubo) = 0;
823
825 Quad *newQuad(int x, int y, int w, int h);
826
830 virtual Mesh *newMeshFromAssimp(const ::aiMesh &mesh) = 0;
831
837 virtual Mesh *newMeshFromAssimp(const ::aiMesh &mesh, const aiMatrix4x4 &worldTransform) = 0;
838
847 virtual Mesh *newMeshFromArrays(const float *posXYZ, const float *nrmXYZ, const float *uvST,
848 int vertexCount, const uint32_t *indices, int indexCount) = 0;
850 virtual Mesh *newMeshFromArraysColored(const float *posXYZ, const float *nrmXYZ, const float *uvST,
851 const float *colorRGBA, int vertexCount,
852 const uint32_t *indices, int indexCount) = 0;
853
859 [[nodiscard]] virtual std::optional<MeshBackendDescriptor> describeMesh(Mesh *mesh) const {
860 (void)mesh;
861 return std::nullopt;
862 }
863
875 virtual bool updateMeshVertices(Mesh *mesh, const float *posXYZ, const float *nrmXYZ,
876 const float *uvST, int vertexCount, const uint32_t *indices,
877 int indexCount) = 0;
878
882 virtual bool setMeshSkinningData(Mesh *mesh, const uint16_t *joints4, const float *weights4,
883 int vertexCount) {
884 (void)mesh;
885 (void)joints4;
886 (void)weights4;
887 (void)vertexCount;
888 return false;
889 }
890
895 virtual bool bakeMeshMorph(Mesh *mesh) = 0;
896
901 virtual Mesh *newMeshSphere(int slices = 32, int stacks = 16) = 0;
902
908 virtual Mesh *newMeshCylinder(int slices = 32, int stacks = 1, bool caps = true) = 0;
909
914 Mesh *newMeshCube(float size = 1.f);
915
927 virtual bool releaseMesh(Mesh *mesh) {
928 (void)mesh;
929 return false;
930 }
931
933 virtual void render3D();
939 virtual void renderScene3DToCanvas(Canvas *canvas, Camera3D *camera);
941 virtual void setDirectionalLight(float dx, float dy, float dz, float r = 1.f, float g = 1.f, float b = 1.f);
942
949 virtual void drawScene3DRGBA(float x, float y, float w, float h, float r = 1.f, float g = 1.f, float b = 1.f,
950 float a = 1.f);
952 void drawScene3D(float x, float y, float w, float h) { drawScene3DRGBA(x, y, w, h, 1.f, 1.f, 1.f, 1.f); }
953
955 virtual void drawCanvasRGBA(Canvas *canvas, float x, float y, float w, float h, float r = 1.f, float g = 1.f,
956 float b = 1.f, float a = 1.f);
958 void drawCanvas(Canvas *canvas, float x, float y, float w, float h) {
959 drawCanvasRGBA(canvas, x, y, w, h, 1.f, 1.f, 1.f, 1.f);
960 }
961
966 virtual void pushValidationScope() = 0;
968 virtual void popValidationScope() = 0;
969
974 Material *newMaterial();
975
980 RenderControl *getRenderControl();
981
987 virtual void beginGBufferPass(int width, int height) = 0;
989 virtual void drawMeshGBuffer(Mesh* mesh, const glm::mat4& mvp, const glm::mat4& model, float nearZ, float farZ,
990 Texture* albedo = nullptr, float tintR = 1.f, float tintG = 1.f, float tintB = 1.f,
991 float motionX = 0.f, float motionY = 0.f, float roughness = 0.45f,
992 float metallic = 0.f) = 0;
999 virtual void drawMeshGBufferAlpha(Mesh* mesh, const glm::mat4& mvp, const glm::mat4& model, float nearZ, float farZ,
1000 Texture* albedo = nullptr, float tintR = 1.f, float tintG = 1.f,
1001 float tintB = 1.f, float motionX = 0.f, float motionY = 0.f,
1002 float roughness = 0.45f, float metallic = 0.f) = 0;
1004 virtual void endGBufferPass() = 0;
1005
1013 virtual void begin3DFrame() = 0;
1014
1022 virtual void begin3DFrameToCanvas(Canvas *canvas) = 0;
1024 virtual void end3DFrameToCanvas() = 0;
1025
1030 virtual float getLastOffscreen3DGpuDurationMs() const { return 0.f; }
1031
1035 virtual void setMesh3DViewProj(const glm::mat4 &viewProj) = 0;
1036
1038 virtual void setMesh3DView(const glm::mat4 &view) = 0;
1039
1041 virtual void setMesh3DClip(float nearZ, float farZ) = 0;
1042
1047 virtual Texture *getSceneColorTexture() { return nullptr; }
1049 virtual Texture* getSceneLinearDepthTexture() { return nullptr; }
1050
1059 Mesh *mesh = nullptr;
1060 glm::mat4 model{1.f};
1061 glm::vec4 idColor{0.f, 0.f, 0.f, 1.f};
1062 };
1066 virtual image::ImageData *renderEntityIdMask(const std::vector<EntityIdDraw> &draws,
1067 const glm::mat4 &viewProj, int w, int h) {
1068 (void)draws;
1069 (void)viewProj;
1070 (void)w;
1071 (void)h;
1072 return nullptr;
1073 }
1074
1081 virtual image::ImageData *readGBufferToImageData(const std::string &attachment) {
1082 (void)attachment;
1083 return nullptr;
1084 }
1091 virtual image::ImageData *readDecalLayerToImageData(const std::string &attachment) {
1092 (void)attachment;
1093 return nullptr;
1094 }
1095
1097 virtual void drawMesh(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint) = 0;
1098
1100 virtual void drawMeshShader(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint,
1101 Shader *shader) = 0;
1102
1116 [[nodiscard]] virtual Result<void> drawMeshShaderInstances(Mesh &mesh, Shader &shader, const glm::mat4 &model,
1117 const Color &tint, std::uint32_t first,
1118 std::uint32_t count) {
1119 (void)mesh;
1120 (void)shader;
1121 (void)model;
1122 (void)tint;
1123 (void)first;
1124 (void)count;
1126 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported,
1127 "Custom mesh instancing is unavailable on this backend",
1128 "graphics.instances"));
1129 }
1130
1133
1135 virtual void setMesh3DPackedNormalMask(bool enabled) = 0;
1136
1139
1146 virtual void setMesh3DVirtualTexture(bool enabled, int pageCountX, int pageCountY, int atlasSlotsX, int atlasSlotsY,
1147 float borderFraction) = 0;
1148
1155
1166
1168 enum class Mesh3DSceneColorCaptureStatus { ExplicitOverride, Scheduled, Captured, HistoryReuse, Unavailable };
1169
1182 return Mesh3DSceneColorCaptureStatus::HistoryReuse;
1183 }
1184
1186 virtual void setMesh3DMaterial(float metallic, float roughness) = 0;
1192 [[nodiscard]] virtual Result<void> setMesh3DPbrSurface(const PbrSurface* surface) {
1193 if (!surface) return Result<void>::success();
1195 return Result<void>::failure(Diagnostic::error(
1196 DiagnosticCode::Unsupported, "extended PBR material rendering is unavailable on this backend"));
1197 }
1198
1200 virtual void setMesh3DSurface(SurfaceMode mode, BlendMode blend, bool depthWrite, bool doubleSided,
1201 float alphaCutoff, const std::string& alphaTechnique = "cutoff") = 0;
1202
1208 virtual void setMesh3DTexCellBomb(float cellScale, float strength, float rotAmount = 1.f) = 0;
1209
1215 virtual void setMesh3DParallax(float scale, float minLayers = 8.f, float maxLayers = 32.f) = 0;
1216
1218 virtual void setMesh3DLodDither(float weight, bool reverse, bool enabled) = 0;
1219
1221 virtual void setMesh3DLighting(const Lighting3DPack &pack) = 0;
1222
1228 virtual void setCloudShadows(float strength, float worldCell, float time, float windSpeed, float windAngle,
1229 float coverage, float detail) = 0;
1230
1236
1242 virtual void setMesh3DClusteredActive(bool active) = 0;
1243
1248 virtual void setMesh3DSSAO(float intensity) = 0;
1249
1251 virtual void setMesh3DLight(const glm::vec3 &dir, const glm::vec3 &color) = 0;
1252
1254 virtual void setMesh3DCameraPos(const glm::vec3 &eye) = 0;
1255
1264 virtual void drawVoxelFaceInstances(const uint32_t* packed, int count, float originX, float originY, float originZ,
1265 const std::string& faceDir, Texture* atlas, int tilesPerRow = 16,
1266 const uint32_t *ao = nullptr) = 0;
1267
1274 virtual bool supportsDecal() const { return true; }
1275
1282 virtual void beginDecalPass(int width, int height) = 0;
1283
1286 virtual void setDecalCamera(const glm::mat4 &viewProj, float nearZ, float farZ) = 0;
1287
1303 virtual void drawDecal(const glm::mat4 &model, Texture *albedo, Texture *normal,
1304 Texture *params, const float uvRect[4], float fade,
1305 float normalStrength, float roughnessStrength, float metalStrength,
1306 float emissiveStrength, int blendMode = 0, int projectionMode = 0,
1307 float blendSharpness = 4.f, float parallaxScale = 0.f,
1308 float parallaxMinLayers = 8.f, float parallaxMaxLayers = 24.f,
1309 float edgeFadeWidth = 0.06f) = 0;
1311 virtual void endDecalPass() = 0;
1312
1318 virtual void setMesh3DEnv(Texture *cube, float intensity) = 0;
1320 virtual void setMesh3DEnvProbe(const glm::vec3 &center, const glm::vec3 &extent) = 0;
1322 virtual void setMesh3DReflectionProbes(const ReflectionProbeUpload &upload) = 0;
1325 enum class SceneToneMapping { None, Aces, Filmic };
1327 enum class DisplayOutputMode { Sdr, Auto, Hdr10, ScRgb };
1329 enum class DisplayColorSpace { Sdr, ScRgb, Hdr10 };
1332 bool sdr = true;
1333 bool hdr10 = false;
1334 bool scRgb = false;
1335 };
1345 [[nodiscard]] virtual Result<void> setSceneToneMapping(SceneToneMapping mode);
1347 virtual SceneToneMapping getSceneToneMapping() const { return SceneToneMapping::Aces; }
1357 [[nodiscard]] virtual Result<void> setDisplayOutputMode(DisplayOutputMode mode);
1359 virtual DisplayOutputMode getDisplayOutputMode() const;
1366 [[nodiscard]] virtual Result<void> setDisplayHdrCalibration(float paperWhiteNits, float peakNits);
1368 virtual float getDisplayPaperWhiteNits() const;
1370 virtual float getDisplayPeakNits() const;
1372 virtual DisplayColorSpace getActiveDisplayColorSpace() const;
1374 virtual bool isDisplayHdrActive() const;
1380 [[nodiscard]] virtual Result<DisplayOutputSupport> queryDisplayOutputSupport() const;
1385 [[nodiscard]] virtual Result<void> setScenePhotographicVignette(float intensity);
1387 virtual float getScenePhotographicVignette() const { return 0; }
1389 virtual void setSceneExposure(float exposure) = 0;
1391 virtual float getSceneExposure() const = 0;
1393 virtual void setSceneColorFilter(const glm::vec3& color) = 0;
1395 virtual glm::vec3 getSceneColorFilter() const = 0;
1397 virtual void setSceneLiftGammaGain(const glm::vec3& lift, const glm::vec3& inverseGamma, const glm::vec3& gain) = 0;
1399 virtual glm::vec3 getSceneLift() const = 0;
1401 virtual glm::vec3 getSceneInverseGamma() const = 0;
1403 virtual glm::vec3 getSceneGain() const = 0;
1405 virtual void setSceneTransitionFx(float vignette, float vignetteSmoothness, float lensDistortion,
1406 float lensScale) = 0;
1408 virtual float getSceneTransitionVignette() const = 0;
1410 virtual float getSceneTransitionVignetteSmoothness() const = 0;
1412 virtual float getSceneTransitionLensDistortion() const = 0;
1414 virtual float getSceneTransitionLensScale() const = 0;
1416 virtual void setSceneAutoExposure(bool enabled, float minEV, float maxEV) = 0;
1418 virtual bool getSceneAutoExposure() const = 0;
1420 virtual float getSceneAutoExposureMinEV() const = 0;
1422 virtual float getSceneAutoExposureMaxEV() const = 0;
1424 virtual void setSceneBloom(float intensity, float threshold) = 0;
1426 virtual float getSceneBloomIntensity() const = 0;
1428 virtual float getSceneBloomThreshold() const = 0;
1437 virtual void setSceneDepthOfField(float focusDistance, float maxBlurPx, float focusRange,
1438 float nearZ, float farZ) = 0;
1440 virtual float getSceneDofFocusDistance() const = 0;
1442 virtual float getSceneDofMaxBlur() const = 0;
1444 virtual float getSceneDofFocusRange() const = 0;
1446 virtual float getSceneDofNearZ() const = 0;
1448 virtual float getSceneDofFarZ() const = 0;
1449
1451 virtual void setMesh3DShadows(const ShadowUpload &upload) = 0;
1452
1454 virtual void setMesh3DShadowReceive(bool receive) = 0;
1455
1462
1468 virtual void beginShadowPass(int cascadeIndex) = 0;
1471 virtual void drawMeshShadow(Mesh *mesh, const glm::mat4 &lightMVP, bool doubleSided = true) = 0;
1479 virtual void drawMeshShadowAlpha(Mesh* mesh, const glm::mat4& lightMVP, Texture* albedo = nullptr,
1480 bool doubleSided = true, float lodWeight = 1.f,
1481 bool lodFadeReverse = false, bool lodDither = false) = 0;
1483 virtual void endShadowPass() = 0;
1484
1487 bool v = frameHad3D;
1488 return v;
1489 }
1491 bool had3DThisFrame() const { return frameHad3D; }
1492
1494 Color getBackgroundColor() const { return backgroundColor; }
1496 void setBackgroundColor(const Color &c) { backgroundColor = c; }
1497
1502 virtual void setScreenReadbackEnabled(bool enabled) { screenReadbackEnabled = enabled; }
1504 bool isScreenReadbackEnabled() const { return screenReadbackEnabled; }
1505
1510 bool saveFramePng(const std::string &path);
1511
1517 virtual bool beginFrameReadback(const std::string &path) {
1518 (void)path;
1519 return false;
1520 }
1522 virtual int frameReadbackStatus() const { return 0; }
1523
1528 virtual void setVSync(bool enabled) { vsyncEnabled = enabled; }
1530 bool isVSync() const { return vsyncEnabled; }
1532 void setVSyncCount(int count) override { presentationVSyncCount_=count;setVSync(count!=0); }
1534 int getVSyncCount() const noexcept override{return presentationVSyncCount_;}
1535
1541 virtual void setMsaaSamples(int samples) { msaaSamples = samples > 0 ? samples : 0; }
1543 virtual int getMsaaSamples() const { return msaaSamples; }
1544
1546 void setActive(bool active) override {
1547 graphicsActive = active;
1548 if (active) markSwapchainDirty();
1549 }
1551 bool isActive() const { return graphicsActive; }
1552
1554 virtual void markSwapchainDirty() {}
1555
1561 void requestSurfaceRecreate() override {}
1562
1577 for (auto &cb : windowDestroyedCallbacks_) cb.first(cb.second);
1578 windowDestroyedCallbacks_.clear();
1580 clearPresentOverlay();
1581 }
1582
1585 presentOverlayFn_ = nullptr;
1586 presentOverlayUser_ = nullptr;
1587 }
1588
1594 using WindowDestroyedCallback = void (*)(void *userdata);
1597 windowDestroyedCallbacks_.emplace_back(cb, userdata);
1598 }
1599
1606 using PresentOverlayFn = bool (*)(void *userdata, void *commandBuffer);
1608 void setPresentOverlay(PresentOverlayFn fn, void *userdata) {
1609 presentOverlayFn_ = fn;
1610 presentOverlayUser_ = userdata;
1611 }
1613 PresentOverlayFn getPresentOverlay() const { return presentOverlayFn_; }
1615 void *getPresentOverlayUser() const { return presentOverlayUser_; }
1616
1624 Font *newFont(font::FontData *data, std::string charset = Font::defaultCharset());
1625
1627 virtual void setFont(Font *font) { currentFont = font; }
1629 Font *getFont() const { return currentFont; }
1630
1641 virtual void print(const std::string& text, float x, float y, const Color& color = Color(1.f, 1.f, 1.f, 1.f),
1642 float scale = 1.f);
1643
1656 virtual void drawText(Font *font, const std::string &text, float x, float y,
1657 const Color &color = Color(1.f, 1.f, 1.f, 1.f), float scale = 1.f);
1658
1674 void drawTextRGBA(Font* font, const std::string& text, float x, float y, float r, float g, float b, float a,
1675 float scale = 1.f) {
1677 drawText(font, text, x, y, Color(r, g, b, a), scale);
1678 }
1679
1693 void printRGBA(const std::string& text, float x, float y, float r, float g, float b, float a, float scale = 1.f) {
1695 print(text, x, y, Color(r, g, b, a), scale);
1696 }
1697
1699 virtual void setShader(Shader *shader);
1701 virtual void setShader();
1702
1704 Shader *getShader() const { return currentShader; }
1705
1710 virtual Shader *newShaderFromSpv(const std::vector<uint32_t> &vertSpv,
1711 const std::vector<uint32_t> &fragSpv) = 0;
1712
1714 virtual Shader *newShaderFromSpvFile(const std::string &vertPath, const std::string &fragPath) = 0;
1716 Shader *newShaderFromSpvFile(const std::string &fragPath) {
1718 return newShaderFromSpvFile(std::string(), fragPath);
1719 }
1720
1726 virtual Shader *newShader(const std::string &vertGlsl, const std::string &fragGlsl) = 0;
1728 Shader *newShader(const std::string &fragGlsl) { return newShader(std::string(), fragGlsl); }
1729
1740 virtual Shader *newShaderFromWgsl(const std::string &vertWgsl,
1741 const std::string &fragWgsl) = 0;
1742
1754 [[nodiscard]] virtual Result<void> replaceShaderFromSpv(Shader& shader, const std::vector<uint32_t>& vertSpv,
1755 const std::vector<uint32_t> &fragSpv) = 0;
1756
1776 [[nodiscard]] virtual Result<void> replaceMeshShaderResources(Shader &shader, const std::vector<uint32_t> &vertSpv,
1777 const std::vector<uint32_t> &fragSpv,
1779
1790 [[nodiscard]] virtual Result<void> replaceShaderFromWgsl(Shader& shader, const std::string& vertWgsl,
1791 const std::string& fragWgsl) = 0;
1792
1805 Shader &shader, const std::string &vertGlsl, const std::string &fragGlsl) = 0;
1806
1811 virtual Shader *newMeshShaderFromSpv(const std::vector<uint32_t> &vertSpv,
1812 const std::vector<uint32_t> &fragSpv) = 0;
1820 virtual Shader *newMeshShaderFromWgsl(const std::string &vertWgsl,
1821 const std::string &fragWgsl) = 0;
1823 virtual Shader *newMeshShader(const std::string &vertGlsl, const std::string &fragGlsl) = 0;
1830 [[nodiscard]] virtual eve::Result<void> configureMeshShaderSurface(Shader &, BlendMode, bool, bool) {
1833 eve::Diagnostic::error(eve::DiagnosticCode::Unsupported, "Custom mesh surface state is unavailable"));
1834 }
1852 eve::Diagnostic::error(eve::DiagnosticCode::Unsupported, "Custom mesh raster state is unavailable"));
1853 }
1860 Shader *newMeshShaderVF(const std::string &vertGlsl, const std::string &fragGlsl) {
1862 return newMeshShader(vertGlsl, fragGlsl);
1863 }
1866 Shader *newMeshShader(const std::string &fragGlsl) {
1868 return newMeshShader(std::string(), fragGlsl);
1869 }
1870
1875 virtual Shader *newHairShaderFromSpv(const std::vector<uint32_t> &vertSpv,
1876 const std::vector<uint32_t> &fragSpv) = 0;
1878 virtual Shader* newHairShaderFromWgsl(const std::string& vertWgsl, const std::string& fragWgsl) = 0;
1880 Shader *newHairShader();
1881
1886 Mesh *newHairCardMesh(float width = 0.12f, float height = 0.45f);
1887
1892 Material *newHairCardMaterial(Texture *albedo = nullptr);
1893
1908 virtual bool releaseShader(Shader *shader) {
1909 (void)shader;
1910 return false;
1911 }
1912
1917 Shader *newGrassShader();
1918
1928 Shader* newTreeWindShader();
1929
1934 GrassField *newGrassField();
1935
1944 hair::GroomInstance *newGroomInstance();
1945
1951 Waterfall *newWaterfall();
1952
1957 Water *newWater();
1966 [[nodiscard]] Result<void> configureFoliageWind(Material *material, float directionX, float directionZ,
1967 float strength, float bending, float bendingSpeed, float branch,
1968 float branchSpeed, float flutter, float flutterSpeed,
1969 float fadeDistance, float bendFactor);
1972 ReflectionProbeCapture *newReflectionProbeCapture();
1975 ReflectionProbeRegistry *newReflectionProbeRegistry();
1976
1978 virtual Canvas *newCanvas(int width, int height) = 0;
1979
1987 virtual Canvas *newHDRCanvas(int width, int height) = 0;
1988
1990 virtual void setCanvas(Canvas *canvas) = 0;
1992 void setCanvas() { setCanvas(nullptr); }
1993
1995 virtual bool isCanvasActive() const = 0;
1997 virtual Canvas *getCanvas() const = 0;
1998
2003 Volumetric *newVolumetric();
2005 DepthOfField* newDepthOfField();
2006
2011 AmbientOcclusion *newAmbientOcclusion();
2012
2017 Outline *newOutline();
2019 AlphaMask *newAlphaMask();
2024 MapFog *newMapFog();
2025
2030 GlobalIllumination *newGlobalIllumination();
2031
2036 ScreenSpaceReflection *newScreenSpaceReflection();
2037
2044 AmbientOcclusion *pipelineAmbientOcclusion();
2046 GlobalIllumination *pipelineGlobalIllumination();
2048 ScreenSpaceReflection *pipelineScreenSpaceReflection();
2050 AntiAliasing *pipelineAntiAliasing();
2053 Bloom *pipelineBloom();
2056 DepthOfField *pipelineDepthOfField();
2059 Exposure *pipelineExposure();
2062 DepthPyramid *pipelineDepthPyramid();
2065 Texture *prepareFinalSceneTexture(Texture *scene, Texture *motion = nullptr);
2068 Canvas *pipelineReflectionComposite(int width, int height);
2070 void setFinalSceneTexture(Texture *texture) { finalSceneTexture_ = texture; }
2074 Texture *texture = finalSceneTexture_;
2075 finalSceneTexture_ = nullptr;
2076 return texture;
2077 }
2079 Outline *pipelineOutline();
2080
2085 AntiAliasing *newAntiAliasing();
2086
2088 virtual void draw(Drawable *drawable, const glm::mat4 &m);
2089
2094 virtual void drawOcclusion(Drawable *drawable, const glm::mat4 &m);
2096 virtual void drawOcclusionSolid(float x, float y, float w, float h);
2098 virtual void drawOcclusionTexture(Texture *texture, float x, float y, float w, float h);
2099 // void draw(Texture *texture, Quad *quad, const glm::mat4 &m);
2100 // void drawLayer(Texture *texture, int layer, const glm::mat4 &m);
2101 // void drawLayer(Texture *texture, int layer, Quad *quad, const glm::mat4 &m);
2102 // void drawInstanced(Mesh *mesh, const glm::mat4 &m, int instancecount);
2103
2104
2108 void points(const std::vector<glm::vec2> &positions, const std::vector<Color> &colors);
2109
2115 void polyline(const glm::mat4 *vertices, size_t count);
2116
2124 void rectangle(std::string mode, float x, float y, float w, float h);
2125
2137 void rectangle(std::string mode, float x, float y, float w, float h, float rx, float ry, int points);
2139 void rectangle(std::string mode, float x, float y, float w, float h, float rx, float ry);
2140
2149 void circle(std::string mode, float x, float y, float radius, int points);
2151 void circle(std::string mode, float x, float y, float radius);
2152
2162 void ellipse(std::string mode, float x, float y, float a, float b, int points);
2164 void ellipse(std::string mode, float x, float y, float a, float b);
2165
2177 void arc(std::string mode, std::string arcmode, float x, float y, float radius, float angle1, float angle2,
2178 int points);
2180 void arc(std::string mode, std::string arcmode, float x, float y, float radius, float angle1, float angle2);
2181
2188 void polygon(std::string mode, const std::vector<glm::vec2> &vertices, bool skipLastFilledVertex = true);
2189
2190
2192 void push(bool all);
2194 void pop();
2195
2197 const glm::mat4 &getTransform() const;
2199 const glm::mat4 &getProjection() const;
2200
2202 void rotate(float r);
2204 void scale(float x, float y = 1.0f);
2206 void translate(float x, float y);
2208 void origin();
2209
2210 // void applyTransform(love::math::Transform *transform);
2211 // void replaceTransform(love::math::Transform *transform);
2212
2214 glm::vec2 transformPoint(glm::vec2 point);
2216 glm::vec2 inverseTransformPoint(glm::vec2 point);
2217
2218 // virtual void draw(const DrawCommand &cmd) = 0;
2219 // virtual void draw(const DrawIndexedCommand &cmd) = 0;
2220 // virtual void drawQuads(int start, int count, const vertex::Attributes &attributes, const vertex::BufferBindings
2221 // &buffers, Texture *texture) = 0;
2222
2223protected:
2226 std::string key;
2227 Texture *texture = nullptr;
2228 };
2229
2231 void requestFileImageDecode(const std::string &key);
2233 bool fileTextureSourceExists(const std::string &filename) const;
2235 void dropDeferredFileTexture(Texture *texture);
2237 virtual bool uploadDeferredFileTexture(Texture *texture, image::ImageData *data);
2238
2239 std::vector<DeferredFileTexture> deferredFileTextures_;
2240 bool realizingFileTextures_ = false;
2241
2242 int width = 0;
2243 int height = 0;
2244 int pixelWidth = 0;
2245 int pixelHeight = 0;
2246 Color backgroundColor{0.1f, 0.1f, 0.12f, 1.0f};
2247 bool frameHad3D = false;
2249 bool recordingEngine3D_ = false;
2250 bool screenReadbackEnabled = false;
2251 bool vsyncEnabled = true;
2252 int presentationVSyncCount_=1;
2253 DisplayOutputMode displayOutputMode_ = DisplayOutputMode::Sdr;
2254 DisplayColorSpace activeDisplayColorSpace_ = DisplayColorSpace::Sdr;
2255 float displayPaperWhiteNits_ = 200.f;
2256 float displayPeakNits_ = 1000.f;
2257 bool graphicsActive = true;
2258 int msaaSamples = 4;
2259 PresentOverlayFn presentOverlayFn_ = nullptr;
2260 void *presentOverlayUser_ = nullptr;
2261 std::vector<std::pair<WindowDestroyedCallback, void *>> windowDestroyedCallbacks_;
2262 Shader *currentShader = nullptr;
2263 Font *currentFont = nullptr;
2264 std::unique_ptr<RenderControl> renderControl_;
2265 std::shared_ptr<PrimitiveScene> primitiveScene_;
2266 std::unique_ptr<AmbientOcclusion> pipelineAO_;
2267 std::unique_ptr<GlobalIllumination> pipelineGI_;
2268 std::unique_ptr<ScreenSpaceReflection> pipelineSSR_;
2269 std::unique_ptr<AntiAliasing> pipelineAA_;
2270 std::unique_ptr<Bloom> pipelineBloom_;
2271 std::unique_ptr<DepthOfField> pipelineDof_;
2272 std::unique_ptr<Exposure> pipelineExposure_;
2273 bool sceneDepthOfFieldEnabled_ = false;
2274 float sceneDepthOfFieldFocusDistance_ = 10.f;
2275 float sceneDepthOfFieldFocusRange_ = 5.f;
2276 float sceneDepthOfFieldMaximumBlurPixels_ = 8.f;
2277 float sceneDepthOfFieldNearPlane_ = 0.1f;
2278 float sceneDepthOfFieldFarPlane_ = 100.f;
2279 std::unique_ptr<DepthPyramid> pipelineDepthPyramid_;
2280 Canvas *spatialAAResolve_ = nullptr;
2281 int spatialAAResolveWidth_ = 0;
2282 int spatialAAResolveHeight_ = 0;
2283 Canvas *reflectionComposite_ = nullptr;
2284 int reflectionCompositeWidth_ = 0;
2285 int reflectionCompositeHeight_ = 0;
2286 Texture *finalSceneTexture_ = nullptr;
2287 Texture *foliageWindMotionTexture_ = nullptr;
2288 Texture *foliageWindNoiseTexture_ = nullptr;
2289 std::unique_ptr<Outline> pipelineOutline_;
2290
2292 Shader *prepareSceneColorResolveShader(Texture *scene);
2294 void retireResourceLifetime() const;
2295};
2296
2297} // namespace eve::graphics
bool & active
float w
Definition AnimClip.cpp:738
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
std::vector< BuildingInstanceSnapshot > instances
float normalStrength
float cx
Definition CardTypes.cpp:33
float cy
Definition CardTypes.cpp:34
float degrees
Definition CardTypes.cpp:35
graphics::Texture * albedo
#define EVENGINE_API_BACKENDS
Definition Export.h:108
std::uint32_t vertexCount
std::uint32_t indexCount
tensor::Graph g
Definition GpuGraph.cpp:7
float camera[2]
std::uint32_t spawnCount
std::uint32_t instanceCount
std::uint32_t capacity
std::uint32_t key
vk::UniqueSampler sampler
glm::vec4 tint
glm::mat4 mvp
double r
std::vector< std::uint32_t > indices
std::vector< float > positions
float v
std::int32_t c
std::int32_t first
float blend
int h
std::uint32_t height
std::uint32_t width
std::string text
std::array< float, 3 > scale
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
MeshVfxBatchedDraw draw
float roughness
bool doubleSided
Texture * normal
float alphaCutoff
float metallic
std::vector< std::weak_ptr< DeviceBytes > > resources
Definition OnnxGpgpu.cpp:55
std::vector< Point > vertices
float radius
std::string path
Definition PlayHost.cpp:110
std::shared_ptr< const std::vector< glm::vec2 > > points
std::weak_ptr< PrimitiveScene > scene
PrimitiveHandle handle
int detail
bool lodFadeReverse
glm::vec3 eye
Mesh * mesh
float lodWeight
glm::mat4 viewProj
Shader * shader
bool hair
glm::mat4 view
glm::mat4 model
Material * material
Move-only, checked operation results for the common layer.
std::vector< float > colors
bool repeatV
std::string filter
std::string mipmap
bool repeatU
float dz
float dy
float dx
std::uint32_t count
float opacity
float size
Definition TreeMesh.cpp:156
int caps
Definition TreeMesh.cpp:162
V3 dir
Definition TreeMesh.cpp:150
const UnitySourceAsset & source
std::uint32_t depth
ViewPreparation callback
float m[16]
glm::vec3 point
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
Cross-module owner for swapchain presentation cadence.
Render-surface host for the window module (provided by graphics).
EVENGINE_API_FOUNDATION public API.
Definition Module.h:46
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
CPU-side decoded font face (FreeType FT_Face + owned font bytes). Does not upload to GPU — rasterize ...
Definition FontData.h:25
Reusable two-texture alpha mask for immediate 2D composition.
Definition AlphaMask.h:12
Screen-space ambient occlusion.
Classic image-space anti-aliasing.
Linear-HDR bloom pyramid with selectable Karis/tent or Gaussian/scatter reconstruction.
Definition Bloom.h:42
EVENGINE_API_BACKENDS public API.
Canvas public API.
Definition Canvas.h:17
Separable Gaussian depth-of-field for the final HDR scene.
Cross-backend min/max hardware-depth pyramid packed into one texture atlas.
Drawable base (textures, meshes, canvases).
Definition Drawable.h:17
GPU percentile metering, eye adaptation, and linear HDR pre-exposure.
Definition Exposure.h:13
GPU-side font: wraps a decoded font::FontData and rasterizes a fixed set of codepoints into a single ...
Definition Font.h:35
Screen-space single-bounce GI (SSGI). @lifetime All texture arguments are borrowed for the duration o...
virtual void setFont(Font *font)
Optional shared font used by legacy consumers; nullptr = none set.
Definition Graphics.h:1627
virtual Texture * newCubemap(int faceSize, const uint8_t *rgbaFaces)=0
Create an RGBA8 cubemap from 6 faces packed as +X,-X,+Y,-Y,+Z,-Z (each faceSize×faceSize,...
virtual void beginShadowPass(int cascadeIndex)=0
Depth-only shadow pass for one cascade layer (0..2). Draws are recorded into the next begin3DFrame co...
std::vector< std::pair< WindowDestroyedCallback, void * > > windowDestroyedCallbacks_
Definition Graphics.h:2261
virtual void setMesh3DEnvProbe(const glm::vec3 &center, const glm::vec3 &extent)=0
Box projection bounds for the active environment; zero extent disables it.
virtual void onNativeWindowDestroyed()
Called by the Window module when the native window backing the render surface is destroyed (window cl...
Definition Graphics.h:1576
virtual glm::vec3 getSceneGain() const =0
Current pre-tonemap gain coefficients.
void(*)(void *userdata) WindowDestroyedCallback
Register a callback invoked when the native window is destroyed. Used by the UI backend to tear down ...
Definition Graphics.h:1594
virtual void setMesh3DReflectionProbes(const ReflectionProbeUpload &upload)=0
Upload the two dominant local reflection probes for subsequent mesh draws.
bool consumeFrameHad3D()
True after begin3DFrame until present completes.
Definition Graphics.h:1486
void drawCanvas(Canvas *canvas, float x, float y, float w, float h)
Draws a Canvas with opaque white tint (script-friendly defaults).
Definition Graphics.h:958
virtual bool updateTexture(Texture *texture, int width, int height, const uint8_t *rgba)=0
Replace an existing texture's pixels in place (pointer stays stable).
virtual bool releaseMesh(Mesh *mesh)
Eagerly releases a mesh created by this Graphics.
Definition Graphics.h:927
void ellipse(std::string mode, float x, float y, float a, float b)
Ellipse.
virtual void setMesh3DSceneColor(Texture *color)=0
Optional completed scene-color snapshot for custom mesh shaders.
virtual bool gpuDrivenSubmitOpaque(const GpuInstance *instances, uint32_t instanceCount)
Upload + record GPU-driven opaque draws (call inside the open 3D frame). The backend sorts instances ...
Definition Graphics.h:365
virtual bool copyHDRCanvasesToCubemap(Canvas *const *sources, int faceCount, Texture *cubemap)
Copy consecutive RGBA16F canvases into cubemap base-level faces.
Definition Graphics.h:590
virtual std::string getBackendName() const =0
Renderer backend id used by sibling modules (e.g. Gpgpu).
int getPixelHeight() const
Returns the pixel height.
Definition Graphics.h:508
virtual Texture * getSceneLinearDepthTexture()
Sampleable scene linear depth in [0,1], or nullptr when unavailable.
Definition Graphics.h:1049
virtual void setVSync(bool enabled)
Prefer uncapped present (IMMEDIATE/MAILBOX) when false, vsync (MAILBOX/FIFO) when true....
Definition Graphics.h:1528
virtual image::ImageData * readGBufferToImageData(const std::string &attachment)
Read a G-buffer attachment back to CPU as RGBA8. name is one of "depth" (RGBA8 linear depth),...
Definition Graphics.h:1081
std::unique_ptr< AntiAliasing > pipelineAA_
Definition Graphics.h:2269
virtual float getSceneAutoExposureMinEV() const =0
Minimum automatic exposure EV.
virtual void drawTexturedRectShader4(Texture *color, Texture *depth, Texture *motion, Texture *extra, Shader *shader, float x, float y, float w, float h, const Color &tint)=0
Post draw with four sampled textures at bindings 0, 1, 2 and 3.
virtual GpuParticleHandle createGpuParticleEmitter(std::uint32_t capacity)
Allocate backend-owned resident state for one particle emitter.
Definition Graphics.h:324
virtual Shader * newMeshShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
Create a Mesh3D custom shader (MeshVertex + Frame UBO + albedo). Empty vert → default mesh3d....
virtual bool gpuDrivenCullEnabled() const
True when the stage-2 GPU cull chain will run this frame.
Definition Graphics.h:388
void setBackgroundColor(const Color &c)
Sets the background color.
Definition Graphics.h:1496
virtual void setMesh3DShadows(const ShadowUpload &upload)=0
Upload CSM constants for subsequent default mesh draws (active=false disables).
void ellipse(std::string mode, float x, float y, float a, float b, int points)
Draws an ellipse using the specified arguments.
virtual void endGBufferPass()=0
Ends g buffer pass.
bool isVSync() const
True when v sync.
Definition Graphics.h:1530
virtual void setMesh3DClip(float nearZ, float farZ)=0
Near/far used to pack linear depth into scene color A (SSGI).
virtual void gpuDrivenOpenScenePass()
Open the scene color pass that begin3DFrame deferred (cull path).
Definition Graphics.h:411
void setActive(bool active) override
Pause/resume presenting (Android background / foreground).
Definition Graphics.h:1546
void translate(float x, float y)
Translate.
virtual Mesh * newMeshCylinder(int slices=32, int stacks=1, bool caps=true)=0
Procedural Y-up cylinder (radius 1, height 2 centered at origin). slices = longitude divisions; stack...
virtual Result< void > replaceShaderFromGlsl(Shader &shader, const std::string &vertGlsl, const std::string &fragGlsl)=0
Compile GLSL and transactionally replace an existing shader.
std::unique_ptr< Outline > pipelineOutline_
Definition Graphics.h:2289
virtual float getSceneAutoExposureMaxEV() const =0
Maximum automatic exposure EV.
virtual void setMesh3DMaterial(float metallic, float roughness)=0
Metallic (0..1) and roughness (0..1) for the next default mesh draw.
virtual bool gpuDrivenVgSetInstance(std::uint32_t vgAssetId, const glm::mat4 &model, std::uint32_t materialId)
Register one instance of a VG asset this frame (model + material). The first instance per asset wins;...
Definition Graphics.h:458
void polyline(const glm::mat4 *vertices, size_t count)
Draws a series of lines connecting the given vertices.
int getWidth() const
Returns the width.
Definition Graphics.h:502
virtual Shader * newHairShaderFromWgsl(const std::string &vertWgsl, const std::string &fragWgsl)=0
Create an alpha-blended hair/card shader from WGSL on WebGPU.
virtual float getSceneTransitionVignetteSmoothness() const =0
Return the final-composite vignette smoothness.
virtual bool drawGpuParticleEmitter(GpuParticleHandle handle, const GpuParticleDraw &draw)
Queue an indirect draw at the current 2D overlay position.
Definition Graphics.h:347
virtual GpuParticleStats getGpuParticleStats(GpuParticleHandle handle) const
Return the latest fence-complete counters without waiting on the GPU.
Definition Graphics.h:354
std::unique_ptr< DepthPyramid > pipelineDepthPyramid_
Definition Graphics.h:2279
virtual bool supportsGpuParticles() const
True when this backend supports resident compute + indirect particle draws.
Definition Graphics.h:318
std::unique_ptr< Bloom > pipelineBloom_
Definition Graphics.h:2270
bool isScreenReadbackEnabled() const
True when screen readback enabled.
Definition Graphics.h:1504
virtual float getSceneBloomIntensity() const =0
Current final-scene bloom intensity.
std::vector< DeferredFileTexture > deferredFileTextures_
Definition Graphics.h:2239
virtual std::uint32_t gpuDrivenVgAssetId(Mesh *mesh) const
VG asset id attached to a mesh (kInvalidGpuDrivenSlot when none).
Definition Graphics.h:440
virtual bool releaseTexture(Texture *texture)
Eagerly releases a texture created by this Graphics.
Definition Graphics.h:733
virtual Shader * newShaderFromWgsl(const std::string &vertWgsl, const std::string &fragWgsl)=0
Create a 2D custom shader from WGSL source (WebGPU backend). Empty vert → default textured vertex sha...
virtual float getSceneTransitionLensDistortion() const =0
Return the final-composite radial lens-distortion strength.
virtual void drawTexturedRectShaderUV(Texture *texture, Shader *shader, float x, float y, float w, float h, float u0, float v0, float u1, float v1, const Color &color, bool rotatedUV=false, BlendMode blend=BlendMode::Alpha)=0
UV draw with an explicit Shader (nullptr = default textured pipeline).
virtual Shader * newMeshShader(const std::string &vertGlsl, const std::string &fragGlsl)=0
Creates a mesh shader. @ownership Caller deletes unless documented otherwise.
virtual void setMesh3DViewProj(const glm::mat4 &viewProj)=0
Sets the mesh 3 d view proj.
virtual void drawMeshShadow(Mesh *mesh, const glm::mat4 &lightMVP, bool doubleSided=true)=0
Queue an opaque shadow caster.
virtual void drawMesh(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint)=0
Draw one mesh with model matrix. Requires begin3DFrame() (or an open swapchain pass).
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
Shadow pass draw with alpha-cutout discard (card/billboard geometry such as sprite-stack slices): tra...
virtual Texture * newTexture(image::ImageData *data)=0
Create texture from ImageData (RGBA8 required for now).
std::shared_ptr< PrimitiveScene > primitiveScene_
Definition Graphics.h:2265
virtual void resetGpuParticleEmitter(GpuParticleHandle handle)
Clear resident state before the next submitted frame.
Definition Graphics.h:333
virtual Result< void > setMesh3DPbrSurface(const PbrSurface *surface)
Copy a validated extended surface for subsequent draws; null resets to legacy shading.
Definition Graphics.h:1192
virtual void drawTexturedRectLitUVRotated(Texture *albedo, Texture *normal, float cx, float cy, float w, float h, float degrees, float u0, float v0, float u1, float v1, const Color &color, BlendMode blend=BlendMode::Alpha)=0
Lit 2D draw rotated degrees clockwise (screen Y-down) around (cx, cy). Fragment tangent frame is rebu...
virtual void setMesh3DCameraPos(const glm::vec3 &eye)=0
Camera eye used by mesh shaders that need view/rim (stored in Mesh3DUBO).
virtual glm::vec3 getSceneLift() const =0
Current pre-tonemap lift coefficients.
std::unique_ptr< ScreenSpaceReflection > pipelineSSR_
Definition Graphics.h:2268
virtual uint32_t gpuDrivenMeshRecord(Mesh *mesh)
GPU mesh-table slot for a mesh (kInvalidGpuDrivenSlot when not uploaded).
Definition Graphics.h:274
virtual glm::vec3 getSceneColorFilter() const =0
Current linear RGB multiplier applied during final HDR exposure.
Color getBackgroundColor() const
Returns the background color.
Definition Graphics.h:1494
void addWindowDestroyedCallback(WindowDestroyedCallback cb, void *userdata)
Adds window destroyed callback.
Definition Graphics.h:1596
virtual void setMsaaSamples(int samples)
Hardware MSAA sample count for the 3D scene color pass (0 disables, then 2/4/8 are used when the devi...
Definition Graphics.h:1541
virtual bool getSceneAutoExposure() const =0
Whether automatic exposure is active.
virtual void endShadowPass()=0
Ends shadow pass.
virtual void setLighting2D(const Lighting2DUBO &ubo)=0
Upload per-frame / per-canvas 2D lighting constants for subsequent lit draws.
void arc(std::string mode, std::string arcmode, float x, float y, float radius, float angle1, float angle2, int points)
Draws an arc using the specified arguments.
virtual void setMesh3DPackedNormalMask(bool enabled)=0
Interpret normal texture RG as tangent XY, B as AO and A as smoothness for terrain surfaces.
void push(bool all)
Pushes .
virtual image::ImageData * readDecalLayerToImageData(const std::string &attachment)
Read back a DecalLayer attachment ("albedo" | "normal" | "params") to CPU. Renders the pending G-buff...
Definition Graphics.h:1091
virtual float getSceneTransitionVignette() const =0
Return the final-composite vignette strength.
virtual void setMesh3DSSAO(float intensity)=0
Sets the screen-space ambient-occlusion strength applied in the forward mesh pass....
std::unique_ptr< DepthOfField > pipelineDof_
Definition Graphics.h:2271
virtual Mesh * newMeshFromAssimp(const ::aiMesh &mesh)=0
Creates a mesh from assimp. @ownership Caller deletes unless documented otherwise.
virtual void setMesh3DClusteredActive(bool active)=0
Cheap per-draw toggle for the already-uploaded clustered light table. Unlike setMesh3DClusteredLighti...
virtual Mesh * newMeshFromAssimp(const ::aiMesh &mesh, const aiMatrix4x4 &worldTransform)=0
Like newMeshFromAssimp, but bakes an Assimp node world transform into positions and transforms normal...
virtual bool canSubmitGpuParticles() const
True when the current frame topology can accept a GPU particle compute section.
Definition Graphics.h:321
double getScreenDPIScale() const
Returns the screen dpi scale.
Definition Graphics.h:513
glm::vec2 inverseTransformPoint(glm::vec2 point)
Inverse transform point.
virtual bool copyHDRCanvasToCubemapFace(Canvas *source, Texture *cubemap, int face)
Copy one RGBA16F Canvas into a staging cubemap base-level face.
Definition Graphics.h:572
virtual void begin3DFrameToCanvas(Canvas *canvas)=0
Open a 3D render pass targeting an offscreen Canvas (color + depth) at the canvas size....
virtual eve::Result< void > updateTextureFromResidentRgba8(Texture *texture, const GpuResidentBufferView &source, int width, int height)
Copy a same-device resident RGBA8 buffer into an existing texture.
Definition Graphics.h:643
virtual SceneColorDistortionStatus drawSceneColorDistortionUVRotated(Texture *displacement, float cx, float cy, float w, float h, float degrees, float u0, float v0, float u1, float v1, float strengthPixels, float opacity, bool rotatedUV=false)
Draws scene color distortion uv rotated.
Definition Graphics.h:796
glm::vec2 transformPoint(glm::vec2 point)
Transform point.
virtual void setMesh3DEnv(Texture *cube, float intensity)=0
Specular IBL environment for subsequent default mesh draws. cube must be from newCubemap (or nullptr ...
virtual bool gpuDrivenMaterialUsable(Material *material)
Whether a material can be shaded by the GPU-driven opaque path. Backends/drivers with descriptor-inde...
Definition Graphics.h:304
virtual void setMesh3DLodDither(float weight, bool reverse, bool enabled)=0
Set opaque LOD dither coverage for the next default mesh draw. Render-thread only.
SceneColorDistortionStatus
Refract the resolved 3D scene color through a displacement texture.
Definition Graphics.h:793
virtual void setMesh3DTexCellBomb(float cellScale, float strength, float rotAmount=1.f)=0
Texture cell bombing for the next default mesh draw (breaks tiling). cellScale: cells per UV unit (ty...
virtual void beginDecalPass(int width, int height)=0
Open the decal pass (reads G-buffer hwDepth + normal, writes the screen-space DecalLayer targets)....
virtual Canvas * getCanvas() const =0
Returns the canvas.
virtual void initWithWindow(void *nativeWindow)=0
Bind to an existing native window (SDL_Window*) and create Vulkan device/swapchain....
virtual float getScenePhotographicVignette() const
Return photographic vignette intensity; render thread only.
Definition Graphics.h:1387
virtual float getSceneBloomThreshold() const =0
Current linear HDR bloom threshold.
virtual void setSceneExposure(float exposure)=0
Set linear exposure multiplier used by the final scene tone-map resolve.
virtual GpuResidentSubmitStatus gpuDrivenSubmitResident(const GpuResidentInstanceBatch &batch)
Submit a GPU-authored, bucket-sorted GpuInstance buffer without CPU readback.
Definition Graphics.h:378
void rectangle(std::string mode, float x, float y, float w, float h, float rx, float ry, int points)
Variant of rectangle that draws a rounded rectangle.
DisplayOutputMode
Requested swapchain present preference.
Definition Graphics.h:1327
virtual void popValidationScope()=0
Pops validation scope.
void arc(std::string mode, std::string arcmode, float x, float y, float radius, float angle1, float angle2)
Arc.
void rectangle(std::string mode, float x, float y, float w, float h, float rx, float ry)
Rectangle.
virtual void pushValidationScope()=0
Backend hooks so the platform-independent render3D() can wrap its work in a GPU validation error scop...
virtual void beginGBufferPass(int width, int height)=0
Depth/normal(/albedo) fill pass for mid/post effects. One-shot submit (like shadow); call before begi...
virtual void setMesh3DClusteredLighting(const ClusteredLightingUpload &upload)=0
Enable clustered forward path for subsequent default mesh draws (SSBO light lists)....
virtual void setMesh3DParallax(float scale, float minLayers=8.f, float maxLayers=32.f)=0
Parallax occlusion mapping for the next default mesh draw. scale: UV displacement strength (0=off)....
void rectangle(std::string mode, float x, float y, float w, float h)
Draws a rectangle.
void circle(std::string mode, float x, float y, float radius)
Circle.
virtual void setSceneBloom(float intensity, float threshold)=0
Configure final HDR bloom intensity and linear threshold.
void clearPresentOverlay()
Drop the present overlay callback (window gone; re-register on UI init).
Definition Graphics.h:1584
virtual Shader * newShader(const std::string &vertGlsl, const std::string &fragGlsl)=0
Compile GLSL source with the engine's build-time GLSL compiler. Empty vertGlsl → default textured ver...
virtual bool filterHDRReflectionCubemap(Texture *cubemap, int sampleCount=64)
Generate GGX specular mips and final diffuse irradiance for an HDR cubemap. @compatibility Preserves ...
Definition Graphics.h:601
virtual void drawTexturedRectShaderUVRotated(Texture *texture, Shader *shader, float cx, float cy, float w, float h, float degrees, float u0, float v0, float u1, float v1, const Color &color, bool rotatedUV=false, BlendMode blend=BlendMode::Alpha)=0
UV draw rotated degrees clockwise (screen Y-down) around the rect center. texture may be null → solid...
virtual Texture * newTexture(int width, int height, const uint8_t *rgba, bool repeatU=false, bool repeatV=false)=0
Creates a texture. @ownership Caller deletes unless documented otherwise.
virtual void drawDecal(const glm::mat4 &model, Texture *albedo, Texture *normal, Texture *params, const float uvRect[4], float fade, float normalStrength, float roughnessStrength, float metalStrength, float emissiveStrength, int blendMode=0, int projectionMode=0, float blendSharpness=4.f, float parallaxScale=0.f, float parallaxMinLayers=8.f, float parallaxMaxLayers=24.f, float edgeFadeWidth=0.06f)=0
Queue one box-projected decal draw. model maps the unit decal box ([-0.5, 0.5]^3, +Z = decal forward)...
void setCanvas()
Sets the canvas.
Definition Graphics.h:1992
virtual bool reloadTextureFromFile(const std::string &filename)=0
Reload a path-cached texture from disk in place (pointer stable). False if unbound.
virtual void setMesh3DVirtualTexture(bool enabled, int pageCountX, int pageCountY, int atlasSlotsX, int atlasSlotsY, float borderFraction)=0
Configure page-table sampling for the next mesh draw.
virtual std::optional< MeshBackendDescriptor > describeMesh(Mesh *mesh) const
Describe a live mesh created by this Graphics backend.
Definition Graphics.h:859
std::shared_ptr< PrimitiveScene > getPrimitiveScene() const noexcept
Returns the authoritative persistent spatial-primitive scene.
Definition Graphics.h:521
Shader * newMeshShaderVF(const std::string &vertGlsl, const std::string &fragGlsl)
Creates a Mesh3D shader from separate vertex and fragment GLSL sources.
Definition Graphics.h:1860
virtual bool updateMeshVertices(Mesh *mesh, const float *posXYZ, const float *nrmXYZ, const float *uvST, int vertexCount, const uint32_t *indices, int indexCount)=0
In-place update of a mesh's vertex/index data (CPU -> host-visible VBO). Mirrors bakeMeshMorph: the u...
virtual void setMesh3DView(const glm::mat4 &view)=0
Camera view matrix for subsequent drawMesh (view-space depth / CSM select).
virtual float getLastOffscreen3DGpuDurationMs() const
Return the GPU timestamp duration of the most recently completed offscreen 3D pass,...
Definition Graphics.h:1030
virtual void setCloudShadows(float strength, float worldCell, float time, float windSpeed, float windAngle, float coverage, float detail)=0
Dynamic cloud shadows cast on the ground by the default PBR mesh path. strength 0 disables (no change...
virtual bool gpuDrivenScenePassPending() const
Scene pass opening deferred until after the compute cull section.
Definition Graphics.h:391
virtual void gpuDrivenResolve()
Record the fullscreen vis resolve inside the open scene color pass.
Definition Graphics.h:427
virtual eve::Result< void > configureMeshShaderRaster(Shader &shader, const MeshShaderRasterState &state)
Transactionally configure an owned ordinary mesh shader's raster state.
Definition Graphics.h:1847
SceneToneMapping
Final display mapping; None preserves linear color, Aces uses the fitted curve, and Filmic uses Rec....
Definition Graphics.h:1325
const glm::mat4 & getProjection() const
Returns the projection.
Shader * newShader(const std::string &fragGlsl)
Creates a shader. @ownership Caller deletes unless documented otherwise.
Definition Graphics.h:1728
virtual Shader * newHairShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
Hair/fur card shader (alpha blend + Kajiya-Kay). Empty vert → mesh3d_hair.vert. Owned by Graphics.
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
GBuffer fill with alpha-cutout discard (card/billboard geometry such as sprite-stack slices): same ou...
virtual void drawSolidRectRotated(float cx, float cy, float w, float h, float degrees, const Color &color, BlendMode blend=BlendMode::Alpha)=0
Rotated solid quad degrees clockwise (screen Y-down) around (cx, cy).
std::unique_ptr< Exposure > pipelineExposure_
Definition Graphics.h:2272
virtual void setMesh3DLight(const glm::vec3 &dir, const glm::vec3 &color)=0
Directional light for subsequent drawMesh calls (world-space direction toward surface).
virtual bool beginFrameReadback(const std::string &path)
Queue an asynchronous readback of the current frame to a PNG file.
Definition Graphics.h:1517
virtual bool releaseShader(Shader *shader)
Eagerly releases a shader created by this Graphics.
Definition Graphics.h:1908
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
Instanced voxel face rectangles (32-bit packed instances). ao: optional per-instance ambient-occlusio...
virtual void setCanvas(Canvas *canvas)=0
nullptr or this → screen. Switching flushes pending draws to the previous target.
bool had3DThisFrame() const
Had 3 d this frame.
Definition Graphics.h:1491
virtual bool isCanvasActive() const =0
True when canvas active.
virtual float getSceneExposure() const =0
Current linear manual exposure multiplier.
virtual void drawTexturedRectShaderDepthMotion(Texture *color, Texture *depth, Texture *motion, Shader *shader, float x, float y, float w, float h, const Color &tint)=0
Post draw with color, depth/history and motion/reactive textures.
virtual float getMaxAnisotropy() const =0
Device max supported anisotropy (1 if unsupported). Valid after initWithWindow.
virtual void setSceneTransitionFx(float vignette, float vignetteSmoothness, float lensDistortion, float lensScale)=0
Set final-composite vignette and radial lens distortion strengths in [0,1].
virtual Result< void > drawMeshShaderInstances(Mesh &mesh, Shader &shader, const glm::mat4 &model, const Color &tint, std::uint32_t first, std::uint32_t count)
Draw a checked range from a resource shader's immutable instance matrix buffer. @ownership Mesh and S...
Definition Graphics.h:1116
std::unique_ptr< RenderControl > renderControl_
Definition Graphics.h:2264
virtual void setDecalCamera(const glm::mat4 &viewProj, float nearZ, float farZ)=0
Per-frame camera constants for the decal pass (world-space reconstruction from the G-buffer depth)....
virtual void markSwapchainDirty()
Request swapchain recreation on next present/begin3DFrame.
Definition Graphics.h:1554
bool isActive() const
True when active.
Definition Graphics.h:1551
const glm::mat4 & getTransform() const
Returns the transform.
virtual void setMesh3DSurface(SurfaceMode mode, BlendMode blend, bool depthWrite, bool doubleSided, float alphaCutoff, const std::string &alphaTechnique="cutoff")=0
Select pipeline state for subsequent mesh draws.
void drawTextRGBA(Font *font, const std::string &text, float x, float y, float r, float g, float b, float a, float scale=1.f)
Script-friendly UTF-8 text drawing overload using RGBA components.
Definition Graphics.h:1674
virtual Texture * newTextureFromFile(const std::string &filename)=0
Creates a texture from file. @ownership Caller deletes unless documented otherwise.
virtual void setSceneColorFilter(const glm::vec3 &color)=0
Set a non-negative linear RGB multiplier applied during final HDR exposure.
int getVSyncCount() const noexcept override
Returns the v sync count.
Definition Graphics.h:1534
virtual void drawTexturedRectUV(Texture *texture, float x, float y, float w, float h, float u0, float v0, float u1, float v1, const Color &color)=0
Draw a textured sub-rect (atlas / tile UVs). texture may be null → solid.
void scale(float x, float y=1.0f)
Scale.
virtual bool isHeadless() const
True when the renderer was initialized via initHeadless().
Definition Graphics.h:494
virtual Texture * newTexture(int width, int height, const uint8_t *rgba, const TextureCreateInfo &info)=0
Creates a texture. @ownership Caller deletes unless documented otherwise.
virtual void setSceneAutoExposure(bool enabled, float minEV, float maxEV)=0
Configure log-average scene auto exposure and its EV clamp range.
virtual int getMsaaSamples() const
Returns the msaa samples.
Definition Graphics.h:1543
virtual glm::vec3 getSceneInverseGamma() const =0
Current pre-tonemap inverse-gamma coefficients.
virtual float getSceneDofFarZ() const =0
Returns the scene dof far z.
virtual void present()=0
Present.
virtual bool setMeshSkinningData(Mesh *mesh, const uint16_t *joints4, const float *weights4, int vertexCount)
Upload four joint indices and weights per vertex for built-in GPU skinning.
Definition Graphics.h:882
void rotate(float r)
Rotate.
virtual void setMesh3DSceneDepth(Texture *depth)=0
Optional scene hardware depth (G-buffer hwDepth, Vulkan NDC z) bound to mesh3d shader binding 7....
virtual void gpuDrivenSetEnabled(bool enabled)
Enable/disable the GPU-driven opaque path (no-op when unsupported).
Definition Graphics.h:271
void setVSyncCount(int count) override
Sets the v sync count.
Definition Graphics.h:1532
virtual int frameReadbackStatus() const
Async readback state: 0=idle, 1=pending, 2=done, 3=failed.
Definition Graphics.h:1522
virtual uint32_t gpuDrivenMaterialRecord(Material *material)
GPU material-table slot for a material (lazily created).
Definition Graphics.h:280
virtual bool bakeMeshMorph(Mesh *mesh)=0
If mesh morph weights are dirty, bake blended positions and upload to the GPU VBO....
virtual void setMesh3DSkinInfluenceLimit(SkinInfluenceLimit count)=0
Limit GPU skinning to the strongest one, two or four vertex influences.
virtual bool gpuDrivenResolveWanted() const
True when the stage-3 vis+resolve path should run this frame.
Definition Graphics.h:421
virtual void gpuDrivenRecordVisPass()
Record the GBuffer vis pass (opaque indirect draws write visID/visBary).
Definition Graphics.h:424
Shader * getShader() const
Returns the shader.
Definition Graphics.h:1704
virtual Shader * newShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
Create a custom 2D shader from SPIR-V words (vert + frag). Owned by Graphics. Vertex stage may be emp...
virtual void setMesh3DShadowReceive(bool receive)=0
Per-draw: when false, shadow sampling is forced off for the next mesh draw.
virtual image::ImageData * renderEntityIdMask(const std::vector< EntityIdDraw > &draws, const glm::mat4 &viewProj, int w, int h)
Renders entity id mask.
Definition Graphics.h:1066
virtual bool supportsGBufferPost() const
Whether gbuffer-based post-process shaders (AO, GI) can be created on this backend....
Definition Graphics.h:238
virtual Mesh3DSceneColorCaptureStatus captureMesh3DSceneColor()
Make opaque scene color available to subsequent refractive mesh draws.
Definition Graphics.h:1181
virtual void begin3DFrame()=0
Begin a 3D frame: shadow/gbuffer (if pending) then a sampleable scene color pass (color+depth)....
void setFinalSceneTexture(Texture *texture)
Override the HDR source consumed by the next backend scene resolve.
Definition Graphics.h:2070
virtual eve::Result< void > updateTextureRegions(Texture *texture, std::span< const TextureRegionUpload > regions)=0
Validate then upload multiple independent mip-zero RGBA8 regions as one batch.
virtual eve::Result< void > configureMeshShaderSurface(Shader &, BlendMode, bool, bool)
Prepare a custom mesh shader's blend, depth and culling state.
Definition Graphics.h:1830
std::unique_ptr< GlobalIllumination > pipelineGI_
Definition Graphics.h:2267
void points(const std::vector< glm::vec2 > &positions, const std::vector< Color > &colors)
Draws a series of points at the specified positions.
virtual bool supportsGpuDriven3D() const
True when the backend can run GPU-driven opaque draws.
Definition Graphics.h:255
virtual uint32_t gpuDrivenReflectionProbeSlot(Texture *cubemap)
Return/register a bindless cubemap slot for a GPU-driven local probe.
Definition Graphics.h:310
Mesh3DSceneColorCaptureStatus
Observable result of requesting a same-frame mesh SceneColor snapshot.
Definition Graphics.h:1168
void requestSurfaceRecreate() override
Request recreation of the platform render surface on the next frame (Android background/foreground de...
Definition Graphics.h:1561
std::unique_ptr< AmbientOcclusion > pipelineAO_
Definition Graphics.h:2266
virtual void setTextureSampler(Texture *texture, const TextureSampler &sampler)=0
Recreate the sampler for an existing texture (keeps image / mip chain). No-op when texture is null or...
virtual void setSceneLiftGammaGain(const glm::vec3 &lift, const glm::vec3 &inverseGamma, const glm::vec3 &gain)=0
Set pre-tonemap HDR lift, inverse-gamma and gain coefficients.
void polygon(std::string mode, const std::vector< glm::vec2 > &vertices, bool skipLastFilledVertex=true)
Draws a polygon with an arbitrary number of vertices.
virtual float getSceneDofNearZ() const =0
Returns the scene dof near z.
virtual void drawTexturedRect(Texture *texture, float x, float y, float w, float h, const Color &color)=0
Draws textured rect.
virtual void releaseGpuParticleEmitter(GpuParticleHandle handle)
Release a GPU particle emitter. Explicit release may wait for in-flight frames.
Definition Graphics.h:330
virtual Canvas * newHDRCanvas(int width, int height)=0
Create an engine-internal linear RGBA16F post-process target.
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 gpuDrivenCullEmit(const glm::mat4 &viewProj, const glm::vec3 &eye, float fovYDeg, float nearZ, float farZ)
Record the cull + emit compute dispatches for the current frame.
Definition Graphics.h:401
virtual float getSceneDofFocusDistance() const =0
Returns the scene dof focus distance.
void drawScene3D(float x, float y, float w, float h)
Script-friendly 4-arg form (simplesquirrel does not apply C++ defaults).
Definition Graphics.h:952
bool(*)(void *userdata, void *commandBuffer) PresentOverlayFn
Optional overlay drawn inside the swapchain render pass (before end). Used by declarative UI (ImGui)....
Definition Graphics.h:1606
Shader * newShaderFromSpvFile(const std::string &fragPath)
Creates a shader from spv file. @ownership Caller deletes unless documented otherwise.
Definition Graphics.h:1716
virtual void gpuDrivenDrawOpaque()
Draw the opaque geometry with GPU-written indirect commands.
Definition Graphics.h:414
virtual bool gpuDrivenEnabled() const
Whether the GPU-driven opaque path is currently enabled.
Definition Graphics.h:268
virtual Texture * getSceneColorTexture()
Sampleable 3D color target for the current frame (RGB = lit, A = linear depth). Valid after begin3DFr...
Definition Graphics.h:1047
virtual void drawMeshShader(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint, Shader *shader)=0
Draw mesh with an explicit Mesh3D Shader (nullptr = default PBR pipeline).
virtual bool supportsDeferredLighting() const
True when the backend can run Hybrid clustered deferred lighting.
Definition Graphics.h:245
void printRGBA(const std::string &text, float x, float y, float r, float g, float b, float a, float scale=1.f)
Script-friendly stateful print overload using RGBA components.
Definition Graphics.h:1693
virtual float getSceneTransitionLensScale() const =0
Return the final-composite lens scaling factor.
virtual bool supportsRayTracing() const
True when the Vulkan device enabled the KHR ray-tracing path. WebGPU and software devices return fals...
Definition Graphics.h:262
virtual void gpuDrivenVgComputeSection(const glm::mat4 &viewProj, const glm::vec3 &eye, float fovYDeg, float nearZ, float farZ)
Record the HZB build + cull-params section (VG-only frames).
Definition Graphics.h:467
virtual Mesh * newMeshFromArrays(const float *posXYZ, const float *nrmXYZ, const float *uvST, int vertexCount, const uint32_t *indices, int indexCount)=0
Upload a triangle mesh from packed CPU arrays. Owned by Graphics. posXYZ required (vertexCount*3)....
Font * getFont() const
Returns the font.
Definition Graphics.h:1629
virtual SceneToneMapping getSceneToneMapping() const
Return the current final display mapping; graphics/render thread only.
Definition Graphics.h:1347
virtual void endDecalPass()=0
Ends decal pass.
virtual Result< void > replaceShaderFromSpv(Shader &shader, const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
Transactionally replace an existing shader with SPIR-V stages.
virtual void drawSolidRect(float x, float y, float w, float h, const Color &color, BlendMode blend=BlendMode::Alpha)=0
Internal immediate-mode helper used by RenderSystem / Batcher.
virtual void drawTexturedRectShader5(Texture *color, Texture *depth, Texture *motion, Texture *extra, Texture *specular, Shader *shader, float x, float y, float w, float h, const Color &tint)=0
Post draw with five sampled textures at bindings 0 through 4.
Shader * newMeshShader(const std::string &fragGlsl)
Creates a mesh shader. @ownership Caller deletes unless documented otherwise.
Definition Graphics.h:1866
virtual void end3DFrameToCanvas()=0
Ends 3 d frame to canvas.
virtual float getSceneDofMaxBlur() const =0
Returns the scene dof max blur.
PresentOverlayFn getPresentOverlay() const
Returns the present overlay.
Definition Graphics.h:1613
virtual Canvas * newCanvas(int width, int height)=0
Create an offscreen render target (sampleable). Owned by Graphics.
virtual Result< void > replaceShaderFromWgsl(Shader &shader, const std::string &vertWgsl, const std::string &fragWgsl)=0
Transactionally replace an existing shader with WGSL stages.
DisplayColorSpace
Color space actually selected for the live swapchain.
Definition Graphics.h:1329
virtual bool gpuDrivenVgAttachToMesh(Mesh *mesh, std::uint32_t vgAssetId)
Attach an uploaded VG asset to a mesh (routes it to the VG path).
Definition Graphics.h:446
virtual void drawDeferredLighting()
Fullscreen deferred lighting into the open scene-color pass. Samples GBuffer + clustered lights + CSM...
Definition Graphics.h:252
virtual Shader * newMeshShaderFromWgsl(const std::string &vertWgsl, const std::string &fragWgsl)=0
Create a Mesh3D custom shader from WGSL source (WebGPU backend). The WGSL must declare the engine's F...
virtual eve::Result< void > updateTextureRegion(Texture *texture, int x, int y, int width, int height, std::span< const std::uint8_t > rgba, std::size_t bytesPerRow=0)=0
Upload one tightly packed or row-strided RGBA8 rectangle into mip level zero.
virtual void setScreenReadbackEnabled(bool enabled)
When true, each present copies the swapchain to a CPU buffer for getPixel/newImageData....
Definition Graphics.h:1502
int getPixelWidth() const
Returns the pixel width.
Definition Graphics.h:506
virtual Mesh * newMeshFromArraysColored(const float *posXYZ, const float *nrmXYZ, const float *uvST, const float *colorRGBA, int vertexCount, const uint32_t *indices, int indexCount)=0
Upload a triangle mesh with an optional packed RGBA color per vertex.
virtual bool supportsDecal() const
True when the backend can render the screen-space decal layer (box-projected decals writing albedo/no...
Definition Graphics.h:1274
virtual Mesh * newMeshSphere(int slices=32, int stacks=16)=0
Procedural UV sphere (radius 1, Y-up). Owned by Graphics. slices = longitude divisions,...
virtual Texture * newTexture(image::ImageData *data, const TextureCreateInfo &info)=0
Create texture from ImageData with sampler / mipmap options.
virtual void setViewportSize(int width, int height, int pixelwidth, int pixelheight)=0
Sets the current graphics display viewport dimensions.
virtual void drawTexturedRectLitUV(Texture *albedo, Texture *normal, float x, float y, float w, float h, float u0, float v0, float u1, float v1, const Color &color, BlendMode blend=BlendMode::Alpha)=0
Lit 2D draw (albedo + normal map). Uses Lighting2DUBO from setLighting2D. normal may be null → treate...
virtual bool supportsRuntimeGlslCompilation() const
Whether this backend and build can compile GLSL to SPIR-V at runtime.
Definition Graphics.h:214
int getHeight() const
Returns the height.
Definition Graphics.h:504
Texture * takeFinalSceneTexture()
Consume and clear the per-frame HDR scene resolve override. @lifetime Returned texture is borrowed an...
Definition Graphics.h:2073
void * getPresentOverlayUser() const
Returns the present overlay user.
Definition Graphics.h:1615
void setPresentOverlay(PresentOverlayFn fn, void *userdata)
Sets the present overlay.
Definition Graphics.h:1608
void circle(std::string mode, float x, float y, float radius, int points)
Draws a circle using the specified arguments.
virtual RayTracingCaps rayTracingCaps() const
Probed ray-tracing capabilities (empty when unsupported).
Definition Graphics.h:265
virtual Shader * newShaderFromSpvFile(const std::string &vertPath, const std::string &fragPath)=0
Load SPIR-V from files via Filesystem (empty vertPath → default textured vert).
virtual Result< void > gpuDrivenReleaseMaterialRecord(Material *material)
Release a lazily-created GPU material-table record.
Definition Graphics.h:292
virtual void drawTexturedRectShader(Texture *texture, Shader *shader, float x, float y, float w, float h, const Color &color)=0
Draw with an explicit Shader (nullptr = default textured pipeline).
double getCurrentDPIScale() const
Returns the current dpi scale.
Definition Graphics.h:511
virtual void setMesh3DNormalTexture(Texture *normal)=0
Optional normal map for the next drawMesh / drawMeshShader (nullptr = flat).
virtual bool gpuDrivenCullBegin(const GpuInstance *instances, uint32_t instanceCount)
Upload sorted instances + bucket metadata for the cull chain.
Definition Graphics.h:394
virtual void setMesh3DHeightTexture(Texture *height)=0
Optional height map for parallax (R channel; nullptr = flat / off).
virtual Texture * newCubemap(int faceSize, const uint8_t *rgbaFaces, const TextureCreateInfo &info)=0
Cubemap with GGX specular mips and final diffuse-irradiance mip.
virtual void setMesh3DLighting(const Lighting3DPack &pack)=0
Per-frame ambient + up to 8 lights packed into Mesh3DUBO.
virtual std::uint32_t gpuDrivenVgUpload(const GpuVgAssetUpload &asset)
Upload a virtual-geometry asset into the shared cluster pool.
Definition Graphics.h:434
virtual void drawTexturedRectShaderDepth(Texture *color, Texture *depth, Shader *shader, float x, float y, float w, float h, const Color &tint)=0
Fullscreen/post draw sampling color at binding 0 and depth at binding 1 (hardware D32,...
virtual float getSceneDofFocusRange() const =0
Returns the scene dof focus range.
virtual bool updateGpuParticleEmitter(GpuParticleHandle handle, const GpuParticleUpdate &update, const GpuParticleSpawn *spawns, std::uint32_t spawnCount)
Upload one simulation step and optional spawn commands. @compatibility Preserves the established GPU-...
Definition Graphics.h:337
virtual Texture * newHDRCubemap(int faceSize)
Allocate a linear RGBA16F six-layer staging cubemap for runtime capture.
Definition Graphics.h:562
Dense grass + sparse dark tufts on a mesh. Caller owns GrassField*; GPU Mesh / Shader / Texture are o...
Definition Grass.h:193
Narrow offscreen-Canvas allocation boundary for tools and optional modules.
Narrow render-target binding boundary for optional tooling modules.
2D immediate-mode drawing surface (screen or offscreen Canvas).
Definition IGraphics2D.h:33
3D frame / mesh / light / shadow rendering surface.
Definition IGraphics3D.h:51
Post-process / special-effect object factory.
Definition IPostFX.h:21
Texture / mesh / shader / canvas creation and release.
Narrow solid-rectangle draw boundary for UI/debug tooling.
SLG / large-map war-fog overlay driven by a dual-scrolling cloud texture and an RGBA mask bridge (R u...
Definition MapFog.h:18
Packages shading method + surface parameters into one attachable asset.
Definition Material.h:35
GPU mesh handle (+ optional CPU morph targets).
Definition Mesh.h:25
Screen-space model outline (t3ssel8r-style), computed from the GBuffer hardware depth + world-normal ...
Definition Outline.h:33
Authoritative owner for primitives that persist across frames.
Pixel-space sub-rectangle of a Texture (atlas cell / sprite frame). UV conversion uses the texture's ...
Definition Quad.h:11
Incremental six-face HDR scene capture for a runtime reflection probe.
Scene-level stable selection of published reflection probes for a camera.
Declarative, compilable 3D render control.
Default renderable entity for declarative 2D sprites / solid quads.
Screen-space reflections (SSR) as a fullscreen post pass. @lifetime All Graphics and texture argument...
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
Volumetric light + fog.
Definition Volumetric.h:38
Dynamic water surface with sky reflection and animated ripples.
Definition Water.h:68
Flowing waterfall (falling water sheet) rendered on a vertical plane.
Definition Waterfall.h:34
Runtime groom drawable (UE UGroomComponent analogue).
Represents raw pixel data.
Definition ImageData.h:38
std::vector< ParamSpec > params
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
std::uint64_t GpuParticleHandle
Opaque backend-owned GPU particle emitter handle.
SurfaceMode
How a 3D surface contributes to depth and color passes.
Definition SurfaceMode.h:6
eve::Color Color
RGBA color used by every graphics draw call. Lives inside eve::graphics so including a graphics heade...
Definition Color.h:13
constexpr GpuParticleHandle kInvalidGpuParticleHandle
Invalid GPU particle handle returned when the backend cannot allocate the resource.
constexpr uint32_t kInvalidGpuDrivenSlot
GPU-driven rendering shared constants + std430 GPU layouts.
SkinInfluenceLimit
Number of strongest vertex influences retained by GPU skinning.
Definition IGraphics3D.h:19
GpuResidentSubmitStatus
Structured result for direct resident-instance submission.
eve::Subscription Subscription
Compatibility alias for the common observer lifetime token.
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
BlendMode
Render-neutral 2D blend mode shared by graphics-facing modules.
Definition RenderTypes.h:11
SettlementPipeline::Stage fn
bool enabled
Transient backend buffer slice shared between sibling GPU modules. @ownership Non-owning; nativeHandl...
CPU-built clustered lighting upload for one frame/camera. Point lights are clustered; directional lig...
Per-instance GPU record (std430). Mirrors GLSL GpuInstance.
Parameters for rendering a resident GPU particle emitter.
GPU particle state uploaded only for newly spawned particles.
Delayed non-blocking counters from a resident GPU emitter.
Parameters for one resident GPU simulation step.
Direct-render description for a GPU-authored array of GpuInstance records. @ownership buckets and buf...
Neutral GPU upload for one virtual-geometry asset. Raw arrays so the graphics module does not depend ...
DeferredFileTexture public API.
Definition Graphics.h:2225
Surface present formats the current device/window can offer.
Definition Graphics.h:1331
Per-pixel mesh entity-ID pass. Renders each EntityIdDraw's mesh with the given flat idColor (RGB enco...
Definition Graphics.h:1058
Lighting2DUBO public API.
Definition Light.h:53
Lighting3DPack public API.
Definition Light.h:172
Backend-owned layout facts for a mesh uploaded through Graphics.
Definition Graphics.h:86
Value snapshot of custom mesh rasterization state, independent of blending/culling.
Owning material parameter snapshot; texture pointers remain borrowed. Base color/metallic/roughness c...
Definition PbrSurface.h:218
Hardware ray-tracing capabilities probed once at Vulkan device creation.
ReflectionProbeUpload public API.
Definition IGraphics3D.h:26
Inputs for descriptor set 1 of a resource mesh program.
ShadowUpload public API.
Definition Shadow.h:54
Options for Graphics::newTexture / newCubemap. When generateMipmaps is true and sampler....
One borrowed RGBA8 source rectangle for a batched texture update. @ownership rgba remains owned by th...
Definition Graphics.h:70
std::span< const std::uint8_t > rgba
Definition Graphics.h:75
Sampler state for a Texture (filter, wrap, mip LOD, anisotropy). Defaults match historical engine beh...
glm::uvec4 info
glm::vec4 color