载入中...
搜索中...
未找到
Graphics.cpp
浏览该文件的文档.
1#include "graphics/Graphics.h"
2#include "common/Capability.h"
4#include "common/Profile.h"
6#include "common/config.h"
7#include "font/FontData.h"
9#include "graphics/Bloom.h"
13#include "graphics/Exposure.h"
17#include "graphics/Grass.h"
18#include "graphics/HairCards.h"
19#include "graphics/HairShader.h"
21#include "graphics/TreeWind.h"
23
24#ifdef EVENGINE_WEBGPU
26#else
28#endif
29#include "graphics/AlphaMask.h"
35#include "graphics/FogVolume.h"
36#include "graphics/Font.h"
37#include "graphics/GBuffer.h"
39#include "graphics/GrassWind.h"
40#include "graphics/Light.h"
41#include "graphics/MapFog.h"
42#include "graphics/Material.h"
43#include "graphics/Mesh.h"
44#include "graphics/Outline.h"
48#include "graphics/Quad.h"
58#include "graphics/Texture.h"
60#include "graphics/Volumetric.h"
61#include "graphics/Water.h"
66#include "graphics/Waterfall.h"
67#include "image/ImageData.h"
68
69#ifndef EVENGINE_WEBGPU
70#include "font/FontData.h"
71#endif
72#include "common/Diagnostic.h"
73#include "common/Exception.h"
74#include "common/RenderTrace.h"
75#include "common/Resource.h"
80#include "image/Image.h"
81#include "image/ImageData.h"
82
83
84#include <simplesquirrel/simplesquirrel.hpp>
85
86#include <algorithm>
87#include <cstdint>
88#include <filesystem>
89#include <fstream>
90#include <functional>
91#include <glm/gtc/type_ptr.hpp>
92#include <memory>
93
94namespace eve::graphics {
95
96namespace {
97
98
99bool copyArrayFloats(ssq::Array arr, std::vector<float>& out) {
100 const size_t n = arr.size();
101 out.resize(n);
102 for (size_t i = 0; i < n; ++i) out[i] = arr.get<float>(i);
103 return n > 0;
104}
105
106bool copyArrayUints(ssq::Array arr, std::vector<uint32_t>& out) {
107 const size_t n = arr.size();
108 out.resize(n);
109 for (size_t i = 0; i < n; ++i) out[i] = static_cast<uint32_t>(arr.get<int>(i));
110 return n > 0;
111}
112
113Mesh* newMeshFromArraysScript(Graphics* gfx, ssq::Array posArr, ssq::Array nrmArr, ssq::Array uvArr, int vertexCount,
114 ssq::Array idxArr, int indexCount) {
115 std::vector<float> pos, nrm, uv;
116 std::vector<uint32_t> idx;
117 copyArrayFloats(posArr, pos);
118 copyArrayFloats(nrmArr, nrm);
119 copyArrayFloats(uvArr, uv);
120 copyArrayUints(idxArr, idx);
121 return gfx->newMeshFromArrays(pos.data(), nrm.empty() ? nullptr : nrm.data(), uv.empty() ? nullptr : uv.data(),
122 vertexCount, idx.empty() ? nullptr : idx.data(), indexCount);
123}
124
125bool updateMeshVerticesScript(Graphics* gfx, Mesh* mesh, ssq::Array posArr, ssq::Array nrmArr, ssq::Array uvArr,
126 int vertexCount, ssq::Array idxArr, int indexCount) {
127 std::vector<float> pos, nrm, uv;
128 std::vector<uint32_t> idx;
129 copyArrayFloats(posArr, pos);
130 copyArrayFloats(nrmArr, nrm);
131 copyArrayFloats(uvArr, uv);
132 copyArrayUints(idxArr, idx);
133 return gfx->updateMeshVertices(mesh, pos.data(), nrm.empty() ? nullptr : nrm.data(),
134 uv.empty() ? nullptr : uv.data(), vertexCount, idx.empty() ? nullptr : idx.data(),
135 indexCount);
136}
137
138void setMesh3DViewProjScript(Graphics* gfx, ssq::Array a) {
139 if (a.size() != 16) throw eve::Exception("setMesh3DViewProj: expected 16 floats");
140 glm::mat4 m(1.f);
141 for (size_t i = 0; i < 16; ++i) glm::value_ptr(m)[i] = a.get<float>(i);
142 gfx->setMesh3DViewProj(m);
143}
144
145void setMesh3DViewScript(Graphics* gfx, ssq::Array a) {
146 if (a.size() != 16) throw eve::Exception("setMesh3DView: expected 16 floats");
147 glm::mat4 m(1.f);
148 for (size_t i = 0; i < 16; ++i) glm::value_ptr(m)[i] = a.get<float>(i);
149 gfx->setMesh3DView(m);
150}
151
152void setMesh3DCameraPosScript(Graphics* gfx, float x, float y, float z) { gfx->setMesh3DCameraPos(glm::vec3(x, y, z)); }
153
154void setCanvasScript(Graphics* gfx, ssq::Object obj) {
155 if (obj.isNull()) {
156 gfx->setCanvas(nullptr);
157 return;
158 }
159 gfx->setCanvas(obj.toPtrUnsafe<Canvas*>());
160}
161
162void setShaderScript(Graphics* gfx, ssq::Object obj) {
163 if (obj.isNull()) {
164 gfx->setShader();
165 return;
166 }
167 gfx->setShader(obj.toPtrUnsafe<Shader*>());
168}
169
170} // namespace
171
173 : rayTracing_(eve::cap::ProviderRef<IRayTracing>::bind()), frameCaptures_(std::make_unique<FrameCaptureStore>()) {
174 primitiveScene_ = std::make_shared<PrimitiveScene>();
175 // The window module owns the native window; we own the render surface.
176 // Register as its surface host so window never has to include graphics.
177 // The query happens after native window creation, so this pointer is valid
178 // by the time it is used; see common/WindowSurfaceHost.h.
179 eve::cap::provide<IWindowSurfaceHost>(this);
180 eve::cap::provide<IFramePresentation>(this);
181 eve::cap::provide<IRenderFrameCapture>(frameCaptures_.get());
184}
185
187 if (!rayTracing_) return std::nullopt;
188 return std::ref(*rayTracing_);
189}
190
192 eve::cap::revoke<IRenderFrameCapture>(frameCaptures_.get());
193 eve::cap::revoke<IFramePresentation>(this);
195 // Derived backends detach first, while their virtual releaseMesh boundary
196 // is still live. This base path covers host-only Graphics subclasses.
198 // Out-of-line so unique_ptr members of effect classes (Outline, AO, GI, …)
199 // are destroyed where the complete types are visible.
200}
201
203
204#ifdef EVENGINE_WEBGPU
206#else
208#endif
209
220
223 RenderSystem3D::renderToCanvas(*this, canvas, camera, 0xffffffffu, 1.f, true, true, nullptr, nullptr, 1.f, true);
225}
226
228 if (!canvas || !camera) return;
232}
233
235 if (!scene) return nullptr;
237 const bool doAA = !renderControl_ || renderControl_->isEnabled("aa") || renderControl_->isEnabled("taa");
238 aa->setMode("fxaa");
239 if (doAA) {
240 const std::string requested = renderControl_ ? renderControl_->getPostProcessQuality() : "high";
241 const std::string quality = requested == "ultra" ? "high" : requested;
242 if (aa->getQuality() != quality) aa->setQuality(quality);
243 } else {
244 if (aa->getMode() == "fxaa") {
245 aa->setFloat("edgeThreshold", 1.f);
246 aa->setFloat("edgeThresholdMin", 1.f);
247 aa->setFloat("subpix", 0.f);
248 }
249 }
250 aa->prepareSource(scene);
251 return aa->getShader();
252}
253
254void Graphics::drawScene3DRGBA(float x, float y, float w, float h, float r, float g, float b, float a) {
256 if (!scene) return;
257 // Queue a scene-color blit at this 2D overlay slot so present() owns
258 // AA/Bloom/Exposure + ACES. Running prepareFinalSceneTexture here would
259 // setCanvas() (ending the still-open scene pass and queueing auto-resolve)
260 // then blit the HDR result through the LDR textured pipeline *on top of*
261 // the auto ACES composite — two fullscreen 3D quads that strobe.
262 drawTexturedRectShaderUV(scene, nullptr, x, y, w, h, 0.f, 0.f, 1.f, 1.f, Color(r, g, b, a), false,
264}
265
266void Graphics::drawCanvasRGBA(Canvas* canvas, float x, float y, float w, float h, float r, float g, float b, float a) {
267 if (!canvas) return;
268 Texture* tex = canvas->getTexture();
269 if (!tex) return;
270 drawTexturedRect(tex, x, y, w, h, Color(r, g, b, a));
271}
272
273void Graphics::setDirectionalLight(float dx, float dy, float dz, float r, float g, float b) {
275}
276
278
280 if (!renderControl_) {
281 renderControl_ = std::make_unique<RenderControl>();
282 renderControl_->attach(this);
283 // Phase D: desktop→Hybrid when deferred is available; CI/mobile stay ForwardPlus.
284 // Explicit EVENGINE_LIGHTING_MODE overrides the suggested preset.
285 auto applied = renderControl_->applySuggestedLightingPreset();
286 applied.ignore();
287 renderControl_->compile();
288 }
289 return renderControl_.get();
290}
291
292void Graphics::expose(ssq::Table& table) {
293 auto cls = table.addClass(name, Graphics::create, false);
294 expose(cls);
295
299 auto depthOfField = table.addClass<DepthOfField>(
300 "DepthOfField", std::function<DepthOfField*()>([]() -> DepthOfField* { return nullptr; }), true);
301 depthOfField.addFunc("apply", &DepthOfField::apply);
310
312
313 auto maskCls = table.addClass<AlphaMask>("AlphaMask",
314 std::function<AlphaMask*()>([]() -> AlphaMask* { return nullptr; }), true);
315 maskCls.addFunc("setThreshold", &AlphaMask::setThreshold);
316 maskCls.addFunc("getThreshold", &AlphaMask::getThreshold);
317 maskCls.addFunc("setSoftness", &AlphaMask::setSoftness);
318 maskCls.addFunc("getSoftness", &AlphaMask::getSoftness);
319 maskCls.addFunc("setInverted", &AlphaMask::setInverted);
320 maskCls.addFunc("getInverted", &AlphaMask::getInverted);
321 maskCls.addFunc("draw", &AlphaMask::draw);
322
323 auto mapFogCls =
324 table.addClass<MapFog>("MapFog", std::function<MapFog*()>([]() -> MapFog* { return nullptr; }), true);
325 mapFogCls.addFunc("update", &MapFog::update);
326 mapFogCls.addFunc("setTime", &MapFog::setTime);
327 mapFogCls.addFunc("getTime", &MapFog::getTime);
328 mapFogCls.addFunc("setCloudTexture", &MapFog::setCloudTexture);
329 mapFogCls.addFunc("getCloudTexture", &MapFog::getCloudTexture);
330 mapFogCls.addFunc("setMaskTexture", &MapFog::setMaskTexture);
331 mapFogCls.addFunc("getMaskTexture", &MapFog::getMaskTexture);
332 mapFogCls.addFunc("setCloudTiling", &MapFog::setCloudTiling);
333 mapFogCls.addFunc("setCloudSpeed", &MapFog::setCloudSpeed);
334 mapFogCls.addFunc("setDistort", &MapFog::setDistort);
335 mapFogCls.addFunc("setDistortFix", &MapFog::setDistortFix);
336 mapFogCls.addFunc("setFogColor", &MapFog::setFogColor);
337 mapFogCls.addFunc("setFogAlpha", &MapFog::setFogAlpha);
338 mapFogCls.addFunc("setEdgeSoftness", &MapFog::setEdgeSoftness);
339 mapFogCls.addFunc("setShadowEnabled", &MapFog::setShadowEnabled);
340 mapFogCls.addFunc("setShadow", &MapFog::setShadow);
341 mapFogCls.addFunc("setSelectStrength", &MapFog::setSelectStrength);
342 mapFogCls.addFunc("setDissolveScale", &MapFog::setDissolveScale);
343 mapFogCls.addFunc("setCloudMix", &MapFog::setCloudMix);
344 mapFogCls.addFunc("setCloudDensity", &MapFog::setCloudDensity);
345 mapFogCls.addFunc("getCloudTileA", &MapFog::getCloudTileA);
346 mapFogCls.addFunc("getCloudTileB", &MapFog::getCloudTileB);
347 mapFogCls.addFunc("getFogAlpha", &MapFog::getFogAlpha);
348 mapFogCls.addFunc("getShadowEnabled", &MapFog::getShadowEnabled);
349 mapFogCls.addFunc("makeCloudTexture", &MapFog::makeCloudTexture);
350 mapFogCls.addFunc("draw", &MapFog::draw);
351
352 auto texCls =
353 table.addClass<Texture>("Texture", std::function<Texture*()>([]() -> Texture* { return nullptr; }), true);
354 texCls.addFunc("setCastOcclusion", &Texture::setCastOcclusion);
355 texCls.addFunc("getCastOcclusion", &Texture::getCastOcclusion);
356 texCls.addFunc("getWidth", &Texture::getWidth);
357 texCls.addFunc("getHeight", &Texture::getHeight);
358 texCls.addFunc("getMipmapCount", &Texture::getMipmapCount);
359 texCls.addFunc("setAlphaConvention", &Texture::setAlphaConvention);
360 texCls.addFunc("getAlphaConvention", &Texture::getAlphaConvention);
361
362 // Texture / Mesh expose occlusion flags used by volumetric light shafts.
363 // (create returns null — instances come from Graphics::newTexture / newMesh*)
364
366
367 auto quad = table.addClass<Quad>("Quad", std::function<Quad*()>([]() -> Quad* { return nullptr; }), true);
368 quad.addFunc("setViewport", &Quad::setViewport);
369 quad.addFunc("getX", &Quad::getX);
370 quad.addFunc("getY", &Quad::getY);
371 quad.addFunc("getWidth", &Quad::getWidth);
372 quad.addFunc("getHeight", &Quad::getHeight);
373
374 auto shader = table.addClass<Shader>("Shader", std::function<Shader*()>([]() -> Shader* { return nullptr; }), true);
375 shader.addFunc("declareFloat", &Shader::declareFloat);
376 shader.addFunc("declareVec2", &Shader::declareVec2);
377 shader.addFunc("declareVec3", &Shader::declareVec3);
378 shader.addFunc("declareVec4", &Shader::declareVec4);
379 shader.addFunc("declareMatrix", &Shader::declareMatrix);
380 shader.addFunc("sendFloat", &Shader::sendFloat);
381 shader.addFunc("sendVec2", &Shader::sendVec2);
382 shader.addFunc("sendVec3", &Shader::sendVec3);
383 shader.addFunc("sendVec4", &Shader::sendVec4);
384 shader.addFunc("setMeshTexture", [](Shader* self, int slot, Texture* texture) {
385 if (slot < 0) throw Exception("Shader.setMeshTexture: slot must be in [0,4)");
386 auto result = self->setMeshTexture(static_cast<std::size_t>(slot), texture);
387 if (!result) throw Exception("Shader.setMeshTexture: slot must be in [0,4)");
388 });
389 shader.addFunc("hasUniform", &Shader::hasUniform);
390 shader.addFunc("getUniformIndex", &Shader::getUniformIndex);
391
392 // ECS entities live in the registry buffer (not standalone new/delete).
393 // Squirrel must not delete them on VM shutdown or close asserts
394 // _CrtIsValidHeapPointer.
395 auto cam2d = table.addClass<Camera2D>("Camera2D",
396 std::function<Camera2D*()>([]() { return Camera2D::createCamera(); }), false);
397 cam2d.addFunc("setAmbient", &Camera2D::setAmbient);
398 cam2d.addFunc("setPosition", &Camera2D::setPosition);
399 cam2d.addFunc("getX", &Camera2D::getX);
400 cam2d.addFunc("getY", &Camera2D::getY);
401 cam2d.addFunc("setZoom", &Camera2D::setZoom);
402 cam2d.addFunc("getZoom", &Camera2D::getZoom);
403 cam2d.addFunc("setPixelConfig",
404 [vm = table.getHandle()](Camera2D* self, float pixelsPerUnit, int refWidth, int refHeight) {
405 return eve::script::projectResult(vm, self->setPixelConfig(pixelsPerUnit, refWidth, refHeight));
406 });
407 cam2d.addFunc("clearPixelConfig", &Camera2D::clearPixelConfig);
408 cam2d.addFunc("setPixelPerfect", &Camera2D::setPixelPerfect);
409 cam2d.addFunc("getPixelPerfect", &Camera2D::getPixelPerfect);
410 cam2d.addFunc("setPixelSnap", &Camera2D::setPixelSnap);
411 cam2d.addFunc("getPixelSnap", &Camera2D::getPixelSnap);
412 cam2d.addFunc("applyPixelPerfect", [vm = table.getHandle()](Camera2D* self, int viewWidth, int viewHeight) {
413 return eve::script::projectResult(vm, self->applyPixelPerfect(viewWidth, viewHeight));
414 });
415 cam2d.addFunc("getPixelsPerUnit", &Camera2D::getPixelsPerUnit);
416 cam2d.addFunc("getPixelRefWidth", &Camera2D::getPixelRefWidth);
417 cam2d.addFunc("getPixelRefHeight", &Camera2D::getPixelRefHeight);
418 cam2d.addFunc("getPixelScale", &Camera2D::getPixelScale);
419 cam2d.addFunc("screenToWorldX", &Camera2D::screenToWorldX);
420 cam2d.addFunc("screenToWorldY", &Camera2D::screenToWorldY);
421 cam2d.addFunc("worldToScreenX", &Camera2D::worldToScreenX);
422 cam2d.addFunc("worldToScreenY", &Camera2D::worldToScreenY);
423
424 auto light = table.addClass<Light2D>(
425 "Light2D", std::function<Light2D*()>([]() { return Light2D::createLight("point"); }), false);
426 light.addFunc("setType", &Light2D::setType);
427 light.addFunc("getType", &Light2D::getType);
428 light.addFunc("setPosition", &Light2D::setPosition);
429 light.addFunc("getX", &Light2D::getX);
430 light.addFunc("getY", &Light2D::getY);
431 light.addFunc("setDirection", &Light2D::setDirection);
432 light.addFunc("getDirX", &Light2D::getDirX);
433 light.addFunc("getDirY", &Light2D::getDirY);
434 light.addFunc("setColor", &Light2D::setColor);
435 light.addFunc("setRadius", &Light2D::setRadius);
436 light.addFunc("getRadius", &Light2D::getRadius);
437 light.addFunc("setSpotAngle", &Light2D::setSpotAngle);
438 light.addFunc("getSpotAngle", &Light2D::getSpotAngle);
439 light.addFunc("setSpotSoftness", &Light2D::setSpotSoftness);
440 light.addFunc("getSpotSoftness", &Light2D::getSpotSoftness);
441 light.addFunc("setEnabled", &Light2D::setEnabled);
442 light.addFunc("isEnabled", &Light2D::isEnabled);
443 light.addFunc("setVolumetric", &Light2D::setVolumetric);
444 light.addFunc("getVolumetric", &Light2D::getVolumetric);
445 light.addFunc("setVolumetricIntensity", &Light2D::setVolumetricIntensity);
446 light.addFunc("getVolumetricIntensity", &Light2D::getVolumetricIntensity);
447 light.addFunc("setVolumetricOnly", &Light2D::setVolumetricOnly);
448 light.addFunc("getVolumetricOnly", &Light2D::getVolumetricOnly);
449 light.addFunc("setCanvas", &Light2D::setCanvas);
450 table.addFunc("createEmissiveLight2D",
451 std::function<Light2D *(float, float, float, float, float, float, float)>(
452 [](float x, float y, float r, float g, float b, float intensity, float radius) {
453 return Light2D::createEmissiveProxy(x, y, r, g, b, intensity, radius);
454 }));
455
456 auto cam = table.addClass<Camera3D>("Camera3D",
457 std::function<Camera3D*()>([]() { return Camera3D::createCamera(); }), false);
458 cam.addFunc("setEye", &Camera3D::setEye);
459 cam.addFunc("getEyeX", &Camera3D::getEyeX);
460 cam.addFunc("getEyeY", &Camera3D::getEyeY);
461 cam.addFunc("getEyeZ", &Camera3D::getEyeZ);
462 cam.addFunc("setTarget", &Camera3D::setTarget);
463 cam.addFunc("getTargetX", &Camera3D::getTargetX);
464 cam.addFunc("getTargetY", &Camera3D::getTargetY);
465 cam.addFunc("getTargetZ", &Camera3D::getTargetZ);
466 cam.addFunc("setUp", &Camera3D::setUp);
467 cam.addFunc("setFov", &Camera3D::setFov);
468 cam.addFunc("getFov", &Camera3D::getFov);
469 cam.addFunc("setOrthographic", &Camera3D::setOrthographic);
470 cam.addFunc("setPerspective", &Camera3D::setPerspective);
471 cam.addFunc("isOrthographic", &Camera3D::isOrthographic);
472 cam.addFunc("getOrthoHeight", &Camera3D::getOrthoHeight);
473 cam.addFunc("setPixelConfig",
474 [vm = table.getHandle()](Camera3D* self, float pixelsPerUnit, int refWidth, int refHeight) {
475 return eve::script::projectResult(vm, self->setPixelConfig(pixelsPerUnit, refWidth, refHeight));
476 });
477 cam.addFunc("clearPixelConfig", &Camera3D::clearPixelConfig);
478 cam.addFunc("hasPixelConfig", &Camera3D::hasPixelConfig);
479 cam.addFunc("setPixelSnap", &Camera3D::setPixelSnap);
480 cam.addFunc("getPixelSnap", &Camera3D::getPixelSnap);
481 cam.addFunc("getPixelsPerUnit", &Camera3D::getPixelsPerUnit);
482 cam.addFunc("getPixelRefWidth", &Camera3D::getPixelRefWidth);
483 cam.addFunc("getPixelRefHeight", &Camera3D::getPixelRefHeight);
484 cam.addFunc("getPixelScale", &Camera3D::getPixelScale);
485 cam.addFunc("applyPixelPerfect", [vm = table.getHandle()](Camera3D* self, int viewWidth, int viewHeight) {
486 return eve::script::projectResult(vm, self->applyPixelPerfect(viewWidth, viewHeight));
487 });
488 cam.addFunc("setPixelOrthographic", [vm = table.getHandle()](Camera3D* self, float pixelsPerUnit, int viewWidth,
489 int viewHeight, int refWidth, int refHeight) {
490 return eve::script::projectResult(
491 vm, self->setPixelOrthographic(pixelsPerUnit, viewWidth, viewHeight, refWidth, refHeight));
492 });
493 cam.addFunc("snapToPixelGrid", &Camera3D::snapToPixelGrid);
494 cam.addFunc("setClipPlanes", &Camera3D::setClipPlanes);
495 cam.addFunc("getNearClip", &Camera3D::getNearClip);
496 cam.addFunc("getFarClip", &Camera3D::getFarClip);
497 cam.addFunc("setPhysicalLens", &Camera3D::setPhysicalLens);
498 cam.addFunc("getAperture", &Camera3D::getAperture);
499 cam.addFunc("getFocalLength", &Camera3D::getFocalLength);
500 cam.addFunc("setLayerCullDistance", &Camera3D::setLayerCullDistance);
501 cam.addFunc("getLayerCullDistance", &Camera3D::getLayerCullDistance);
502 cam.addFunc("setShadowLayerCullDistance", &Camera3D::setShadowLayerCullDistance);
503 cam.addFunc("getShadowLayerCullDistance", &Camera3D::getShadowLayerCullDistance);
504 cam.addFunc("setActive", &Camera3D::setActive);
505 cam.addFunc("setAmbient", &Camera3D::setAmbient);
506 cam.addFunc("setEnvMap", &Camera3D::setEnvMap);
507 cam.addFunc("setEnvIntensity", &Camera3D::setEnvIntensity);
508 cam.addFunc("setExposure", &Camera3D::setExposure);
509 cam.addFunc("getExposure", &Camera3D::getExposure);
510 cam.addFunc("setAutoExposure", &Camera3D::setAutoExposure);
511 cam.addFunc("isAutoExposure", &Camera3D::isAutoExposure);
512 cam.addFunc("setBloom", &Camera3D::setBloom);
513 cam.addFunc("getBloomIntensity", &Camera3D::getBloomIntensity);
514 cam.addFunc("getBloomThreshold", &Camera3D::getBloomThreshold);
515 cam.addFunc("setDepthOfField", &Camera3D::setDepthOfField);
516 cam.addFunc("clearDepthOfField", &Camera3D::clearDepthOfField);
517 cam.addFunc("getDofFocusDistance", &Camera3D::getDofFocusDistance);
518 cam.addFunc("getDofMaxBlur", &Camera3D::getDofMaxBlur);
519 cam.addFunc("getDofFocusRange", &Camera3D::getDofFocusRange);
520 cam.addFunc("setEnvProbe", &Camera3D::setEnvProbe);
521 cam.addFunc("clearEnvProbe", &Camera3D::clearEnvProbe);
522 cam.addFunc("hasEnvProbe", &Camera3D::hasEnvProbe);
523 cam.addFunc("getEnvProbeCenterX", &Camera3D::getEnvProbeCenterX);
524 cam.addFunc("getEnvProbeCenterY", &Camera3D::getEnvProbeCenterY);
525 cam.addFunc("getEnvProbeCenterZ", &Camera3D::getEnvProbeCenterZ);
526 cam.addFunc("getEnvProbeExtentX", &Camera3D::getEnvProbeExtentX);
527 cam.addFunc("getEnvProbeExtentY", &Camera3D::getEnvProbeExtentY);
528 cam.addFunc("getEnvProbeExtentZ", &Camera3D::getEnvProbeExtentZ);
529 cam.addFunc("setReflectionProbe", &Camera3D::setReflectionProbe);
530 cam.addFunc("clearReflectionProbe", &Camera3D::clearReflectionProbe);
531 cam.addFunc("getReflectionProbeCount", &Camera3D::getReflectionProbeCount);
532 cam.addFunc("screenToRay", &Camera3D::screenToRay);
533 cam.addFunc("getScreenRayOriginX", &Camera3D::getScreenRayOriginX);
534 cam.addFunc("getScreenRayOriginY", &Camera3D::getScreenRayOriginY);
535 cam.addFunc("getScreenRayOriginZ", &Camera3D::getScreenRayOriginZ);
536 cam.addFunc("getScreenRayDirX", &Camera3D::getScreenRayDirX);
537 cam.addFunc("getScreenRayDirY", &Camera3D::getScreenRayDirY);
538 cam.addFunc("getScreenRayDirZ", &Camera3D::getScreenRayDirZ);
539
540 auto light3d = table.addClass<Light3D>(
541 "Light3D", std::function<Light3D*()>([]() { return Light3D::createLight("point"); }), false);
542 light3d.addFunc("setType", &Light3D::setType);
543 light3d.addFunc("getType", &Light3D::getType);
544 light3d.addFunc("setPosition", &Light3D::setPosition);
545 light3d.addFunc("getX", &Light3D::getX);
546 light3d.addFunc("getY", &Light3D::getY);
547 light3d.addFunc("getZ", &Light3D::getZ);
548 light3d.addFunc("setDirection", &Light3D::setDirection);
549 light3d.addFunc("getDirX", &Light3D::getDirX);
550 light3d.addFunc("getDirY", &Light3D::getDirY);
551 light3d.addFunc("getDirZ", &Light3D::getDirZ);
552 light3d.addFunc("setColor", &Light3D::setColor);
553 light3d.addFunc("setRadius", &Light3D::setRadius);
554 light3d.addFunc("getRadius", &Light3D::getRadius);
555 light3d.addFunc("setSpotAngle", &Light3D::setSpotAngle);
556 light3d.addFunc("getSpotAngle", &Light3D::getSpotAngle);
557 light3d.addFunc("setSpotSoftness", &Light3D::setSpotSoftness);
558 light3d.addFunc("getSpotSoftness", &Light3D::getSpotSoftness);
559 light3d.addFunc("setEnabled", &Light3D::setEnabled);
560 light3d.addFunc("isEnabled", &Light3D::isEnabled);
561 light3d.addFunc("setCastShadow", &Light3D::setCastShadow);
562 light3d.addFunc("getCastShadow", &Light3D::getCastShadow);
563 light3d.addFunc("setShadowMethod", &Light3D::setShadowMethod);
564 light3d.addFunc("getShadowMethod", &Light3D::getShadowMethod);
565 light3d.addFunc("setShadowBias", &Light3D::setShadowBias);
566 light3d.addFunc("getShadowBias", &Light3D::getShadowBias);
567 light3d.addFunc("setShadowStrength", &Light3D::setShadowStrength);
568 light3d.addFunc("getShadowStrength", &Light3D::getShadowStrength);
569 light3d.addFunc("setVolumetric", &Light3D::setVolumetric);
570 light3d.addFunc("getVolumetric", &Light3D::getVolumetric);
571 light3d.addFunc("setVolumetricIntensity", &Light3D::setVolumetricIntensity);
572 light3d.addFunc("getVolumetricIntensity", &Light3D::getVolumetricIntensity);
573 light3d.addFunc("setVolumetricOnly", &Light3D::setVolumetricOnly);
574 light3d.addFunc("getVolumetricOnly", &Light3D::getVolumetricOnly);
575 table.addFunc("createEmissiveLight3D",
576 std::function<Light3D *(float, float, float, float, float, float, float, float)>(
577 [](float x, float y, float z, float r, float g, float b, float intensity,
578 float radius) {
579 return Light3D::createEmissiveProxy(x, y, z, r, g, b, intensity, radius);
580 }));
582
583 auto sprite2d = table.addClass<Renderable2D>(
584 "Sprite2D", std::function<Renderable2D*()>([]() { return Renderable2D::create(); }), false);
585 sprite2d.addFunc("setPosition", &Renderable2D::setPosition);
586 sprite2d.addFunc("getX", &Renderable2D::getX);
587 sprite2d.addFunc("getY", &Renderable2D::getY);
588 sprite2d.addFunc("setRotation", &Renderable2D::setRotation);
589 sprite2d.addFunc("getRotation", &Renderable2D::getRotation);
590 sprite2d.addFunc("setScale", &Renderable2D::setScale);
591 sprite2d.addFunc("getScaleX", &Renderable2D::getScaleX);
592 sprite2d.addFunc("getScaleY", &Renderable2D::getScaleY);
593 sprite2d.addFunc("setSize", &Renderable2D::setSize);
594 sprite2d.addFunc("getWidth", &Renderable2D::getWidth);
595 sprite2d.addFunc("getHeight", &Renderable2D::getHeight);
596 sprite2d.addFunc("setTexture", &Renderable2D::setTexture);
597 sprite2d.addFunc("getTexture", &Renderable2D::getTexture);
598 sprite2d.addFunc("setNormalTexture", &Renderable2D::setNormalTexture);
599 sprite2d.addFunc("getNormalTexture", &Renderable2D::getNormalTexture);
600 sprite2d.addFunc("setQuad", &Renderable2D::setQuad);
601 sprite2d.addFunc("getQuad", &Renderable2D::getQuad);
602 sprite2d.addFunc("setColor", &Renderable2D::setColor);
603 sprite2d.addFunc("setLayer", &Renderable2D::setLayer);
604 sprite2d.addFunc("getLayer", &Renderable2D::getLayer);
605 sprite2d.addFunc("setVisible", &Renderable2D::setVisible);
606 sprite2d.addFunc("getVisible", &Renderable2D::getVisible);
607 sprite2d.addFunc("setReceiveLight", &Renderable2D::setReceiveLight);
608 sprite2d.addFunc("getReceiveLight", &Renderable2D::getReceiveLight);
609 sprite2d.addFunc("setBlend", &Renderable2D::setBlend);
610 sprite2d.addFunc("getBlend", &Renderable2D::getBlend);
611 sprite2d.addFunc("setAnchor", &Renderable2D::setAnchor);
612 sprite2d.addFunc("getAnchorX", &Renderable2D::getAnchorX);
613 sprite2d.addFunc("getAnchorY", &Renderable2D::getAnchorY);
614 sprite2d.addFunc("setFlip", &Renderable2D::setFlip);
615 sprite2d.addFunc("getFlipX", &Renderable2D::getFlipX);
616 sprite2d.addFunc("getFlipY", &Renderable2D::getFlipY);
617 sprite2d.addFunc("setFrameLayout", &Renderable2D::setFrameLayout);
618 sprite2d.addFunc("setCastOcclusion", &Renderable2D::setCastOcclusion);
619 sprite2d.addFunc("getCastOcclusion", &Renderable2D::getCastOcclusion);
620 sprite2d.addFunc("destroy", [](Renderable2D* self) { self->release(); });
621
622 auto material =
623 table.addClass<Material>("Material", std::function<Material*()>([]() -> Material* { return nullptr; }), true);
624 material.addFunc("setShadingModel", &Material::setShadingModel);
625 material.addFunc("getShadingModel", &Material::getShadingModel);
626 material.addFunc(
627 "setFoliageTranslucency",
628 [vm = table.getHandle()](Material* self, float red, float green, float blue, float intensity, float strength,
629 float normalDistortion, float scattering, float direct, float ambient, float shadow) {
630 return eve::script::projectResult(
631 vm, self->setFoliageTranslucency(red, green, blue, intensity, strength, normalDistortion, scattering,
632 direct, ambient, shadow));
633 });
634 material.addFunc("setClearcoat", [vm = table.getHandle()](Material* self, float factor, float roughness) {
635 return eve::script::projectResult(vm, self->setClearcoat(factor, roughness));
636 });
637 material.addFunc("setFoliageWindTime", [vm = table.getHandle()](Material* self, float seconds) {
638 return eve::script::projectResult(vm, self->setFoliageWindTime(seconds));
639 });
640 material.addFunc("setAlbedoTexture", &Material::setAlbedoTexture);
641 material.addFunc("getAlbedoTexture", &Material::getAlbedoTexture);
642 material.addFunc("setAlbedoUvOffset", [vm = table.getHandle()](Material* self, float u, float v) {
643 return eve::script::projectResult(vm, self->setAlbedoUvOffset(u, v));
644 });
645 material.addFunc("getAlbedoUvOffsetU", &Material::getAlbedoUvOffsetU);
646 material.addFunc("getAlbedoUvOffsetV", &Material::getAlbedoUvOffsetV);
647 material.addFunc("setAlbedoUvScale", [vm = table.getHandle()](Material* self, float u, float v) {
648 return eve::script::projectResult(vm, self->setAlbedoUvScale(u, v));
649 });
650 material.addFunc("getAlbedoUvScaleU", &Material::getAlbedoUvScaleU);
651 material.addFunc("getAlbedoUvScaleV", &Material::getAlbedoUvScaleV);
652 material.addFunc("setAlbedoUvRotation", [vm = table.getHandle()](Material* self, float radians) {
653 return eve::script::projectResult(vm, self->setAlbedoUvRotation(radians));
654 });
655 material.addFunc("getAlbedoUvRotation", &Material::getAlbedoUvRotation);
656 material.addFunc("setNormalTexture", &Material::setNormalTexture);
657 material.addFunc("getNormalTexture", &Material::getNormalTexture);
658 material.addFunc("setHeightTexture", &Material::setHeightTexture);
659 material.addFunc("getHeightTexture", &Material::getHeightTexture);
660 material.addFunc("enableVirtualTexture",
661 [](Material* self, int width, int height, int tileSize, int borderSize, int residentCapacity,
662 int maxDecodesPerUpdate) {
663 if (!self) throw eve::Exception("Material.enableVirtualTexture: null self");
664 VirtualTextureStreamingConfig config{};
665 config.blend.width = width;
666 config.blend.height = height;
667 config.blend.tileSize = tileSize;
668 config.blend.borderSize = borderSize;
669 config.blend.residentPageCapacity = std::size_t(std::max(1, residentCapacity));
670 config.maxDecodesPerUpdate = std::size_t(std::max(1, maxDecodesPerUpdate));
671 auto result = self->enableVirtualTexture(config);
672 if (!result.ok()) throw eve::Exception("%s", result.status().describe().c_str());
673 });
674 auto addMaterialVtLayer = [](Material* self, image::ImageData* albedo, image::ImageData* normal,
675 image::ImageData* weight, float uvScale, float constantWeight, float heightContrast) {
676 if (!self) throw eve::Exception("Material.addVirtualTextureLayer: null self");
677 if (!albedo) throw eve::Exception("Material.addVirtualTextureLayer: albedo is required");
678 VirtualTextureBlendLayer layer{};
679 layer.albedo = std::shared_ptr<image::ImageData>(albedo, [](image::ImageData*) {});
680 if (normal) layer.normal = std::shared_ptr<image::ImageData>(normal, [](image::ImageData*) {});
681 if (weight) layer.weight = std::shared_ptr<image::ImageData>(weight, [](image::ImageData*) {});
682 layer.uvScale = uvScale;
683 layer.constantWeight = constantWeight;
684 layer.heightContrast = heightContrast;
685 auto result = self->addVirtualTextureLayer(layer);
686 if (!result.ok()) throw eve::Exception("%s", result.status().describe().c_str());
687 return int(result.value());
688 };
689 material.addFunc("addVirtualTextureLayer",
690 [addMaterialVtLayer](Material* self, image::ImageData* albedo, image::ImageData* normal,
691 float uvScale, float constantWeight, float heightContrast) {
692 return addMaterialVtLayer(self, albedo, normal, nullptr, uvScale, constantWeight,
693 heightContrast);
694 });
695 material.addFunc("addVirtualTextureLayerWeighted",
696 [addMaterialVtLayer](Material* self, image::ImageData* albedo, image::ImageData* normal,
697 image::ImageData* weight, float uvScale, float constantWeight,
698 float heightContrast) {
699 return addMaterialVtLayer(self, albedo, normal, weight, uvScale, constantWeight,
700 heightContrast);
701 });
702 material.addFunc("clearVirtualTexture", &Material::clearVirtualTexture);
703 material.addFunc("usesVirtualTexture", [](Material* self) {
704 return self->virtualTextureMode() == MaterialVirtualTextureMode::AtlasPageTable;
705 });
706 material.addFunc("setShader", &Material::setShader);
707 material.addFunc("getShader", &Material::getShader);
708 // Script adapter for the canonical validated PbrSurface API. Only the descriptor
709 // is copied; referenced textures remain borrowed from their Graphics owner.
710 material.addFunc("copyPbrSurfaceFrom", [vm = table.getHandle()](Material* self, Material* source) {
711 return eve::script::projectResult(vm, self->setPbrSurface(source->pbrSurface()));
712 });
713 material.addFunc("setTint", &Material::setTint);
714 material.addFunc("setMetallic", &Material::setMetallic);
715 material.addFunc("getMetallic", &Material::getMetallic);
716 material.addFunc("setRoughness", &Material::setRoughness);
717 material.addFunc("getRoughness", &Material::getRoughness);
718 material.addFunc("setTexCellBomb", &Material::setTexCellBomb);
719 material.addFunc("setParallax", &Material::setParallax);
720 material.addFunc("setReceiveLight", &Material::setReceiveLight);
721 material.addFunc("getReceiveLight", &Material::getReceiveLight);
722 material.addFunc("setCastShadow", &Material::setCastShadow);
723 material.addFunc("getCastShadow", &Material::getCastShadow);
724 material.addFunc("setReceiveShadow", &Material::setReceiveShadow);
725 material.addFunc("getReceiveShadow", &Material::getReceiveShadow);
726 material.addFunc("setCastOcclusion", &Material::setCastOcclusion);
727 material.addFunc("getCastOcclusion", &Material::getCastOcclusion);
728 material.addFunc("setHair", &Material::setHair);
729 material.addFunc("getHair", &Material::getHair);
730 material.addFunc("setSurfaceMode", &Material::setSurfaceMode);
731 material.addFunc("getSurfaceMode", &Material::getSurfaceMode);
732 material.addFunc("setAlphaCutoff", &Material::setAlphaCutoff);
733 material.addFunc("getAlphaCutoff", &Material::getAlphaCutoff);
734 material.addFunc("setBlendMode", &Material::setBlendMode);
735 material.addFunc("getBlendMode", &Material::getBlendMode);
736 material.addFunc("setDepthWrite", &Material::setDepthWrite);
737 material.addFunc("getDepthWrite", &Material::getDepthWrite);
738 material.addFunc("setDoubleSided", &Material::setDoubleSided);
739 material.addFunc("getDoubleSided", &Material::getDoubleSided);
740 material.addFunc("setCameraFacing", &Material::setCameraFacing);
741 material.addFunc("getCameraFacing", &Material::getCameraFacing);
742 material.addFunc("setSortPriority", &Material::setSortPriority);
743 material.addFunc("getSortPriority", &Material::getSortPriority);
744 material.addFunc("setAlphaTechnique", &Material::setAlphaTechnique);
745 material.addFunc("getAlphaTechnique", &Material::getAlphaTechnique);
746 material.addFunc("hasParam", &Material::hasParam);
747 material.addFunc("setFloat", &Material::setFloat);
748 material.addFunc("getFloat", &Material::getFloat);
749
750 auto gbuffer =
751 table.addClass<GBuffer>("GBuffer", std::function<GBuffer*()>([]() -> GBuffer* { return nullptr; }), true);
752 gbuffer.addFunc("isValid", &GBuffer::isValid);
753 gbuffer.addFunc("getWidth", &GBuffer::getWidth);
754 gbuffer.addFunc("getHeight", &GBuffer::getHeight);
755 gbuffer.addFunc("getDepthTexture", &GBuffer::getDepthTexture);
756 gbuffer.addFunc("getHwDepthTexture", &GBuffer::getHwDepthTexture);
757 gbuffer.addFunc("getNormalTexture", &GBuffer::getNormalTexture);
758 gbuffer.addFunc("getAlbedoTexture", &GBuffer::getAlbedoTexture);
759 gbuffer.addFunc("hasBuffer", &GBuffer::hasBuffer);
760 gbuffer.addFunc("getBuffer", &GBuffer::getBuffer);
761
762 auto rctrl = table.addClass<RenderControl>(
763 "RenderControl", std::function<RenderControl*()>([]() -> RenderControl* { return nullptr; }), true);
764 rctrl.addFunc("supports", &RenderControl::supports);
765 rctrl.addFunc(
766 "requestFeature", [vm = table.getHandle()](RenderControl* rc, const std::string& feature, bool enabled) {
767 auto result =
768 rc ? rc->requestFeature(feature, enabled)
769 : Result<void>::failure(Diagnostic::error(
770 DiagnosticCode::InvalidArgument, "RenderControl.requestFeature: non-null control required"));
771 return eve::script::projectResult(vm, std::move(result));
772 });
773 rctrl.addFunc("enable", &RenderControl::enable);
774 rctrl.addFunc("disable", &RenderControl::disable);
775 rctrl.addFunc("isEnabled", &RenderControl::isEnabled);
776 rctrl.addFunc("pathTracingDiagnostic", &RenderControl::pathTracingDiagnostic);
777 rctrl.addFunc("pathTracingFrameState", [](RenderControl* rc) -> std::string {
778 switch (rc->pathTracingFrameState()) {
779 case PathTracingFrameState::Active: return "active";
780 case PathTracingFrameState::Unavailable: return "unavailable";
781 case PathTracingFrameState::SceneRejected: return "sceneRejected";
782 default: return "disabled";
783 }
784 });
785 rctrl.addFunc("setLightingMode", [](RenderControl* rc, const std::string& name) -> bool {
786 if (!rc) return false;
787 return rc->setLightingMode(name).ok();
788 });
789 rctrl.addFunc("getLightingMode", [](RenderControl* rc) -> std::string {
790 return rc && rc->getLightingMode() == LightingMode::Hybrid ? "hybrid" : "forwardPlus";
791 });
792 rctrl.addFunc("getEffectiveLightingMode", [](RenderControl* rc) -> std::string {
793 return rc && rc->getEffectiveLightingMode() == LightingMode::Hybrid ? "hybrid" : "forwardPlus";
794 });
795 rctrl.addFunc("isDeferredLightingAvailable", &RenderControl::isDeferredLightingAvailable);
796 rctrl.addFunc("hasHybridLightingFallback", &RenderControl::hasHybridLightingFallback);
797 rctrl.addFunc("applyLightingPreset", [](RenderControl* rc, const std::string& name) -> bool {
798 if (!rc) return false;
799 return rc->applyLightingPreset(name).ok();
800 });
801 rctrl.addFunc("applySuggestedLightingPreset", [](RenderControl* rc) -> bool {
802 if (!rc) return false;
803 return rc->applySuggestedLightingPreset().ok();
804 });
805 rctrl.addFunc("getLightingPreset", [](RenderControl* rc) -> std::string {
806 if (!rc) return "desktop";
807 switch (rc->getLightingPreset()) {
808 case LightingPreset::Mobile: return "mobile";
809 case LightingPreset::Ci: return "ci";
811 default: return "desktop";
812 }
813 });
814 rctrl.addFunc("setReflectionQuality", &RenderControl::setReflectionQuality);
815 rctrl.addFunc("getReflectionQuality", &RenderControl::getReflectionQuality);
816 rctrl.addFunc("setPostProcessQuality", &RenderControl::setPostProcessQuality);
817 rctrl.addFunc("getPostProcessQuality", &RenderControl::getPostProcessQuality);
818 rctrl.addFunc("compile", &RenderControl::compile);
819 rctrl.addFunc("isCompiled", &RenderControl::isCompiled);
820 rctrl.addFunc("getPassCount", &RenderControl::getPassCount);
821 rctrl.addFunc("getPassName", &RenderControl::getPassName);
822 rctrl.addFunc("hasPass", &RenderControl::hasPass);
823 rctrl.addFunc("getGBuffer", static_cast<GBuffer* (RenderControl::*)()>(&RenderControl::getGBuffer));
824
825 auto vol = table.addClass<Volumetric>("Volumetric",
826 std::function<Volumetric*()>([]() -> Volumetric* { return nullptr; }), true);
827 vol.addFunc("setQuality", &Volumetric::setQuality);
828 vol.addFunc("getQuality", &Volumetric::getQuality);
829 vol.addFunc("setMode", &Volumetric::setMode);
830 vol.addFunc("getMode", &Volumetric::getMode);
831 vol.addFunc("setLightScreenUV", &Volumetric::setLightScreenUV);
832 vol.addFunc("getLightScreenU", &Volumetric::getLightScreenU);
833 vol.addFunc("getLightScreenV", &Volumetric::getLightScreenV);
834 vol.addFunc("setLightScreenPos", &Volumetric::setLightScreenPos);
835 vol.addFunc("setLightDirection", &Volumetric::setLightDirection);
836 vol.addFunc("setCamera", &Volumetric::setCamera);
837 vol.addFunc("setShaftColor", &Volumetric::setShaftColor);
838 vol.addFunc("setFogColor", &Volumetric::setFogColor);
839 vol.addFunc("setIntensity", &Volumetric::setIntensity);
840 vol.addFunc("setTime", &Volumetric::setTime);
841 vol.addFunc("setDensity", &Volumetric::setDensity);
842 vol.addFunc("setAnisotropy", &Volumetric::setAnisotropy);
843 vol.addFunc("getAnisotropy", &Volumetric::getAnisotropy);
844 vol.addFunc("hasParam", &Volumetric::hasParam);
845 vol.addFunc("setFloat", &Volumetric::setFloat);
846 vol.addFunc("getFloat", &Volumetric::getFloat);
847 vol.addFunc("getSampleCount", &Volumetric::getSampleCount);
848 vol.addFunc("getDownscale", &Volumetric::getDownscale);
849 vol.addFunc("resolutionFor", &Volumetric::resolutionFor);
850 vol.addFunc("beginOcclusionMap", &Volumetric::beginOcclusionMap);
851 vol.addFunc("drawOccluder", &Volumetric::drawOccluder);
852 vol.addFunc("drawOccluderSolid", &Volumetric::drawOccluderSolid);
853 vol.addFunc("drawOccluderTexture", &Volumetric::drawOccluderTexture);
854 vol.addFunc("drawOccluders2D", &Volumetric::drawOccluders2D);
855 vol.addFunc("scatter", &Volumetric::scatter);
856 vol.addFunc("scatterTo", &Volumetric::scatterTo);
857 vol.addFunc("applyFromScene", &Volumetric::applyFromScene);
858 vol.addFunc("applyFromSceneTo", &Volumetric::applyFromSceneTo);
859 vol.addFunc("rayMarch", &Volumetric::rayMarch);
860 vol.addFunc("rayMarchTo", &Volumetric::rayMarchTo);
861 vol.addFunc("setFogHeight", &Volumetric::setFogHeight);
862 vol.addFunc("setFogHeightFalloff", &Volumetric::setFogHeightFalloff);
863 vol.addFunc("setFogStart", &Volumetric::setFogStart);
864 vol.addFunc("setFogEnd", &Volumetric::setFogEnd);
865 vol.addFunc("setFogNoise", &Volumetric::setFogNoise);
866 vol.addFunc("setCloudLayer", &Volumetric::setCloudLayer);
867 vol.addFunc("setCloudCoverage", &Volumetric::setCloudCoverage);
868 vol.addFunc("setCloudDensity", &Volumetric::setCloudDensity);
869 vol.addFunc("setCloudScale", &Volumetric::setCloudScale);
870 vol.addFunc("setCloudWind", &Volumetric::setCloudWind);
871 vol.addFunc("setCloudLightColor", &Volumetric::setCloudLightColor);
872 vol.addFunc("applyFog", &Volumetric::applyFog);
873 vol.addFunc("applyFogTo", &Volumetric::applyFogTo);
874 vol.addFunc("projectDirectionalCookie",
875 [vm = table.getHandle()](Volumetric* value, Graphics* graphics, Texture* depth, Texture* cookie,
876 float worldSize, float intensity) {
877 auto result = value ? value->projectDirectionalCookie(graphics, depth, cookie, worldSize, intensity)
878 : Result<void>::failure(Diagnostic::error(
879 DiagnosticCode::InvalidArgument,
880 "Volumetric.projectDirectionalCookie: non-null provider required"));
881 return eve::script::projectResult(vm, std::move(result));
882 });
883 vol.addFunc("renderClouds", &Volumetric::renderClouds);
884 vol.addFunc("renderCloudsTo", &Volumetric::renderCloudsTo);
885 vol.addFunc("configureFroxelGrid", &Volumetric::configureFroxelGrid);
886 vol.addFunc("clearFroxelGrid", &Volumetric::clearFroxelGrid);
887 vol.addFunc("injectFroxelHeightFog", &Volumetric::injectFroxelHeightFog);
888 vol.addFunc("injectFroxelLocalVolume", &Volumetric::injectFroxelLocalVolume);
889 vol.addFunc("integrateFroxel", &Volumetric::integrateFroxel);
890 vol.addFunc("driveFromLight3D",
891 [vm = table.getHandle()](Volumetric *value, Light3D *light, float viewportW,
892 float viewportH) {
893 auto result = value ? value->driveFromLight3D(light, viewportW, viewportH)
894 : Result<void>::failure(Diagnostic::error(
895 DiagnosticCode::InvalidArgument,
896 "Volumetric.driveFromLight3D: non-null provider required"));
897 return eve::script::projectResult(vm, std::move(result));
898 });
899 vol.addFunc("driveFromPrimarySceneLight3D",
900 [vm = table.getHandle()](Volumetric *value, float viewportW, float viewportH) {
901 auto result = value ? value->driveFromPrimarySceneLight3D(viewportW, viewportH)
902 : Result<void>::failure(Diagnostic::error(
903 DiagnosticCode::InvalidArgument,
904 "Volumetric.driveFromPrimarySceneLight3D: non-null provider required"));
905 return eve::script::projectResult(vm, std::move(result));
906 });
907 vol.addFunc("integrateFroxelFromSceneLights",
908 [vm = table.getHandle()](Volumetric *value, float ambientR, float ambientG,
909 float ambientB, float minX, float minY, float minZ,
910 float maxX, float maxY, float maxZ, int maxLights) {
911 auto result =
912 value ? value->integrateFroxelFromSceneLights(
913 ambientR, ambientG, ambientB, glm::vec3(minX, minY, minZ),
914 glm::vec3(maxX, maxY, maxZ), maxLights)
915 : Result<void>::failure(Diagnostic::error(
916 DiagnosticCode::InvalidArgument,
917 "Volumetric.integrateFroxelFromSceneLights: non-null provider required"));
918 return eve::script::projectResult(vm, std::move(result));
919 });
920 vol.addFunc("beginOcclusionMapFromSceneLights2D",
921 [vm = table.getHandle()](Volumetric *value, Graphics *graphics, Canvas *canvas,
922 float defaultRadiusPixels) {
923 auto result =
924 value ? value->beginOcclusionMapFromSceneLights2D(graphics, canvas,
925 defaultRadiusPixels)
926 : Result<int>::failure(Diagnostic::error(
927 DiagnosticCode::InvalidArgument,
928 "Volumetric.beginOcclusionMapFromSceneLights2D: non-null provider required"));
929 return eve::script::projectResult(vm, std::move(result),
930 [](int count) { return count; });
931 });
932 vol.addFunc("scatterFromSceneLights2D",
933 [vm = table.getHandle()](Volumetric *value, Graphics *graphics, Texture *occlusion,
934 Canvas *canvas) {
935 auto result = value ? value->scatterFromSceneLights2D(graphics, occlusion, canvas)
938 "Volumetric.scatterFromSceneLights2D: non-null provider required"));
939 return eve::script::projectResult(vm, std::move(result),
940 [](int count) { return count; });
941 });
942 vol.addFunc("injectEmissiveLightProxy",
943 [vm = table.getHandle()](Volumetric *value, float x, float y, float z, float r,
944 float g, float b, float radius, float intensity) {
945 auto result =
946 value ? value->injectEmissiveLightProxy(x, y, z, r, g, b, radius, intensity)
949 "Volumetric.injectEmissiveLightProxy: non-null provider required"));
950 return eve::script::projectResult(vm, std::move(result));
951 });
952 vol.addFunc("uploadFroxel", &Volumetric::uploadFroxel);
953 vol.addFunc("applyFroxel", &Volumetric::applyFroxel);
954 vol.addFunc("applyFroxelTo", &Volumetric::applyFroxelTo);
955 vol.addFunc("getShader", &Volumetric::getShader);
956 vol.addFunc("getRayMarchShader", &Volumetric::getRayMarchShader);
957 vol.addFunc("getFogShader", &Volumetric::getFogShader);
958 vol.addFunc("getCloudShader", &Volumetric::getCloudShader);
959
960 auto fogVolume = table.addClass<FogVolume>("FogVolume");
961 fogVolume.addFunc("setShape", &FogVolume::setShape);
962 fogVolume.addFunc("getShape", &FogVolume::getShapeName);
963 fogVolume.addFunc("setPosition", &FogVolume::setPosition);
964 fogVolume.addFunc("setSize", &FogVolume::setSize);
965 fogVolume.addFunc("setExtinction", &FogVolume::setExtinction);
966 fogVolume.addFunc("getExtinction", &FogVolume::getExtinction);
967 fogVolume.addFunc("setAlbedo", &FogVolume::setAlbedo);
968 fogVolume.addFunc("setEmissive", &FogVolume::setEmissive);
969 fogVolume.addFunc("setAnisotropy", &FogVolume::setAnisotropy);
970 fogVolume.addFunc("getAnisotropy", &FogVolume::getAnisotropy);
971 fogVolume.addFunc("setEdgeFalloff", &FogVolume::setEdgeFalloff);
972 fogVolume.addFunc("getEdgeFalloff", &FogVolume::getEdgeFalloff);
973 fogVolume.addFunc("setNoise", &FogVolume::setNoise);
974 fogVolume.addFunc("getNoiseAmount", &FogVolume::getNoiseAmount);
975 fogVolume.addFunc("getNoiseScale", &FogVolume::getNoiseScale);
976 fogVolume.addFunc("getNoiseSeed", &FogVolume::getNoiseSeed);
977
978 auto foliage = table.addClass<grass::GrassFoliageSettings>("GrassFoliageSettings");
979 foliage.addVar("baseR", &grass::GrassFoliageSettings::baseR);
980 foliage.addVar("baseG", &grass::GrassFoliageSettings::baseG);
981 foliage.addVar("baseB", &grass::GrassFoliageSettings::baseB);
982 foliage.addVar("alphaCutoff", &grass::GrassFoliageSettings::alphaCutoff);
983 foliage.addVar("normalStrength", &grass::GrassFoliageSettings::normalStrength);
984 foliage.addVar("renderDistance", &grass::GrassFoliageSettings::renderDistance);
985 foliage.addVar("fadeRange", &grass::GrassFoliageSettings::fadeRange);
986 foliage.addVar("hardRenderDistance", &grass::GrassFoliageSettings::hardRenderDistance);
987 foliage.addVar("density", &grass::GrassFoliageSettings::density);
988 foliage.addVar("snowMinimumHeight", &grass::GrassFoliageSettings::snowMinimumHeight);
989 foliage.addVar("snowFadeDistance", &grass::GrassFoliageSettings::snowFadeDistance);
990 foliage.addVar("snowProgress", &grass::GrassFoliageSettings::snowProgress);
991 foliage.addVar("snowR", &grass::GrassFoliageSettings::snowR);
992 foliage.addVar("snowG", &grass::GrassFoliageSettings::snowG);
993 foliage.addVar("snowB", &grass::GrassFoliageSettings::snowB);
994 auto detailOverwrite = table.addClass<grass::TerrainDetailOverwriteSettings>("TerrainDetailOverwriteSettings");
995 detailOverwrite.addVar("pcgDetailDistance", &grass::TerrainDetailOverwriteSettings::pcgDetailDistance);
996 detailOverwrite.addVar("pcgFadeoutDistance", &grass::TerrainDetailOverwriteSettings::pcgFadeoutDistance);
997 detailOverwrite.addVar("unityDetailDistance", &grass::TerrainDetailOverwriteSettings::unityDetailDistance);
998 detailOverwrite.addVar("unityDetailDensity", &grass::TerrainDetailOverwriteSettings::unityDetailDensity);
999 detailOverwrite.addVar("detailResolutionPerPatch",
1001
1002 auto grassField = table.addClass<GrassField>(
1003 "GrassField", std::function<GrassField*()>([]() -> GrassField* { return nullptr; }), true);
1004 grassField.addFunc("bakePlane", static_cast<void (GrassField::*)(float, float, int, int)>(&GrassField::bakePlane));
1005 grassField.addFunc("update", &GrassField::update);
1006 grassField.addFunc("setTime", &GrassField::setTime);
1007 grassField.addFunc("getTime", &GrassField::getTime);
1008 grassField.addFunc("setFrameDuration", &GrassField::setFrameDuration);
1009 grassField.addFunc("getFrameDuration", &GrassField::getFrameDuration);
1010 grassField.addFunc("draw", static_cast<void (GrassField::*)()>(&GrassField::draw));
1011 grassField.addFunc("setReflectionCaptureEnabled", &GrassField::setReflectionCaptureEnabled);
1012 grassField.addFunc("getReflectionCaptureEnabled", &GrassField::getReflectionCaptureEnabled);
1013 grassField.addFunc("setReflectionCaptureMask", &GrassField::setReflectionCaptureMask);
1014 grassField.addFunc("getReflectionCaptureMask", &GrassField::getReflectionCaptureMask);
1015 grassField.addFunc("getDenseMesh", &GrassField::getDenseMesh);
1016 grassField.addFunc("getSparseMesh", &GrassField::getSparseMesh);
1017 grassField.addFunc("getShader", &GrassField::getShader);
1018 grassField.addFunc("getAtlas", &GrassField::getAtlas);
1019 grassField.addFunc("getDenseCount", &GrassField::getDenseCount);
1020 grassField.addFunc("getSparseCount", &GrassField::getSparseCount);
1021 grassField.addFunc(
1022 "setTerrainDetailOverwrite",
1023 [vm = table.getHandle()](GrassField* field, const grass::TerrainDetailOverwriteSettings& settings) {
1024 return eve::script::projectResult(vm, field->setTerrainDetailOverwrite(settings),
1025 [](int value) { return value; });
1026 });
1027 grassField.addFunc("getTerrainDetailHardDistance",
1028 [](const GrassField* field) { return field->getTerrainDetailHardDistance(); });
1029 grassField.addFunc("getTerrainDetailDensity",
1030 [](const GrassField* field) { return field->getTerrainDetailDensity(); });
1031 grassField.addFunc("setPhotoModeAuthority", &GrassField::setPhotoModeAuthority);
1032 grassField.addFunc("getPhotoModeDensity", [](const GrassField* field) { return field->getPhotoModeDensity(); });
1033 grassField.addFunc("getPhotoModeDistance", [](const GrassField* field) { return field->getPhotoModeDistance(); });
1034 grassField.addFunc("getPhotoModeCellDistance",
1035 [](const GrassField* field) { return field->getPhotoModeCellDistance(); });
1036 grassField.addFunc("getPhotoModeCellSubdivision",
1037 [](const GrassField* field) { return field->getPhotoModeCellSubdivision(); });
1038
1039 auto groomInstance = table.addClass<hair::GroomInstance>(
1040 "GroomInstance", std::function<hair::GroomInstance*()>([]() -> hair::GroomInstance* { return nullptr; }), true);
1041 // Fallible bake/rebuild stay C++-only (Result); scripts use factory + draw getters.
1042 groomInstance.addFunc("draw", static_cast<void (hair::GroomInstance::*)()>(&hair::GroomInstance::draw));
1043 groomInstance.addFunc("setForcedLod", &hair::GroomInstance::setForcedLod);
1044 groomInstance.addFunc("getForcedLod", &hair::GroomInstance::getForcedLod);
1045 groomInstance.addFunc("setScreenSize", &hair::GroomInstance::setScreenSize);
1046 groomInstance.addFunc("getScreenSize", &hair::GroomInstance::getScreenSize);
1047 groomInstance.addFunc("setWidthScale", &hair::GroomInstance::setWidthScale);
1048 groomInstance.addFunc("getWidthScale", &hair::GroomInstance::getWidthScale);
1049 groomInstance.addFunc("setSideHint", &hair::GroomInstance::setSideHint);
1050 groomInstance.addFunc("getMesh", &hair::GroomInstance::getMesh);
1051 groomInstance.addFunc("getShader", &hair::GroomInstance::getShader);
1052 groomInstance.addFunc("getTexture", &hair::GroomInstance::getTexture);
1053 groomInstance.addFunc("getCurveCount", &hair::GroomInstance::getCurveCount);
1054 groomInstance.addFunc("getPointCount", &hair::GroomInstance::getPointCount);
1055 groomInstance.addFunc("getGroupCount", &hair::GroomInstance::getGroupCount);
1056 groomInstance.addFunc("setClusterCullingEnabled", &hair::GroomInstance::setClusterCullingEnabled);
1057 groomInstance.addFunc("isClusterCullingEnabled", &hair::GroomInstance::isClusterCullingEnabled);
1058 groomInstance.addFunc("getActiveLodIndex", &hair::GroomInstance::getActiveLodIndex);
1059 groomInstance.addFunc("getActiveRepresentation", &hair::GroomInstance::getActiveRepresentation);
1060 groomInstance.addFunc("getClusterCount", &hair::GroomInstance::getClusterCount);
1061 groomInstance.addFunc("getVisibleCurveCount", &hair::GroomInstance::getVisibleCurveCount);
1062 groomInstance.addFunc("setMarschnerLobes", &hair::GroomInstance::setMarschnerLobes);
1063 groomInstance.addFunc("getMarschnerR", &hair::GroomInstance::getMarschnerR);
1064 groomInstance.addFunc("getMarschnerTT", &hair::GroomInstance::getMarschnerTT);
1065 groomInstance.addFunc("getMarschnerTRT", &hair::GroomInstance::getMarschnerTRT);
1066 groomInstance.addFunc("setSelfShadow", &hair::GroomInstance::setSelfShadow);
1067 groomInstance.addFunc("getSelfShadowStrength", &hair::GroomInstance::getSelfShadowStrength);
1068 groomInstance.addFunc("getSelfShadowBias", &hair::GroomInstance::getSelfShadowBias);
1069 groomInstance.addFunc("getRootAoStrength", &hair::GroomInstance::getRootAoStrength);
1070 groomInstance.addFunc("isGuideSimulationEnabled", &hair::GroomInstance::isGuideSimulationEnabled);
1071
1072 auto waterfall = table.addClass<Waterfall>(
1073 "Waterfall", std::function<Waterfall*()>([]() -> Waterfall* { return nullptr; }), true);
1074 waterfall.addFunc("createSheet", &Waterfall::createSheet);
1075 waterfall.addFunc("createCurvedSheet", &Waterfall::createCurvedSheet);
1076 waterfall.addFunc("update", &Waterfall::update);
1077 waterfall.addFunc("setTime", &Waterfall::setTime);
1078 waterfall.addFunc("getTime", &Waterfall::getTime);
1079 waterfall.addFunc("setFlowSpeed", &Waterfall::setFlowSpeed);
1080 waterfall.addFunc("getFlowSpeed", &Waterfall::getFlowSpeed);
1081 waterfall.addFunc("setTurbulence", &Waterfall::setTurbulence);
1082 waterfall.addFunc("getTurbulence", &Waterfall::getTurbulence);
1083 waterfall.addFunc("setStreakCount", &Waterfall::setStreakCount);
1084 waterfall.addFunc("getStreakCount", &Waterfall::getStreakCount);
1085 waterfall.addFunc("setStreakScale", &Waterfall::setStreakScale);
1086 waterfall.addFunc("getStreakScale", &Waterfall::getStreakScale);
1087 waterfall.addFunc("setTopFoam", &Waterfall::setTopFoam);
1088 waterfall.addFunc("getTopFoam", &Waterfall::getTopFoam);
1089 waterfall.addFunc("setBottomFoam", &Waterfall::setBottomFoam);
1090 waterfall.addFunc("getBottomFoam", &Waterfall::getBottomFoam);
1091 waterfall.addFunc("setFoamAmount", &Waterfall::setFoamAmount);
1092 waterfall.addFunc("getFoamAmount", &Waterfall::getFoamAmount);
1093 waterfall.addFunc("setWaterColor", &Waterfall::setWaterColor);
1094 waterfall.addFunc("setReflectionIntensity", &Waterfall::setReflectionIntensity);
1095 waterfall.addFunc("getReflectionIntensity", &Waterfall::getReflectionIntensity);
1096 waterfall.addFunc("setSunIntensity", &Waterfall::setSunIntensity);
1097 waterfall.addFunc("getSunIntensity", &Waterfall::getSunIntensity);
1098 waterfall.addFunc("bindParams", &Waterfall::bindParams);
1099 waterfall.addFunc("draw", &Waterfall::draw);
1100 waterfall.addFunc("setReflectionCaptureEnabled", &Waterfall::setReflectionCaptureEnabled);
1101 waterfall.addFunc("getReflectionCaptureEnabled", &Waterfall::getReflectionCaptureEnabled);
1102 waterfall.addFunc("setReflectionCaptureMask", &Waterfall::setReflectionCaptureMask);
1103 waterfall.addFunc("getReflectionCaptureMask", &Waterfall::getReflectionCaptureMask);
1104 waterfall.addFunc("getShader", &Waterfall::getShader);
1105 waterfall.addFunc("getMesh", &Waterfall::getMesh);
1106 auto probeCapture = table.addClass<ReflectionProbeCapture>(
1107 "ReflectionProbeCapture",
1108 std::function<ReflectionProbeCapture*()>([]() -> ReflectionProbeCapture* { return nullptr; }), true);
1109 probeCapture.addFunc("configure", &ReflectionProbeCapture::configure);
1110 probeCapture.addFunc("requestCapture", &ReflectionProbeCapture::requestCapture);
1111 probeCapture.addFunc("queueCapture", &ReflectionProbeCapture::queueCapture);
1112 probeCapture.addFunc("update", &ReflectionProbeCapture::update);
1113 probeCapture.addFunc("getFaceCanvas", &ReflectionProbeCapture::getFaceCanvas);
1114 probeCapture.addFunc("isCapturePending", &ReflectionProbeCapture::isCapturePending);
1115 probeCapture.addFunc("isRecaptureQueued", &ReflectionProbeCapture::isRecaptureQueued);
1116 probeCapture.addFunc("isCaptureComplete", &ReflectionProbeCapture::isCaptureComplete);
1117 probeCapture.addFunc("getRevision", &ReflectionProbeCapture::getRevision);
1118 probeCapture.addFunc("stageCapturedFaces", &ReflectionProbeCapture::stageCapturedFaces);
1119 probeCapture.addFunc("getStagingCubemap", &ReflectionProbeCapture::getStagingCubemap);
1120 probeCapture.addFunc("getStagedRevision", &ReflectionProbeCapture::getStagedRevision);
1121 probeCapture.addFunc("filterAndPublish", &ReflectionProbeCapture::filterAndPublish);
1122 probeCapture.addFunc("getActiveCubemap", &ReflectionProbeCapture::getActiveCubemap);
1123 probeCapture.addFunc("getPublishedRevision", &ReflectionProbeCapture::getPublishedRevision);
1124 probeCapture.addFunc("setUpdateMode", &ReflectionProbeCapture::setUpdateMode);
1125 probeCapture.addFunc("getUpdateMode", &ReflectionProbeCapture::getUpdateMode);
1126 probeCapture.addFunc("setRefreshInterval", &ReflectionProbeCapture::setRefreshInterval);
1127 probeCapture.addFunc("getRefreshInterval", &ReflectionProbeCapture::getRefreshInterval);
1128 probeCapture.addFunc("setCaptureMask", &ReflectionProbeCapture::setCaptureMask);
1129 probeCapture.addFunc("getCaptureMask", &ReflectionProbeCapture::getCaptureMask);
1130 probeCapture.addFunc("setEnvironmentLighting", &ReflectionProbeCapture::setEnvironmentLighting);
1131 probeCapture.addFunc("getEnvironmentLighting", &ReflectionProbeCapture::getEnvironmentLighting);
1132 probeCapture.addFunc("getEnvironmentLightingIntensity", &ReflectionProbeCapture::getEnvironmentLightingIntensity);
1133 probeCapture.addFunc("setSkyColor", &ReflectionProbeCapture::setSkyColor);
1134 probeCapture.addFunc("setSkyFaceColor", &ReflectionProbeCapture::setSkyFaceColor);
1135 probeCapture.addFunc("setSkyFaceTexture", &ReflectionProbeCapture::setSkyFaceTexture);
1136 probeCapture.addFunc("getSkyFaceTexture", &ReflectionProbeCapture::getSkyFaceTexture);
1137 probeCapture.addFunc("setSkyFaceTextureScale", &ReflectionProbeCapture::setSkyFaceTextureScale);
1138 probeCapture.addFunc("getSkyFaceTextureScale", &ReflectionProbeCapture::getSkyFaceTextureScale);
1139 probeCapture.addFunc("getSkyFaceColor", &ReflectionProbeCapture::getSkyFaceColor);
1140 probeCapture.addFunc("getSkyR", &ReflectionProbeCapture::getSkyR);
1141 probeCapture.addFunc("getSkyG", &ReflectionProbeCapture::getSkyG);
1142 probeCapture.addFunc("getSkyB", &ReflectionProbeCapture::getSkyB);
1143 probeCapture.addFunc("getSkyIntensity", &ReflectionProbeCapture::getSkyIntensity);
1144 probeCapture.addFunc("getPendingFaceCount", &ReflectionProbeCapture::getPendingFaceCount);
1145 probeCapture.addFunc("getLastCapturedFaceCount", &ReflectionProbeCapture::getLastCapturedFaceCount);
1146 probeCapture.addFunc("getTotalCapturedFaceCount", &ReflectionProbeCapture::getTotalCapturedFaceCount);
1147 probeCapture.addFunc("getLastFilterSampleCount", &ReflectionProbeCapture::getLastFilterSampleCount);
1148 probeCapture.addFunc("setGpuBudgetMs", &ReflectionProbeCapture::setGpuBudgetMs);
1149 probeCapture.addFunc("getGpuBudgetMs", &ReflectionProbeCapture::getGpuBudgetMs);
1150 probeCapture.addFunc("reportGpuDurationMs", &ReflectionProbeCapture::reportGpuDurationMs);
1151 probeCapture.addFunc("getSmoothedGpuDurationMs", &ReflectionProbeCapture::getSmoothedGpuDurationMs);
1152 probeCapture.addFunc("getAdaptiveFaceBudget", &ReflectionProbeCapture::getAdaptiveFaceBudget);
1153 probeCapture.addFunc("getAdaptiveFilterSamples", &ReflectionProbeCapture::getAdaptiveFilterSamples);
1154 probeCapture.addFunc("tickAdaptive", &ReflectionProbeCapture::tickAdaptive);
1155 probeCapture.addFunc("tick", &ReflectionProbeCapture::tick);
1156 probeCapture.addFunc("configureInfluence", &ReflectionProbeCapture::configureInfluence);
1157 probeCapture.addFunc("getInfluenceExtentX", &ReflectionProbeCapture::getInfluenceExtentX);
1158 probeCapture.addFunc("getInfluenceExtentY", &ReflectionProbeCapture::getInfluenceExtentY);
1159 probeCapture.addFunc("getInfluenceExtentZ", &ReflectionProbeCapture::getInfluenceExtentZ);
1160 probeCapture.addFunc("getInfluenceIntensity", &ReflectionProbeCapture::getInfluenceIntensity);
1161 probeCapture.addFunc("getInfluenceBlendDistance", &ReflectionProbeCapture::getInfluenceBlendDistance);
1162 probeCapture.addFunc("getInfluencePriority", &ReflectionProbeCapture::getInfluencePriority);
1163 probeCapture.addFunc("applyConfiguredToCamera", &ReflectionProbeCapture::applyConfiguredToCamera);
1164 probeCapture.addFunc("applyToCamera", &ReflectionProbeCapture::applyToCamera);
1165 probeCapture.addFunc("getResolution", &ReflectionProbeCapture::getResolution);
1166 probeCapture.addFunc("getCenterX", &ReflectionProbeCapture::getCenterX);
1167 probeCapture.addFunc("getCenterY", &ReflectionProbeCapture::getCenterY);
1168 probeCapture.addFunc("getCenterZ", &ReflectionProbeCapture::getCenterZ);
1169 probeCapture.addFunc("getCaptureFarDistance", &ReflectionProbeCapture::getCaptureFarDistance);
1170 probeCapture.addFunc("setCaptureLodDistanceScale", &ReflectionProbeCapture::setCaptureLodDistanceScale);
1171 probeCapture.addFunc("getCaptureLodDistanceScale", &ReflectionProbeCapture::getCaptureLodDistanceScale);
1172 probeCapture.addFunc("setCaptureTransparent", &ReflectionProbeCapture::setCaptureTransparent);
1173 probeCapture.addFunc("getCaptureTransparent", &ReflectionProbeCapture::getCaptureTransparent);
1174 probeCapture.addFunc("setCaptureClusteredLighting", &ReflectionProbeCapture::setCaptureClusteredLighting);
1175 probeCapture.addFunc("getCaptureClusteredLighting", &ReflectionProbeCapture::getCaptureClusteredLighting);
1176 auto probeRegistry = table.addClass<ReflectionProbeRegistry>(
1177 "ReflectionProbeRegistry",
1178 std::function<ReflectionProbeRegistry*()>([]() -> ReflectionProbeRegistry* { return nullptr; }), true);
1179 probeRegistry.addFunc("add", &ReflectionProbeRegistry::add);
1180 probeRegistry.addFunc("remove", &ReflectionProbeRegistry::remove);
1181 probeRegistry.addFunc("clear", &ReflectionProbeRegistry::clear);
1182 probeRegistry.addFunc("getCount", &ReflectionProbeRegistry::getCount);
1183 probeRegistry.addFunc("getLastSelectedCount", &ReflectionProbeRegistry::getLastSelectedCount);
1184 probeRegistry.addFunc("getLastCapturedFaceCount", &ReflectionProbeRegistry::getLastCapturedFaceCount);
1185 probeRegistry.addFunc("getLastPublishedCount", &ReflectionProbeRegistry::getLastPublishedCount);
1186 probeRegistry.addFunc("setSelectionHysteresis", &ReflectionProbeRegistry::setSelectionHysteresis);
1187 probeRegistry.addFunc("getSelectionHysteresis", &ReflectionProbeRegistry::getSelectionHysteresis);
1188 probeRegistry.addFunc("getLastCandidateCount", &ReflectionProbeRegistry::getLastCandidateCount);
1189 probeRegistry.addFunc("setDistanceCullingEnabled", &ReflectionProbeRegistry::setDistanceCullingEnabled);
1190 probeRegistry.addFunc("getDistanceCullingEnabled", &ReflectionProbeRegistry::getDistanceCullingEnabled);
1191 probeRegistry.addFunc("setMaxRenderDistance",
1192 [vm = table.getHandle()](ReflectionProbeRegistry* self, float distance) {
1193 return eve::script::projectResult(vm, self->setMaxRenderDistance(distance));
1194 });
1195 probeRegistry.addFunc("getMaxRenderDistance", &ReflectionProbeRegistry::getMaxRenderDistance);
1196 probeRegistry.addFunc("getLastDistanceCulledCount", &ReflectionProbeRegistry::getLastDistanceCulledCount);
1197 probeRegistry.addFunc("queueCapture", &ReflectionProbeRegistry::queueCapture);
1198 probeRegistry.addFunc("queueCaptureAABB", &ReflectionProbeRegistry::queueCaptureAABB);
1199 probeRegistry.addFunc("tick", &ReflectionProbeRegistry::tick);
1200 probeRegistry.addFunc("updateCamera", &ReflectionProbeRegistry::updateCamera);
1201 auto water = table.addClass<Water>("Water", std::function<Water*()>([]() -> Water* { return nullptr; }), true);
1202 water.addFunc("createPlane", &Water::createPlane);
1203 auto waterMeshSettings = table.addClass("WaterMeshSettings", ssq::Class::Ctor<WaterMeshSettings()>());
1204 waterMeshSettings.addVar("sizeX", &WaterMeshSettings::sizeX);
1205 waterMeshSettings.addVar("sizeY", &WaterMeshSettings::sizeY);
1206 waterMeshSettings.addVar("sizeZ", &WaterMeshSettings::sizeZ);
1207 waterMeshSettings.addVar("densityX", &WaterMeshSettings::densityX);
1208 waterMeshSettings.addVar("densityY", &WaterMeshSettings::densityY);
1209 waterMeshSettings.addVar("height", &WaterMeshSettings::height);
1210 waterMeshSettings.addFunc(
1211 "setType", [](WaterMeshSettings* value, int type) { value->type = static_cast<WaterMeshType>(type); });
1212 auto waterGradient = table.addClass("WaterDepthGradient", ssq::Class::Ctor<WaterDepthGradient()>());
1213 waterGradient.addFunc("addColorStop", [vm = table.getHandle()](WaterDepthGradient* value, float time, float red,
1214 float green, float blue) {
1215 auto result = value ? value->addColorStop(time, red, green, blue)
1217 "water.gradient: non-null gradient required"));
1218 return eve::script::projectResult(vm, std::move(result));
1219 });
1220 waterGradient.addFunc("addAlphaStop", [vm = table.getHandle()](WaterDepthGradient* value, float time, float alpha) {
1221 auto result = value ? value->addAlphaStop(time, alpha)
1223 "water.gradient: non-null gradient required"));
1224 return eve::script::projectResult(vm, std::move(result));
1225 });
1226 waterGradient.addFunc("clear", &WaterDepthGradient::clear);
1227 table.addFunc("calculateWaterMeshTriangles", [vm = table.getHandle()](const WaterMeshSettings* settings) {
1230 "water.mesh: non-null settings required"));
1231 return eve::script::projectResult(vm, std::move(result), [](int value) { return value; });
1232 });
1233 water.addFunc("createProceduralMesh", [vm = table.getHandle()](Water* value, const WaterMeshSettings* settings) {
1234 auto result = value && settings
1235 ? value->createProceduralMesh(*settings)
1237 "water.mesh: non-null water and settings required"));
1238 return eve::script::projectResult(vm, std::move(result), [](int count) { return count; });
1239 });
1240 water.addFunc(
1241 "setDepthGradient", [vm = table.getHandle()](Water* value, const WaterDepthGradient* gradient, int resolution) {
1242 auto result =
1243 value && gradient
1244 ? value->setDepthGradient(*gradient, resolution)
1246 "water.gradient: non-null water and gradient required"));
1247 return eve::script::projectResult(vm, std::move(result), [](int count) { return count; });
1248 });
1249 water.addFunc("getDepthGradientTexture", &Water::getDepthGradientTexture);
1250 water.addFunc("clearDepthGradient", &Water::clearDepthGradient);
1251 water.addFunc("update", &Water::update);
1252 water.addFunc("setTime", &Water::setTime);
1253 water.addFunc("getTime", &Water::getTime);
1254 water.addFunc("setWaveSpeed", &Water::setWaveSpeed);
1255 water.addFunc("getWaveSpeed", &Water::getWaveSpeed);
1256 water.addFunc("setWaveAmplitude", &Water::setWaveAmplitude);
1257 water.addFunc("getWaveAmplitude", &Water::getWaveAmplitude);
1258 water.addFunc("setRippleAmplitude", &Water::setRippleAmplitude);
1259 water.addFunc("getRippleAmplitude", &Water::getRippleAmplitude);
1260 water.addFunc("setEdgeFalloff", &Water::setEdgeFalloff);
1261 water.addFunc("getEdgeFalloff", &Water::getEdgeFalloff);
1262 water.addFunc("setRippleCount", &Water::setRippleCount);
1263 water.addFunc("getRippleCount", &Water::getRippleCount);
1264 water.addFunc("setRippleInterval", &Water::setRippleInterval);
1265 water.addFunc("getRippleInterval", &Water::getRippleInterval);
1266 water.addFunc("setWaveScale", &Water::setWaveScale);
1267 water.addFunc("getWaveScale", &Water::getWaveScale);
1268 water.addFunc("setWaveDirectionAngle", [vm = table.getHandle()](Water* value, float degrees) {
1269 auto result = value ? value->setWaveDirectionAngle(degrees)
1271 "water.direction: non-null water required"));
1272 return eve::script::projectResult(vm, std::move(result));
1273 });
1274 water.addFunc("getWaveDirectionAngle", &Water::getWaveDirectionAngle);
1275 water.addFunc("setWaterColor", &Water::setWaterColor);
1276 water.addFunc("setReflectionTint", &Water::setReflectionTint);
1277 water.addFunc("setReflectionIntensity", &Water::setReflectionIntensity);
1278 water.addFunc("getReflectionIntensity", &Water::getReflectionIntensity);
1279 water.addFunc("setSunIntensity", &Water::setSunIntensity);
1280 water.addFunc("getSunIntensity", &Water::getSunIntensity);
1281 water.addFunc("setScreenSpaceReflection", &Water::setScreenSpaceReflection);
1282 water.addFunc("getScreenSpaceReflection", &Water::getScreenSpaceReflection);
1283 water.addFunc("getScreenSpaceReflectionStrength", &Water::getScreenSpaceReflectionStrength);
1284 water.addFunc("applyConfigJson", [vm = table.getHandle()](Water* value, const std::string& json) {
1285 return eve::script::projectResult(vm, value->applyConfigJson(json));
1286 });
1287 water.addFunc("configJson", [vm = table.getHandle()](Water* value) {
1288 return eve::script::projectResult(vm, value->configJson(), [](std::string json) { return json; });
1289 });
1290 water.addFunc("setViewport", &Water::setViewport);
1291 water.addFunc("getViewportWidth", &Water::getViewportWidth);
1292 water.addFunc("getViewportHeight", &Water::getViewportHeight);
1293 water.addFunc("bindParams", &Water::bindParams);
1294 water.addFunc("draw", &Water::draw);
1295 water.addFunc("setReflectionCaptureEnabled", &Water::setReflectionCaptureEnabled);
1296 water.addFunc("getReflectionCaptureEnabled", &Water::getReflectionCaptureEnabled);
1297 water.addFunc("setReflectionCaptureMask", &Water::setReflectionCaptureMask);
1298 water.addFunc("getReflectionCaptureMask", &Water::getReflectionCaptureMask);
1299 water.addFunc("getShader", &Water::getShader);
1300 water.addFunc("getMesh", &Water::getMesh);
1301
1302 auto ao = table.addClass<AmbientOcclusion>(
1303 "AmbientOcclusion", std::function<AmbientOcclusion*()>([]() -> AmbientOcclusion* { return nullptr; }), true);
1304 ao.addFunc("setQuality", &AmbientOcclusion::setQuality);
1305 ao.addFunc("getQuality", &AmbientOcclusion::getQuality);
1306 ao.addFunc("setMode", &AmbientOcclusion::setMode);
1307 ao.addFunc("getMode", &AmbientOcclusion::getMode);
1308 ao.addFunc("setCamera", &AmbientOcclusion::setCamera);
1309 ao.addFunc("setRadius", &AmbientOcclusion::setRadius);
1310 ao.addFunc("setBias", &AmbientOcclusion::setBias);
1311 ao.addFunc("setIntensity", &AmbientOcclusion::setIntensity);
1312 ao.addFunc("setPower", &AmbientOcclusion::setPower);
1313 ao.addFunc("setThickness", &AmbientOcclusion::setThickness);
1314 ao.addFunc("getRadius", &AmbientOcclusion::getRadius);
1315 ao.addFunc("getBias", &AmbientOcclusion::getBias);
1316 ao.addFunc("getIntensity", &AmbientOcclusion::getIntensity);
1317 ao.addFunc("getPower", &AmbientOcclusion::getPower);
1318 ao.addFunc("hasParam", &AmbientOcclusion::hasParam);
1319 ao.addFunc("setFloat", &AmbientOcclusion::setFloat);
1320 ao.addFunc("getFloat", &AmbientOcclusion::getFloat);
1321 ao.addFunc("getSampleCount", &AmbientOcclusion::getSampleCount);
1322 ao.addFunc("getDownscale", &AmbientOcclusion::getDownscale);
1323 ao.addFunc("resolutionFor", &AmbientOcclusion::resolutionFor);
1324 ao.addFunc("compute", &AmbientOcclusion::compute);
1325 ao.addFunc("computeTo", &AmbientOcclusion::computeTo);
1326 ao.addFunc("blur", &AmbientOcclusion::blur);
1327 ao.addFunc("blurTo", &AmbientOcclusion::blurTo);
1328 ao.addFunc("applyOverlay", &AmbientOcclusion::applyOverlay);
1329 ao.addFunc("applyOverlayTo", &AmbientOcclusion::applyOverlayTo);
1330 ao.addFunc("applyFromDepth", &AmbientOcclusion::applyFromDepth);
1331 ao.addFunc("applyFromDepthTo", &AmbientOcclusion::applyFromDepthTo);
1332 ao.addFunc("applyFromGBuffer", &AmbientOcclusion::applyFromGBuffer);
1333 ao.addFunc("getShader", &AmbientOcclusion::getShader);
1334 ao.addFunc("getSsaoShader", &AmbientOcclusion::getSsaoShader);
1335 ao.addFunc("getHbaoShader", &AmbientOcclusion::getHbaoShader);
1336 ao.addFunc("getGtaoShader", &AmbientOcclusion::getGtaoShader);
1337 ao.addFunc("getBlurShader", &AmbientOcclusion::getBlurShader);
1338 ao.addFunc("getOverlayShader", &AmbientOcclusion::getOverlayShader);
1339 ao.addFunc("getFromDepthShader", &AmbientOcclusion::getFromDepthShader);
1340
1341 auto contactShadow = table.addClass<ContactShadow>(
1342 "ContactShadow", std::function<ContactShadow*()>([]() -> ContactShadow* { return nullptr; }), true);
1343 contactShadow.addFunc("setQuality", &ContactShadow::setQuality);
1344 contactShadow.addFunc("getQuality", &ContactShadow::getQuality);
1345 contactShadow.addFunc("setCamera", &ContactShadow::setCamera);
1346 contactShadow.addFunc("setLightDirection", &ContactShadow::setLightDirection);
1347 contactShadow.addFunc("setLength", &ContactShadow::setLength);
1348 contactShadow.addFunc("setThickness", &ContactShadow::setThickness);
1349 contactShadow.addFunc("setIntensity", &ContactShadow::setIntensity);
1350 contactShadow.addFunc("setStartBias", &ContactShadow::setStartBias);
1351 contactShadow.addFunc("getLength", &ContactShadow::getLength);
1352 contactShadow.addFunc("getThickness", &ContactShadow::getThickness);
1353 contactShadow.addFunc("getIntensity", &ContactShadow::getIntensity);
1354 contactShadow.addFunc("getStartBias", &ContactShadow::getStartBias);
1355 contactShadow.addFunc("getStepCount", &ContactShadow::getStepCount);
1356 contactShadow.addFunc("applyFromGBuffer", &ContactShadow::applyFromGBuffer);
1357 contactShadow.addFunc("getShader", &ContactShadow::getShader);
1358
1359 auto outline =
1360 table.addClass<Outline>("Outline", std::function<Outline*()>([]() -> Outline* { return nullptr; }), true);
1361 outline.addFunc("setColor", &Outline::setColor);
1362 outline.addFunc("getColorR", &Outline::getColorR);
1363 outline.addFunc("getColorG", &Outline::getColorG);
1364 outline.addFunc("getColorB", &Outline::getColorB);
1365 outline.addFunc("setWidth", &Outline::setWidth);
1366 outline.addFunc("getWidth", &Outline::getWidth);
1367 outline.addFunc("setDepthThreshold", &Outline::setDepthThreshold);
1368 outline.addFunc("getDepthThreshold", &Outline::getDepthThreshold);
1369 outline.addFunc("setDepthSensitivity", &Outline::setDepthSensitivity);
1370 outline.addFunc("getDepthSensitivity", &Outline::getDepthSensitivity);
1371 outline.addFunc("setNormalThreshold", &Outline::setNormalThreshold);
1372 outline.addFunc("getNormalThreshold", &Outline::getNormalThreshold);
1373 outline.addFunc("setSoftness", &Outline::setSoftness);
1374 outline.addFunc("getSoftness", &Outline::getSoftness);
1375 outline.addFunc("setClip", &Outline::setClip);
1376 outline.addFunc("hasParam", &Outline::hasParam);
1377 outline.addFunc("setFloat", &Outline::setFloat);
1378 outline.addFunc("getFloat", &Outline::getFloat);
1379 outline.addFunc("apply", &Outline::apply);
1380 outline.addFunc("applyTo", &Outline::applyTo);
1381 outline.addFunc("getShader", &Outline::getShader);
1382
1383 auto gi = table.addClass<GlobalIllumination>(
1384 "GlobalIllumination", std::function<GlobalIllumination*()>([]() -> GlobalIllumination* { return nullptr; }),
1385 true);
1386 gi.addFunc("setQuality", &GlobalIllumination::setQuality);
1387 gi.addFunc("getQuality", &GlobalIllumination::getQuality);
1388 gi.addFunc("setCamera", &GlobalIllumination::setCamera);
1389 gi.addFunc("setRadius", &GlobalIllumination::setRadius);
1390 gi.addFunc("setIntensity", &GlobalIllumination::setIntensity);
1391 gi.addFunc("setThickness", &GlobalIllumination::setThickness);
1392 gi.addFunc("setResolutionScale", &GlobalIllumination::setResolutionScale);
1393 gi.addFunc("setLightDirection", &GlobalIllumination::setLightDirection);
1394 gi.addFunc("setLightColor", &GlobalIllumination::setLightColor);
1395 gi.addFunc("getRadius", &GlobalIllumination::getRadius);
1396 gi.addFunc("getIntensity", &GlobalIllumination::getIntensity);
1397 gi.addFunc("getThickness", &GlobalIllumination::getThickness);
1398 gi.addFunc("getResolutionScale", &GlobalIllumination::getResolutionScale);
1399 gi.addFunc("hasParam", &GlobalIllumination::hasParam);
1400 gi.addFunc("setFloat", &GlobalIllumination::setFloat);
1401 gi.addFunc("getFloat", &GlobalIllumination::getFloat);
1402 gi.addFunc("getSampleCount", &GlobalIllumination::getSampleCount);
1403 gi.addFunc("applyFromDepth", &GlobalIllumination::applyFromDepth);
1404 gi.addFunc("applyFromDepthTo", &GlobalIllumination::applyFromDepthTo);
1405 gi.addFunc("applyFromScene", &GlobalIllumination::applyFromScene);
1406 gi.addFunc("getShader", &GlobalIllumination::getShader);
1407
1408 auto ssr = table.addClass<ScreenSpaceReflection>(
1409 "ScreenSpaceReflection",
1410 std::function<ScreenSpaceReflection*()>([]() -> ScreenSpaceReflection* { return nullptr; }), true);
1411 ssr.addFunc("setCamera", &ScreenSpaceReflection::setCamera);
1412 ssr.addFunc("setEnabled", &ScreenSpaceReflection::setEnabled);
1413 ssr.addFunc("getEnabled", &ScreenSpaceReflection::getEnabled);
1414 ssr.addFunc("setQuality", &ScreenSpaceReflection::setQuality);
1415 ssr.addFunc("getQuality", &ScreenSpaceReflection::getQuality);
1416 ssr.addFunc("setMaxDistance", &ScreenSpaceReflection::setMaxDistance);
1417 ssr.addFunc("setStepLength", &ScreenSpaceReflection::setStepLength);
1418 ssr.addFunc("setMaxSteps", &ScreenSpaceReflection::setMaxSteps);
1419 ssr.addFunc("setThickness", &ScreenSpaceReflection::setThickness);
1420 ssr.addFunc("setStrength", &ScreenSpaceReflection::setStrength);
1421 ssr.addFunc("setMaxRoughness", &ScreenSpaceReflection::setMaxRoughness);
1422 ssr.addFunc("setResolutionScale", &ScreenSpaceReflection::setResolutionScale);
1423 ssr.addFunc("getStrength", &ScreenSpaceReflection::getStrength);
1424 ssr.addFunc("getMaxRoughness", &ScreenSpaceReflection::getMaxRoughness);
1425 ssr.addFunc("getResolutionScale", &ScreenSpaceReflection::getResolutionScale);
1426 ssr.addFunc("hasParam", &ScreenSpaceReflection::hasParam);
1427 ssr.addFunc("setFloat", &ScreenSpaceReflection::setFloat);
1428 ssr.addFunc("getFloat", &ScreenSpaceReflection::getFloat);
1429 ssr.addFunc("applyFromScene", &ScreenSpaceReflection::applyFromScene);
1430 ssr.addFunc(
1431 "applyFromSceneTo",
1432 static_cast<void (ScreenSpaceReflection::*)(Graphics*, Texture*, Texture*, Texture*, Texture*, Canvas*)>(
1433 &ScreenSpaceReflection::applyFromSceneTo));
1434 ssr.addFunc("getShader", &ScreenSpaceReflection::getShader);
1435
1436 auto aa = table.addClass<AntiAliasing>(
1437 "AntiAliasing", std::function<AntiAliasing*()>([]() -> AntiAliasing* { return nullptr; }), true);
1438 aa.addFunc("setQuality", &AntiAliasing::setQuality);
1439 aa.addFunc("getQuality", &AntiAliasing::getQuality);
1440 aa.addFunc("setMode", &AntiAliasing::setMode);
1441 aa.addFunc("getMode", &AntiAliasing::getMode);
1442 aa.addFunc("hasParam", &AntiAliasing::hasParam);
1443 aa.addFunc("setFloat", &AntiAliasing::setFloat);
1444 aa.addFunc("getFloat", &AntiAliasing::getFloat);
1445 aa.addFunc("suggestScale", &AntiAliasing::suggestScale);
1446 aa.addFunc("resolutionFor", &AntiAliasing::resolutionFor);
1447 aa.addFunc("apply", &AntiAliasing::apply);
1448 aa.addFunc("applyTo", &AntiAliasing::applyTo);
1449 aa.addFunc("applyCanvas", &AntiAliasing::applyCanvas);
1450 aa.addFunc("applyCanvasTo", &AntiAliasing::applyCanvasTo);
1451 aa.addFunc("getShader", &AntiAliasing::getShader);
1452 aa.addFunc("getFxaaShader", &AntiAliasing::getFxaaShader);
1453 aa.addFunc("getSmaaShader", &AntiAliasing::getSmaaShader);
1454 aa.addFunc("getSsaaShader", &AntiAliasing::getSsaaShader);
1455 aa.addFunc("getNfaaShader", &AntiAliasing::getNfaaShader);
1456}
1457
1458void Graphics::expose(ssq::Class& cls) {
1459 cls.addFunc("getName", &Graphics::getName);
1460 cls.addFunc("reset", &Graphics::reset);
1461 cls.addFunc("present", &Graphics::present);
1462 cls.addFunc("clear", &Graphics::clearScreen);
1463 cls.addFunc("setBackgroundColor", &Graphics::setBackgroundColorRGBA);
1464 cls.addFunc("drawSolidRect", &Graphics::drawSolidRectRGBA);
1465 cls.addFunc("drawTexturedRect", &Graphics::drawTexturedRectRGBA);
1466 cls.addFunc("renderSprites", &Graphics::renderSprites);
1467 cls.addFunc("newSprite2D", &Graphics::newSprite2D);
1468 cls.addFunc("drawTexturedRectRotated", &Graphics::drawTexturedRectRotatedRGBA);
1469 cls.addFunc("newFont", static_cast<Font* (Graphics::*)(font::FontData*, std::string)>(&Graphics::newFont));
1470 cls.addFunc("setFont", &Graphics::setFont);
1471 cls.addFunc("getFont", &Graphics::getFont);
1472 cls.addFunc("drawText", &Graphics::drawTextRGBA);
1473 cls.addFunc("print", &Graphics::printRGBA);
1474 cls.addFunc("loadTexture", [](Graphics* self, const std::string& filename) {
1475 auto loaded = self->loadTexture(filename);
1476 if (!loaded.ok()) throw eve::Exception("%s", loaded.status().describe().c_str());
1477 return &loaded.value().get();
1478 });
1479 cls.addFunc("newTextureFromFile", &Graphics::newTextureFromFile);
1480 cls.addFunc("newTexture",
1481 static_cast<Texture* (Graphics::*)(image::ImageData*, bool, bool)>(&Graphics::newTextureFromImageData));
1482 cls.addFunc(
1483 "setRenderableTextureFromImageData",
1484 [](Graphics* self, Renderable3D* renderable, image::ImageData* data, bool repeatU, bool repeatV) -> Texture* {
1485 if (!renderable) throw eve::Exception("setRenderableTextureFromImageData: null Renderable3D");
1486 Texture* texture = self->newTextureFromImageData(data, repeatU, repeatV);
1487 if (Material* material = renderable->getMaterial())
1488 material->setAlbedoTexture(texture);
1489 else
1490 renderable->setTexture(texture);
1491 return texture;
1492 });
1493 cls.addFunc("updateTextureFromImageData", [](Graphics* self, Texture* texture, image::ImageData* data) {
1494 auto updated = self->updateTextureFromImageData(texture, data);
1495 if (!updated.ok()) throw eve::Exception("%s", updated.status().describe().c_str());
1496 });
1497 cls.addFunc("newTextureFromFile", &Graphics::newTextureFromFile);
1498 cls.addFunc("newTextureFromFileRepeated", &Graphics::newTextureFromFileRepeated);
1499 cls.addFunc("newTextureWithSampler", &Graphics::newTextureWithSampler);
1500 cls.addFunc("setTextureSampler",
1501 static_cast<void (Graphics::*)(Texture*, const std::string&, const std::string&, float, float)>(
1502 &Graphics::setTextureSampler));
1503 cls.addFunc("getMaxAnisotropy", &Graphics::getMaxAnisotropy);
1504 cls.addFunc("newMeshSphere", &Graphics::newMeshSphere);
1505 cls.addFunc("newMeshCylinder", &Graphics::newMeshCylinder);
1506 cls.addFunc("newMeshCube", &Graphics::newMeshCube);
1507 cls.addFunc("newMeshFromArrays",
1508 std::function<Mesh*(Graphics*, ssq::Array, ssq::Array, ssq::Array, int, ssq::Array, int)>(
1509 newMeshFromArraysScript));
1510 cls.addFunc("updateMeshVertices",
1511 std::function<bool(Graphics*, Mesh*, ssq::Array, ssq::Array, ssq::Array, int, ssq::Array, int)>(
1512 updateMeshVerticesScript));
1513 cls.addFunc("bakeMeshMorph", &Graphics::bakeMeshMorph);
1514 cls.addFunc("newShader", static_cast<Shader* (Graphics::*)(const std::string&)>(&Graphics::newShader));
1515 cls.addFunc("newShaderFromWgsl", &Graphics::newShaderFromWgsl);
1516 cls.addFunc("newMeshShader", static_cast<Shader* (Graphics::*)(const std::string&)>(&Graphics::newMeshShader));
1517 cls.addFunc("newMeshShaderVF", &Graphics::newMeshShaderVF);
1518 cls.addFunc("newHairShader", &Graphics::newHairShader);
1519 cls.addFunc("newHairCardMesh", &Graphics::newHairCardMesh);
1520 cls.addFunc("newHairCardMaterial", &Graphics::newHairCardMaterial);
1521 cls.addFunc("newGrassShader", &Graphics::newGrassShader);
1522 cls.addFunc("newTreeWindShader", &Graphics::newTreeWindShader);
1523 cls.addFunc("newGrassField", &Graphics::newGrassField);
1524 cls.addFunc("newGroomInstance", &Graphics::newGroomInstance);
1525 cls.addFunc("newWaterfall", &Graphics::newWaterfall);
1526 cls.addFunc("newReflectionProbeCapture", &Graphics::newReflectionProbeCapture);
1527 cls.addFunc("newReflectionProbeRegistry", &Graphics::newReflectionProbeRegistry);
1528 cls.addFunc("newWater", &Graphics::newWater);
1529 cls.addFunc(
1530 "configureFoliageWind",
1531 [vm = cls.getHandle()](Graphics* self, Material* material, float directionX, float directionZ, float strength,
1532 float bending, float bendingSpeed, float branch, float branchSpeed, float flutter,
1533 float flutterSpeed, float fadeDistance, float bendFactor) {
1535 vm, self->configureFoliageWind(material, directionX, directionZ, strength, bending, bendingSpeed,
1536 branch, branchSpeed, flutter, flutterSpeed, fadeDistance, bendFactor));
1537 });
1538 cls.addFunc("newShaderFromSpvFile",
1539 static_cast<Shader* (Graphics::*)(const std::string&)>(&Graphics::newShaderFromSpvFile));
1540 cls.addFunc("setShader", std::function<void(Graphics*, ssq::Object)>(setShaderScript));
1541 cls.addFunc("getShader", &Graphics::getShader);
1542 cls.addFunc("render3D", &Graphics::render3D);
1543 cls.addFunc("begin3DFrame", &Graphics::begin3DFrame);
1544 cls.addFunc("setMesh3DViewProj", std::function<void(Graphics*, ssq::Array)>(setMesh3DViewProjScript));
1545 cls.addFunc("setMesh3DView", std::function<void(Graphics*, ssq::Array)>(setMesh3DViewScript));
1546 cls.addFunc("setMesh3DCameraPos", std::function<void(Graphics*, float, float, float)>(setMesh3DCameraPosScript));
1547 cls.addFunc("renderScene3DToCanvas", &Graphics::renderScene3DToCanvas);
1548 cls.addFunc("renderScene3DWithShadowsToCanvas", &Graphics::renderScene3DWithShadowsToCanvas);
1549 cls.addFunc("drawScene3DRGBA", &Graphics::drawScene3DRGBA);
1550 cls.addFunc("saveFramePng", &Graphics::saveFramePng);
1551 cls.addFunc("drawScene3D", &Graphics::drawScene3D);
1552 cls.addFunc("drawCanvas", &Graphics::drawCanvas);
1553 cls.addFunc("newCanvas", &Graphics::newCanvas);
1554 cls.addFunc("setCanvas", std::function<void(Graphics*, ssq::Object)>(setCanvasScript));
1555 cls.addFunc("getCanvas", &Graphics::getCanvas);
1556 cls.addFunc("getWidth", &Graphics::getWidth);
1557 cls.addFunc("getHeight", &Graphics::getHeight);
1558 cls.addFunc("setDirectionalLight", &Graphics::setDirectionalLight);
1559 // Process-wide shadow scheme toggles (dir CSM / spot perspective / point cube).
1560 cls.addFunc("setShadowSchemeDirectionalEnabled", [](Graphics*, bool enabled) {
1561 ShadowSchemeSettings::current().enableDirectionalCsm = enabled;
1562 });
1563 cls.addFunc("setShadowSchemeSpotEnabled", [](Graphics*, bool enabled) {
1564 ShadowSchemeSettings::current().enableSpotPerspective = enabled;
1565 });
1566 cls.addFunc("setShadowSchemePointEnabled", [](Graphics*, bool enabled) {
1567 ShadowSchemeSettings::current().enablePointCube = enabled;
1568 });
1569 cls.addFunc("setShadowSchemeMaxSpotCasters", [](Graphics*, int count) {
1570 ShadowSchemeSettings::current().maxSpotShadowCasters = count;
1571 });
1572 cls.addFunc("getShadowSchemeMaxSpotCasters",
1573 [](Graphics*) { return ShadowSchemeSettings::current().maxSpotShadowCasters; });
1574 cls.addFunc("setShadowSchemePagingEnabled", [](Graphics*, bool enabled) {
1575 ShadowSchemeSettings::current().enableLocalPaging = enabled;
1576 });
1577 cls.addFunc("setShadowSchemeMaxLocalUpdates", [](Graphics*, int count) {
1578 ShadowSchemeSettings::current().maxLocalUpdatesPerFrame = count;
1579 });
1580 cls.addFunc("getShadowSchemeMaxLocalUpdates",
1581 [](Graphics*) { return ShadowSchemeSettings::current().maxLocalUpdatesPerFrame; });
1582 cls.addFunc("setShadowSchemeHysteresisBonus", [](Graphics*, float bonus) {
1583 ShadowSchemeSettings::current().hysteresisBonus = bonus;
1584 });
1585 // Dynamic shadow atlas resolution + CSM coverage. GPU recreates on next
1586 // shadow ensure when atlas size changes (@cost: full depth-array realloc).
1587 cls.addFunc("setShadowSchemeDirectionalMapSize", [](Graphics*, int size) {
1588 if (size > 0) setShadowSchemeMapSizes(size, -1).ignore();
1589 });
1590 cls.addFunc("getShadowSchemeDirectionalMapSize",
1591 [](Graphics*) { return ShadowSchemeSettings::current().directionalMapSize; });
1592 cls.addFunc("setShadowSchemeLocalMapSize", [](Graphics*, int size) {
1593 if (size > 0) {
1594 auto& s = ShadowSchemeSettings::current();
1595 s.localMapSize = clampShadowMapSize(size);
1596 }
1597 });
1598 cls.addFunc("getShadowSchemeLocalMapSize", [](Graphics*) { return ShadowSchemeSettings::current().localMapSize; });
1599 cls.addFunc("getShadowSchemeAtlasMapSize",
1600 [](Graphics*) { return ShadowSchemeSettings::current().resolvedAtlasMapSize(); });
1601 cls.addFunc("setShadowSchemeDirectionalMaxDistance",
1602 [](Graphics*, float meters) { setShadowSchemeDirectionalMaxDistance(meters).ignore(); });
1603 cls.addFunc("getShadowSchemeDirectionalMaxDistance",
1604 [](Graphics*) { return ShadowSchemeSettings::current().directionalMaxDistance; });
1605 cls.addFunc("setShadowSchemeAdaptiveCascadeResolution", [](Graphics*, bool enabled) {
1606 ShadowSchemeSettings::current().enableAdaptiveCascadeResolution = enabled;
1607 });
1608 cls.addFunc("getShadowSchemeAdaptiveCascadeResolution",
1609 [](Graphics*) { return ShadowSchemeSettings::current().enableAdaptiveCascadeResolution; });
1610 cls.addFunc("setCloudShadows", &Graphics::setCloudShadows);
1611 cls.addFunc("newMaterial", &Graphics::newMaterial);
1612 cls.addFunc("getRenderControl", &Graphics::getRenderControl);
1613 cls.addFunc("setMsaaSamples", &Graphics::setMsaaSamples);
1614 cls.addFunc("getMsaaSamples", &Graphics::getMsaaSamples);
1615 cls.addFunc("setVSyncCount", &Graphics::setVSyncCount);
1616 cls.addFunc("getVSyncCount", [](Graphics* self) { return self->getVSyncCount(); });
1617 cls.addFunc("getSceneColorTexture", &Graphics::getSceneColorTexture);
1618 cls.addFunc("newQuad", &Graphics::newQuad);
1619 cls.addFunc("newVolumetric", &Graphics::newVolumetric);
1620 cls.addFunc("newDepthOfField", &Graphics::newDepthOfField);
1621 cls.addFunc("newAmbientOcclusion", &Graphics::newAmbientOcclusion);
1622 cls.addFunc("newContactShadow", &Graphics::newContactShadow);
1623 cls.addFunc("newOutline", &Graphics::newOutline);
1624 cls.addFunc("newAlphaMask", &Graphics::newAlphaMask);
1625 cls.addFunc("newMapFog", &Graphics::newMapFog);
1626 cls.addFunc("getOutline", &Graphics::pipelineOutline);
1627 cls.addFunc("newGlobalIllumination", &Graphics::newGlobalIllumination);
1628 cls.addFunc("newScreenSpaceReflection", &Graphics::newScreenSpaceReflection);
1629 cls.addFunc("newAntiAliasing", &Graphics::newAntiAliasing);
1630 cls.addFunc("drawOcclusionSolid", &Graphics::drawOcclusionSolid);
1631 cls.addFunc("drawOcclusionTexture", &Graphics::drawOcclusionTexture);
1632}
1633
1634void Graphics::reset() {
1635 currentShader = nullptr;
1636 currentFont = nullptr;
1637}
1638
1639Renderable2D* Graphics::newSprite2D() { return Renderable2D::create(); }
1640
1641void Graphics::renderSprites() {
1642 std::vector<DrawItem2D> items;
1643 RenderSystem::collectSprites(items);
1644 RenderSystem::drawItems(*this, items, false);
1645}
1646
1647void Graphics::initHeadless(int width, int height) {
1648 (void)width;
1649 (void)height;
1650 throw Exception("Graphics::initHeadless: not supported on this backend");
1651}
1652
1653void Graphics::setShader(Shader* shader) { currentShader = shader; }
1654
1655void Graphics::setShader() { currentShader = nullptr; }
1656
1657Volumetric* Graphics::newVolumetric() { return new Volumetric(this); }
1658
1659DepthOfField* Graphics::newDepthOfField() { return new DepthOfField(this); }
1660
1661AmbientOcclusion* Graphics::newAmbientOcclusion() { return new AmbientOcclusion(this); }
1662
1663ContactShadow* Graphics::newContactShadow() { return new ContactShadow(this); }
1664
1665Outline* Graphics::newOutline() { return new Outline(this); }
1666AlphaMask* Graphics::newAlphaMask() { return new AlphaMask(this); }
1667
1668MapFog* Graphics::newMapFog() { return new MapFog(this); }
1669
1670GlobalIllumination* Graphics::newGlobalIllumination() { return new GlobalIllumination(this); }
1671
1672ScreenSpaceReflection* Graphics::newScreenSpaceReflection() { return new ScreenSpaceReflection(this); }
1673
1674AmbientOcclusion* Graphics::pipelineAmbientOcclusion() {
1675 if (!pipelineAO_) pipelineAO_ = std::make_unique<AmbientOcclusion>(this);
1676 return pipelineAO_.get();
1677}
1678
1679ContactShadow* Graphics::pipelineContactShadow() {
1680 if (!pipelineContactShadow_) pipelineContactShadow_ = std::make_unique<ContactShadow>(this);
1681 return pipelineContactShadow_.get();
1682}
1683
1684GlobalIllumination* Graphics::pipelineGlobalIllumination() {
1685 if (!pipelineGI_) pipelineGI_ = std::make_unique<GlobalIllumination>(this);
1686 return pipelineGI_.get();
1687}
1688
1689AntiAliasing* Graphics::pipelineAntiAliasing() {
1690 if (!pipelineAA_) pipelineAA_ = std::make_unique<AntiAliasing>(this);
1691 return pipelineAA_.get();
1692}
1693
1694Bloom* Graphics::pipelineBloom() {
1695 if (!pipelineBloom_) pipelineBloom_ = std::make_unique<Bloom>(this);
1696 return pipelineBloom_.get();
1697}
1698
1699DepthOfField* Graphics::pipelineDepthOfField() {
1700 if (!pipelineDof_) pipelineDof_ = std::make_unique<DepthOfField>(this);
1701 return pipelineDof_.get();
1702}
1703
1704Exposure* Graphics::pipelineExposure() {
1705 if (!pipelineExposure_) pipelineExposure_ = std::make_unique<Exposure>(this);
1706 return pipelineExposure_.get();
1707}
1708
1709DepthPyramid* Graphics::pipelineDepthPyramid() {
1710 if (!pipelineDepthPyramid_) pipelineDepthPyramid_ = std::make_unique<DepthPyramid>(this);
1711 return pipelineDepthPyramid_.get();
1712}
1713
1714void Graphics::setSceneDepthOfField(float focusDistance, float maximumBlurPixels, float focusRange, float nearPlane,
1715 float farPlane) {
1716 sceneDepthOfFieldEnabled_ = maximumBlurPixels > 0.f;
1717 sceneDepthOfFieldFocusDistance_ = focusDistance;
1718 sceneDepthOfFieldFocusRange_ = focusRange;
1719 sceneDepthOfFieldMaximumBlurPixels_ = maximumBlurPixels;
1720 sceneDepthOfFieldNearPlane_ = nearPlane;
1721 sceneDepthOfFieldFarPlane_ = farPlane;
1722}
1723Texture* Graphics::prepareFinalSceneTexture(Texture* scene, Texture* motion) {
1724 EV_PROFILE_MODULE("graphics", "PostProcess.Prepare");
1725 if (!scene) return nullptr;
1727 AntiAliasing* aa = pipelineAntiAliasing();
1728 const bool temporal = renderControl_ && renderControl_->isEnabled("taa");
1729 const bool spatial = !renderControl_ || renderControl_->isEnabled("aa");
1730 const std::string requested = renderControl_ ? renderControl_->getPostProcessQuality() : "high";
1731 const std::string quality = requested == "ultra" ? "high" : requested;
1732 if (aa->getQuality() != quality) aa->setQuality(quality);
1733 if (temporal) {
1734 aa->setMode("taa");
1735 resolved = aa->resolveTemporal(this, scene, motion);
1736 } else if (spatial) {
1737 aa->setMode("fxaa");
1738 const int width = std::max(scene->getWidth(), 1);
1739 const int height = std::max(scene->getHeight(), 1);
1740 spatialAAResolve_ = &prepareFramePostTarget(FramePostTarget::SpatialAA, width, height);
1741 aa->applyTo(this, scene, spatialAAResolve_);
1742 resolved = spatialAAResolve_->getTexture();
1743 }
1744 if (getSceneDofMaxBlur() > 0.f && renderControl_) {
1745 GBuffer* gb = renderControl_->getGBuffer();
1746 if (gb && gb->isValid()) {
1747 Texture* depth = getBackendName() == "webgpu" ? gb->getDepthTexture() : gb->getHwDepthTexture();
1748 if (depth) {
1749 resolved =
1750 pipelineDepthOfField()->apply(resolved, depth, getSceneDofFocusDistance(), getSceneDofMaxBlur(),
1751 getSceneDofFocusRange(), getSceneDofNearZ(), getSceneDofFarZ());
1752 }
1753 }
1754 }
1755 Texture* meterSource = resolved;
1756 resolved = pipelineBloom()->apply(resolved, getSceneBloomIntensity(), getSceneBloomThreshold());
1757 const RgbF filter = getSceneColorFilter();
1758 const RgbF lift = getSceneLift();
1759 const RgbF invG = getSceneInverseGamma();
1760 const RgbF gain = getSceneGain();
1761 return pipelineExposure()->apply(
1762 resolved, getSceneExposure(), getSceneAutoExposure(), getSceneAutoExposureMinEV(), getSceneAutoExposureMaxEV(),
1763 glm::vec3(filter.r, filter.g, filter.b), glm::vec3(lift.r, lift.g, lift.b), glm::vec3(invG.r, invG.g, invG.b),
1764 glm::vec3(gain.r, gain.g, gain.b), getSceneTransitionVignette(), getSceneTransitionVignetteSmoothness(),
1765 getSceneTransitionLensDistortion(), getSceneTransitionLensScale(), meterSource);
1766}
1767
1768Canvas& Graphics::prepareFramePostTarget(FramePostTarget target, int width, int height) {
1769 auto& canvas = sharedFramePostTargets_[static_cast<size_t>(target)];
1770 if (!canvas || canvas->getWidth() != width || canvas->getHeight() != height) canvas = newHDRCanvas(width, height);
1771 if (!canvas) throw Exception("Post-process target allocation failed");
1772 return *canvas;
1773}
1774
1775Canvas* Graphics::pipelineReflectionComposite(int width, int height) {
1776 width = std::max(width, 1);
1777 height = std::max(height, 1);
1778 if (!reflectionComposite_ || reflectionCompositeWidth_ != width || reflectionCompositeHeight_ != height) {
1779 reflectionComposite_ = newHDRCanvas(width, height);
1780 reflectionCompositeWidth_ = width;
1781 reflectionCompositeHeight_ = height;
1782 }
1783 return reflectionComposite_;
1784}
1785
1786ScreenSpaceReflection* Graphics::pipelineScreenSpaceReflection() {
1787 if (!pipelineSSR_) pipelineSSR_ = std::make_unique<ScreenSpaceReflection>(this);
1788 return pipelineSSR_.get();
1789}
1790
1791Outline* Graphics::pipelineOutline() {
1792 if (!pipelineOutline_) pipelineOutline_ = std::make_unique<Outline>(this);
1793 return pipelineOutline_.get();
1794}
1795
1796AntiAliasing* Graphics::newAntiAliasing() { return new AntiAliasing(this); }
1797
1798Shader* Graphics::newHairShader() { return hair::createShader(this); }
1799
1800Mesh* Graphics::newHairCardMesh(float width, float height) { return hair::newCardMesh(this, width, height); }
1801
1802Material* Graphics::newHairCardMaterial(Texture* albedo) { return hair::makeCardMaterial(this, albedo, nullptr); }
1803
1804Shader* Graphics::newGrassShader() { return grass::createShader(this); }
1805
1806Shader* Graphics::newTreeWindShader() { return createTreeWindShader(this); }
1807
1808GrassField* Graphics::newGrassField() { return new GrassField(this); }
1809
1810hair::GroomInstance* Graphics::newGroomInstance() { return new hair::GroomInstance(this); }
1811
1812Waterfall* Graphics::newWaterfall() { return new Waterfall(this); }
1813Water* Graphics::newWater() { return new Water(this); }
1814
1815ReflectionProbeCapture* Graphics::newReflectionProbeCapture() { return new ReflectionProbeCapture(this); }
1816
1817ReflectionProbeRegistry* Graphics::newReflectionProbeRegistry() { return new ReflectionProbeRegistry(); }
1818
1819Mesh* Graphics::newMeshCube(float size) {
1820 const float h = size * 0.5f;
1821 // 6 faces x 4 corners (per-face normal + full 0..1 UV), outward CCW for RH Y-up.
1822 const float kFaces[6][4][3] = {
1823 {{-h, -h, h}, {h, -h, h}, {h, h, h}, {-h, h, h}}, // +Z
1824 {{h, -h, -h}, {-h, -h, -h}, {-h, h, -h}, {h, h, -h}}, // -Z
1825 {{h, -h, h}, {h, -h, -h}, {h, h, -h}, {h, h, h}}, // +X
1826 {{-h, -h, -h}, {-h, -h, h}, {-h, h, h}, {-h, h, -h}}, // -X
1827 {{-h, h, h}, {h, h, h}, {h, h, -h}, {-h, h, -h}}, // +Y
1828 {{-h, -h, -h}, {h, -h, -h}, {h, -h, h}, {-h, -h, h}}, // -Y
1829 };
1830 const float kN[6][3] = {{0, 0, 1}, {0, 0, -1}, {1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}};
1831 const float kUV[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
1832
1833 std::vector<float> pos, nrm, uv;
1834 pos.reserve(6 * 4 * 3);
1835 nrm.reserve(6 * 4 * 3);
1836 uv.reserve(6 * 4 * 2);
1837 std::vector<uint32_t> indices;
1838 indices.reserve(6 * 6);
1839 for (int f = 0; f < 6; ++f) {
1840 const uint32_t base = uint32_t(f * 4);
1841 for (int c = 0; c < 4; ++c) {
1842 pos.insert(pos.end(), kFaces[f][c], kFaces[f][c] + 3);
1843 nrm.insert(nrm.end(), kN[f], kN[f] + 3);
1844 uv.insert(uv.end(), kUV[c], kUV[c] + 2);
1845 }
1846 indices.push_back(base + 0);
1847 indices.push_back(base + 1);
1848 indices.push_back(base + 2);
1849 indices.push_back(base + 0);
1850 indices.push_back(base + 2);
1851 indices.push_back(base + 3);
1852 }
1853 return newMeshFromArrays(pos.data(), nrm.data(), uv.data(), int(pos.size() / 3), indices.data(),
1854 int(indices.size()));
1855}
1856
1857bool Graphics::saveFramePng(const std::string& path) {
1858 if (!screenReadbackEnabled) setScreenReadbackEnabled(true);
1859 std::unique_ptr<eve::image::ImageData> frame;
1860 try {
1861 frame.reset(newImageData());
1862 } catch (...) {
1863 return false; // no presented frame yet
1864 }
1865 if (!frame) return false;
1866 std::unique_ptr<eve::filesystem::FileData> png(
1867 frame->encode(medialoader::FormatHandler::ENCODED_PNG, path.c_str(), false));
1868 if (!png) return false;
1869 std::error_code ec;
1870 std::filesystem::create_directories(std::filesystem::path(path).parent_path(), ec);
1871 std::ofstream out(path, std::ios::binary);
1872 if (!out.good()) return false;
1873 out.write(static_cast<const char*>(png->getData()), static_cast<std::streamsize>(png->getSize()));
1874 return out.good();
1875}
1876
1877void Graphics::draw(Drawable* drawable, const glm::mat4& m) {
1878 if (drawable) drawable->draw(this, m);
1879}
1880
1881void Graphics::drawOcclusion(Drawable* drawable, const glm::mat4& m) {
1882 if (drawable && drawable->getCastOcclusion()) drawable->drawOcclusion(this, m);
1883}
1884
1885void Graphics::drawOcclusionSolid(float x, float y, float w, float h) {
1886 drawSolidRect(x, y, w, h, Color(0.f, 0.f, 0.f, 1.f));
1887}
1888
1889void Graphics::drawOcclusionTexture(Texture* texture, float x, float y, float w, float h) {
1890 // Black RGB keeps silhouette; texture alpha cuts soft edges (same idea as shadow masks).
1891 drawTexturedRect(texture, x, y, w, h, Color(0.f, 0.f, 0.f, 1.f));
1892}
1893
1894void Graphics::clearScreen() { clear(std::nullopt, std::nullopt, std::nullopt); }
1895
1896void Graphics::setBackgroundColorRGBA(float r, float g, float b, float a) { setBackgroundColor(Color(r, g, b, a)); }
1897
1898void Graphics::drawSolidRectRGBA(float x, float y, float w, float h, float r, float g, float b, float a) {
1899 drawSolidRect(x, y, w, h, Color(r, g, b, a));
1900}
1901
1902void Graphics::drawTexturedRectRGBA(Texture* texture, float x, float y, float w, float h, float r, float g, float b,
1903 float a) {
1904 drawTexturedRect(texture, x, y, w, h, Color(r, g, b, a));
1905}
1906
1907void Graphics::drawTexturedRectRotatedRGBA(Texture* texture, float cx, float cy, float w, float h, float degrees,
1908 float r, float g, float b, float a) {
1909 drawTexturedRectShaderUVRotated(texture, nullptr, cx, cy, w, h, degrees, 0.f, 0.f, 1.f, 1.f, Color(r, g, b, a),
1910 false, BlendMode::Alpha);
1911}
1912
1913void Graphics::drawSolidRect(float x, float y, float w, float h, float r, float g, float b, float a) {
1914 drawSolidRectRGBA(x, y, w, h, r, g, b, a);
1915}
1916
1917void Graphics::drawTexturedRect(Texture* texture, float x, float y, float w, float h, float r, float g, float b,
1918 float a) {
1919 drawTexturedRectRGBA(texture, x, y, w, h, r, g, b, a);
1920}
1921
1922Texture* Graphics::newTextureFromImageData(image::ImageData* data, bool repeatU, bool repeatV) {
1923 if (!data) throw eve::Exception("newTextureFromImageData: null ImageData");
1924 if (data->getFormat() != "RGBA8") throw eve::Exception("newTextureFromImageData: only RGBA8 supported");
1927 info.sampler.repeatV = repeatV;
1928 return newTexture(data->getWidth(), data->getHeight(), static_cast<const uint8_t*>(data->getData()), info);
1929}
1930
1931Texture* Graphics::newTextureFromImageData(image::ImageData* data, const TextureCreateInfo& info) {
1932 if (!data) throw eve::Exception("newTextureFromImageData: null ImageData");
1933 if (data->getFormat() != "RGBA8") throw eve::Exception("newTextureFromImageData: only RGBA8 supported");
1934 return newTexture(data->getWidth(), data->getHeight(), static_cast<const uint8_t*>(data->getData()), info);
1935}
1936
1937eve::Result<void> Graphics::updateTextureFromImageData(Texture* texture, image::ImageData* data) {
1938 ensureFileTexturesReady();
1939 if (!texture || !data)
1941 "texture and ImageData must be non-null",
1942 "graphics.updateTextureFromImageData"));
1943 if (data->getFormat() != "RGBA8")
1945 "only RGBA8 ImageData is supported",
1946 "graphics.updateTextureFromImageData.format"));
1947 if (!updateTexture(texture, data->getWidth(), data->getHeight(), static_cast<const uint8_t*>(data->getData())))
1949 eve::DiagnosticCode::Failed, "texture is not owned by this backend, dimensions differ, or upload failed",
1950 "graphics.updateTextureFromImageData"));
1952}
1953
1954void Graphics::requestFileImageDecode(const std::string& key) {
1956 if (!queued.ok()) throw eve::Exception("%s", queued.status().describe().c_str());
1957}
1958
1959bool Graphics::fileTextureSourceExists(const std::string& filename) const {
1960 auto* fs = eve::filesystem::Filesystem::create();
1961 if (!fs) return false;
1963 return fs->getInfo(filename, info);
1964}
1965
1966void Graphics::dropDeferredFileTexture(Texture* texture) {
1967 if (!texture) return;
1968 deferredFileTextures_.erase(
1969 std::remove_if(deferredFileTextures_.begin(), deferredFileTextures_.end(),
1970 [texture](const DeferredFileTexture& item) { return item.texture == texture; }),
1971 deferredFileTextures_.end());
1972 texture->clearDeferredFilePixels();
1973}
1974
1975bool Graphics::uploadDeferredFileTexture(Texture* texture, image::ImageData* data) {
1976 if (!texture || !data) return false;
1977 if (data->getFormat() != "RGBA8") return false;
1978 return updateTexture(texture, data->getWidth(), data->getHeight(), static_cast<const uint8_t*>(data->getData()));
1979}
1980
1981
1982Texture* Graphics::newTextureWithSampler(image::ImageData* data, bool repeatU, bool repeatV, bool generateMipmaps,
1983 float maxAnisotropy, const std::string& filter, const std::string& mipmap,
1984 float lodBias) {
1986 info.generateMipmaps = generateMipmaps;
1987 info.sampler.min = TextureSampler::parseFilter(filter.c_str());
1988 info.sampler.mag = info.sampler.min;
1989 info.sampler.mipmap = TextureSampler::parseMipmap(mipmap.c_str());
1990 if (generateMipmaps && info.sampler.mipmap == MipmapMode::Disabled) info.sampler.mipmap = MipmapMode::Linear;
1991 info.sampler.repeatU = repeatU;
1992 info.sampler.repeatV = repeatV;
1993 info.sampler.maxAnisotropy = maxAnisotropy;
1994 info.sampler.lodBias = lodBias;
1995 return newTextureFromImageData(data, info);
1996}
1997
1998void Graphics::setTextureSampler(Texture* texture, const std::string& filter, const std::string& mipmap,
1999 float maxAnisotropy, float lodBias) {
2000 if (!texture) return;
2001 // Fail fast on typos instead of silently treating an unknown filter as linear.
2002 if (filter != "nearest" && filter != "Nearest" && filter != "NEAREST" && filter != "linear" && filter != "Linear" &&
2003 filter != "LINEAR") {
2004 throw eve::Exception("Graphics::setTextureSampler: unknown filter '%s'", filter.c_str());
2005 }
2006 if (mipmap != "none" && mipmap != "None" && mipmap != "NONE" && mipmap != "nearest" && mipmap != "Nearest" &&
2007 mipmap != "NEAREST" && mipmap != "linear" && mipmap != "Linear" && mipmap != "LINEAR") {
2008 throw eve::Exception("Graphics::setTextureSampler: unknown mipmap mode '%s'", mipmap.c_str());
2009 }
2010 TextureSampler s = texture->getSampler();
2011 s.min = TextureSampler::parseFilter(filter.c_str());
2012 s.mag = s.min;
2013 s.mipmap = TextureSampler::parseMipmap(mipmap.c_str());
2014 s.maxAnisotropy = maxAnisotropy;
2015 s.lodBias = lodBias;
2016 setTextureSampler(texture, s);
2017}
2018
2019Quad* Graphics::newQuad(int x, int y, int w, int h) { return new Quad(x, y, w, h); }
2020
2021Font* Graphics::newFont(font::FontData* data) { return newFont(data, Font::defaultCharset()); }
2022
2023Font* Graphics::newFont(font::FontData* data, std::string charset) { return new Font(this, data, std::move(charset)); }
2024
2025void Graphics::print(const std::string& text, float x, float y, const Color& color, float scale) {
2026 if (currentFont == nullptr) {
2027 eve::debug::rtDraw("print", "no-font");
2028 throw eve::Exception("Graphics::print: no font set (call setFont first)");
2029 }
2030 drawText(currentFont, text, x, y, color, scale);
2031}
2032
2033void Graphics::drawText(Font* font, const std::string& text, float x, float y, const Color& color, float scale) {
2034 if (font == nullptr) {
2035 eve::debug::rtDraw("drawText", "no-font");
2036 throw eve::Exception("Graphics::drawText: font must not be null");
2037 }
2038 eve::debug::rtBind("font", "explicit");
2039 eve::debug::rtDraw("drawText", text.empty() ? "" : "text");
2040
2041 eve::font::FontData* data = font->getData();
2042 float penX = x;
2043 float baseline = y + font->getBaseline() * scale;
2044 int prevCodepoint = -1;
2045
2046 size_t i = 0;
2047 while (i < text.size()) {
2048 uint32_t cp = nextCodepointUtf8(text, i);
2049 if (cp == 0) continue;
2050 int code = static_cast<int>(cp);
2051
2052 if (prevCodepoint >= 0) penX += data->getKerning(prevCodepoint, code) * scale;
2053
2054 if (const Font::Glyph* g = font->findGlyph(code)) {
2055 if (g->width > 0 && g->height > 0) {
2056 float gx = penX + static_cast<float>(g->bearingX) * scale;
2057 float gy = baseline - static_cast<float>(g->bearingY) * scale;
2058 drawTexturedRectUV(font->getTexture(), gx, gy, static_cast<float>(g->width) * scale,
2059 static_cast<float>(g->height) * scale, g->u0, g->v0, g->u1, g->v1, color);
2060 }
2061 penX += static_cast<float>(g->advance) * scale;
2062 } else {
2063 // Not pre-rasterized into this Font's atlas — still advance the pen.
2064 penX += static_cast<float>(data->getGlyphAdvance(code)) * scale;
2065 }
2066
2067 prevCodepoint = code;
2068 }
2069}
2070
2071} // namespace eve::graphics
double z
double y
double m[16]
double x
LogicalId target
float w
Definition AnimClip.cpp:738
eve::action::ActionSpatialBinding spatial
const std::string & s
float ao
float cx
Definition CardTypes.cpp:36
float cy
Definition CardTypes.cpp:37
float degrees
Definition CardTypes.cpp:38
float uv
bool applied
graphics::Texture * albedo
Stable, structured diagnostics shared by engine modules.
HSQUIRRELVM vm
Definition ECS.cpp:38
HSQOBJECT cls
Definition ECS.cpp:39
SQObjectPtr key
Definition ECS.cpp:155
std::string name
Definition ECS.cpp:154
float strength
DiagnosticCode code
std::uint32_t vertexCount
std::uint32_t indexCount
tensor::Graph g
Definition GpuGraph.cpp:7
float camera[2]
POD RGB triple for Graphics tone-map controls without glm headers.
float u
Definition Grass.cpp:233
glm::vec3 n
Definition Grass.cpp:63
double r
std::uint32_t aa
std::vector< std::uint32_t > indices
float v
std::int32_t c
int h
std::uint32_t height
std::uint32_t width
std::array< float, 3 > scale
Poco::JSON::Object::Ptr result
MeleePoint3 b
Definition MeleeHit.cpp:41
double radius
Definition MeleeHit.cpp:42
MeleePoint3 a
Definition MeleeHit.cpp:40
float distance
float roughness
Texture * normal
#define Module_IMPL(ModuleName, newExpr)
Definition Module.h:27
OceanWakeSettings settings
OceanMeshSettings mesh
ssq::Object frame
glm::dvec3 dx
glm::dvec3 dz
ssq::Object water
size_t queued
Definition OnnxGpgpu.cpp:60
std::string error
Definition Package.cpp:174
std::array< uint32_t, 16 > material
Texture * texture
TileLayer * layer
int idx
float f
std::array< std::uint64_t, kPixelChunkSize *kPixelChunkSize > updated
std::string path
Definition PlayHost.cpp:111
std::unordered_set< std::string > loaded
Definition Plugins.cpp:24
std::weak_ptr< PrimitiveScene > scene
#define EV_PROFILE_MODULE(module, name)
Profile the enclosing scope, tagged with a module for grouping.
Definition Profile.h:158
Object::Ptr value
std::string slot
Shader * shader
float ambientG
float ambientR
float ambientB
RoadNetwork resolved
bool repeatV
std::string filter
std::string mipmap
bool repeatU
Graphics * graphics
std::string text
ScriptStructure out
std::string_view source
Light3D::Data * light
Definition Shadow.cpp:147
float dy
Definition Shadow.cpp:151
Vec scattering
int count
The single Squirrel projection for common Result, Status and Value.
Explicit Value/Owned/Borrowed semantics at the Squirrel boundary.
float size
Definition TreeMesh.cpp:158
std::uint32_t depth
double weight
double gain
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
EVENGINE_API_FOUNDATION public API.
Definition Exception.h:13
Graphics-owned state machine and immutable CPU snapshot authority. @thread Main-thread only; supplied...
eve::Result< void > request(std::string key)
Queue a cache miss load without blocking for decode to finish.
Definition Resource.cpp:149
static ResourceManager & getInstance()
Returns the instance.
Definition Resource.cpp:15
void ignore(std::string_view reason={}) const noexcept
Explicitly discard this result after documenting the reason.
Definition Result.h:571
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
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
float getSoftness() const
Return the current soft-edge width.
Definition AlphaMask.h:26
void setInverted(bool inverted)
Invert mask coverage.
Definition AlphaMask.cpp:67
void setSoftness(float softness)
Set the normalized soft-edge half width.
Definition AlphaMask.cpp:62
bool getInverted() const
Return whether mask coverage is inverted.
Definition AlphaMask.h:30
void draw(Texture *color, Texture *mask, float x, float y, float width, float height, float r=1.f, float g=1.f, float b=1.f, float a=1.f)
Draw a color texture multiplied by a same-UV alpha mask.
Definition AlphaMask.cpp:72
float getThreshold() const
Return the current normalized cutoff.
Definition AlphaMask.h:22
void setThreshold(float threshold)
Set the mask cutoff in normalized alpha space.
Definition AlphaMask.cpp:57
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
float screenToWorldY(float screenX, float screenY, float viewW, float viewH)
bool getPixelSnap()
Return whether pixel-grid snapping is enabled.
int getPixelRefHeight()
Return reference height, or 0 when unset.
int getPixelScale()
Return the last integer upscale from applyPixelPerfect.
float worldToScreenY(float worldX, float worldY, float viewW, float viewH)
void clearPixelConfig()
Clear reference resolution and restore default pixels-per-unit of 1.
int getPixelRefWidth()
Return reference width, or 0 when unset.
static Camera2D * createCamera(ecs::Table &table= *ecs::current())
Create an active camera in the current ECS table.
float worldToScreenX(float worldX, float worldY, float viewW, float viewH)
float getPixelsPerUnit()
Return configured pixels per world unit.
float screenToWorldX(float screenX, float screenY, float viewW, float viewH)
Convert screen pixel (origin top-left of viewport) to world coordinates. viewW/viewH are the current ...
void setZoom(float zoom)
void setAmbient(float r, float g, float b)
void setPosition(float x, float y)
World-space look-at center and zoom (1 = identity).
void setPixelSnap(bool enabled)
Enable or disable snapping the camera center onto the pixel grid.
void setPixelPerfect(bool enabled)
Enable or disable automatic perfect-pixel zoom resolution.
bool getPixelPerfect()
Return whether perfect-pixel resolution is enabled.
EVENGINE_API_BACKENDS public API.
void setBloom(float intensity, float threshold=1.f)
Configure HDR bloom. Zero intensity disables it.
float getPixelsPerUnit()
Return configured pixels per world unit, or 0 when unset.
float getEyeX()
Camera eye position (world space).
void snapToPixelGrid(int viewWidth, int viewHeight)
Snap the eye onto the view-plane pixel grid for the current ortho / pixel sizing.
float getDofFocusDistance()
Return DOF focus distance.
float getNearClip()
Return the positive near clipping distance.
float getDofFocusRange()
Return DOF focus range.
bool hasPixelConfig()
Return whether a pixels-per-unit config is stored.
static Camera3D * createCamera(ecs::Table &table= *ecs::current())
Create an active camera in the current ECS table.
void setShadowLayerCullDistance(int layer, float distance)
Set the shadow-caster cull distance for one render layer; zero disables it.
int getPixelScale()
Return the last integer upscale from applyPixelPerfect.
float getAperture()
Return physical-camera aperture.
void setDepthOfField(float focusDistance, float maxBlurPx, float focusRange=8.f)
Configure Gaussian depth-of-field on the final HDR resolve.
float getFocalLength()
Return physical-camera focal length in millimetres.
float getFov()
Vertical field of view in degrees.
void setLayerCullDistance(int layer, float distance)
Set the camera cull distance for one render layer; zero disables the override.
float getDofMaxBlur()
Return DOF max blur in texels (0 when disabled).
void setReflectionProbe(int slot, Texture *cubemap, float centerX, float centerY, float centerZ, float extentX, float extentY, float extentZ, float intensity=1.f, float blendDistance=1.f, int priority=0)
Configure one local reflection probe slot.
bool isAutoExposure()
Return whether automatic exposure is enabled.
float getBloomThreshold()
Return bloom threshold in linear HDR units.
void setPerspective()
Return to perspective projection, retaining the configured field of view.
bool isOrthographic()
Return whether the camera currently uses orthographic projection.
float getExposure()
Return exposure compensation in photographic stops.
void setUp(float x, float y, float z)
void setOrthographic(float height)
Enable a pure orthographic projection with the given vertical world-space span.
int getPixelRefWidth()
Return reference width, or 0 when unset.
void clearEnvProbe()
Disable box projection and return to an infinite-distance environment.
float getOrthoHeight()
Return the vertical world-space span used by orthographic projection.
void clearReflectionProbe(int slot)
Disable one local reflection probe slot.
void setFov(float fovYDeg)
float getBloomIntensity()
Return bloom intensity.
void setPhysicalLens(float aperture, float focalLength)
Set positive physical-camera aperture and focal length metadata.
bool getPixelSnap()
Return whether pixel-grid snapping is enabled.
void screenToRay(float screenX, float screenY, float viewW, float viewH)
Build a world-space picking ray from a screen pixel. Stores origin (camera eye) and normalized direct...
void setExposure(float ev)
Set exposure compensation in photographic stops. Positive values brighten.
float getLayerCullDistance(int layer)
Return the camera cull-distance override for one render layer.
void setEnvIntensity(float intensity)
void setEnvProbe(float centerX, float centerY, float centerZ, float extentX, float extentY, float extentZ)
Enable box-projected IBL for the camera environment cubemap.
float getFarClip()
Return the far clipping distance.
void clearPixelConfig()
Clear pixel sizing so applyPixelPerfect / setPixelOrthographic require a fresh config.
void setAutoExposure(bool enabled, float minEV=-8.f, float maxEV=8.f)
Enable log-average automatic exposure and set its EV clamp range.
void setTarget(float x, float y, float z)
float getShadowLayerCullDistance(int layer)
Return the shadow-caster cull-distance override for one render layer.
void clearDepthOfField()
Disable depth-of-field while retaining the current focus settings.
void setPixelSnap(bool enabled)
Enable or disable snapping the eye onto the view-plane pixel grid.
void setAmbient(float r, float g, float b)
void setActive(bool active)
int getReflectionProbeCount()
Return the number of enabled local reflection probes.
void setEye(float x, float y, float z)
float getTargetX()
Look-at target (world space).
bool hasEnvProbe()
True when all three box-probe extents are positive.
void setEnvMap(Texture *cube)
Specular IBL cubemap (Graphics::newCubemap). nullptr disables IBL.
void setClipPlanes(float nearZ, float farZ)
Set positive near/far clipping distances; far is kept beyond near.
int getPixelRefHeight()
Return reference height, or 0 when unset.
Canvas public API.
Definition Canvas.h:17
Canvas()
Constructs a Canvas.
Definition Canvas.h:25
virtual Texture * getTexture()=0
Sampleable color buffer; screen Canvas returns nullptr.
Screen-space contact shadows for the primary directional light.
Separable Gaussian depth-of-field for the final HDR scene.
Texture * apply(Texture *source, Texture *hwDepth, float focusDistance, float maxBlurPx, float focusRange, float nearZ, float farZ)
Apply separable Gaussian DOF.
Cross-backend min/max hardware-depth pyramid packed into one texture atlas.
Drawable base (textures, meshes, canvases).
Definition Drawable.h:18
virtual void drawOcclusion(Graphics *gfx, const glm::mat4 &matrix) const
Draw as an opaque black silhouette for volumetric occlusion maps (screen-space god rays / light shaft...
Definition Drawable.h:40
virtual void draw(Graphics *gfx, const glm::mat4 &matrix) const =0
Draws the object with the specified transformation matrix.
bool getCastOcclusion() const
When false, skipped by Graphics::drawOcclusion / volumetric occluder passes.
Definition Drawable.h:31
void setCastOcclusion(bool cast)
Sets the cast occlusion.
Definition Drawable.h:33
GPU percentile metering, eye adaptation, and linear HDR pre-exposure.
Definition Exposure.h:14
void setExtinction(float extinction)
Signed extinction; negative values carve fog but total density is clamped.
Definition FogVolume.h:30
float getNoiseScale() const
World-space density-noise frequency.
Definition FogVolume.h:54
float getExtinction() const
Definition FogVolume.h:31
float getAnisotropy() const
Definition FogVolume.h:40
void setAnisotropy(float anisotropy)
HG anisotropy in [-0.99,0.99].
Definition FogVolume.cpp:68
std::string getShapeName() const
Definition FogVolume.cpp:50
void setShape(const std::string &shape)
Set shape using "sphere", "box" or "cylinder"; unknown selects box.
Definition FogVolume.cpp:41
void setAlbedo(float r, float g, float b)
Single-scattering albedo, clamped to [0,1].
Definition FogVolume.cpp:60
float getEdgeFalloff() const
Definition FogVolume.h:43
int getNoiseSeed() const
Stable density-noise seed.
Definition FogVolume.h:56
void setEmissive(float r, float g, float b)
Unlit radiance emitted per unit density.
Definition FogVolume.cpp:64
void setEdgeFalloff(float falloff)
Fraction of normalized radius used for a smooth edge, in [0,1].
Definition FogVolume.cpp:72
void setSize(float x, float y, float z)
Set full world-space dimensions; values are clamped positive.
Definition FogVolume.cpp:56
float getNoiseAmount() const
Density-noise blend amount in [0,1].
Definition FogVolume.h:52
void setPosition(float x, float y, float z)
Set world-space center.
Definition FogVolume.h:23
void setNoise(float amount, float scale, int seed)
Configure deterministic world-space density variation.
Definition FogVolume.cpp:76
GPU-side font: wraps a decoded font::FontData and rasterizes a fixed set of codepoints into a single ...
Definition Font.h:35
font::FontData * getData() const
Returns the data.
Definition Font.h:49
Texture * getTexture() const
Returns the texture.
Definition Font.h:51
float getBaseline() const
Distance from the top of a line to the baseline (== getAscent()).
Definition Font.cpp:174
const Glyph * findGlyph(int codepoint) const
Returns nullptr if codepoint isn't in this Font's atlas.
Definition Font.cpp:180
Screen-space buffers for mid/post effects and Hybrid deferred lighting.
Definition GBuffer.h:28
int getWidth() const
Returns the width.
Definition GBuffer.h:46
Texture * getBuffer(const std::string &name) const
Returns the buffer.
Definition GBuffer.cpp:20
int getHeight() const
Returns the height.
Definition GBuffer.h:48
bool hasBuffer(const std::string &name) const
"depth" | "hwDepth" | "normal" | "albedo" | "pbrParams" | "emissive" | "velocity"
Definition GBuffer.cpp:9
Texture * getAlbedoTexture() const
Returns the albedo texture.
Definition GBuffer.h:57
Texture * getNormalTexture() const
Returns the normal texture.
Definition GBuffer.h:55
Texture * getDepthTexture() const
Returns the depth texture.
Definition GBuffer.h:51
Texture * getHwDepthTexture() const
Returns the hw depth texture.
Definition GBuffer.h:53
bool isValid() const
True when valid.
Definition GBuffer.cpp:5
Screen-space single-bounce GI (SSGI). @lifetime All texture arguments are borrowed for the duration o...
virtual void setDirectionalLight(float dx, float dy, float dz, float r=1.f, float g=1.f, float b=1.f)
Sets the directional light.
Definition Graphics.cpp:273
void retireResourceLifetime() const
Retire resource lifetime.
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).
std::shared_ptr< PrimitiveScene > primitiveScene_
Definition Graphics.h:2341
FramePostTarget
Internal fully overwritten outputs; temporal histories are excluded.
Definition Graphics.h:2281
eve::OptionalRef< IRayTracing > rayTracingService() const noexcept
Borrow the optional ray-tracing service resolved at graphics construction. @ownership Provider-owned;...
Definition Graphics.cpp:186
bool recordingEngine3D_
True while RenderSystem3D is submitting (AO / engine overlays).
Definition Graphics.h:2325
std::unique_ptr< FrameCaptureStore > frameCaptures_
Definition Graphics.h:2290
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)
Composite this frame's 3D scene color into a rect (screen or active Canvas). Call after render3D(); o...
Definition Graphics.cpp:254
virtual void renderScene3DToCanvas(Canvas *canvas, Camera3D *camera)
Preview-quality 3D pass into an offscreen Canvas (editor viewport): renders visible Renderable3D with...
Definition Graphics.cpp:221
Shader * prepareSceneColorResolveShader(Texture *scene)
FXAA resolve shader that writes opaque RGB (ignores scene-color depth alpha).
Definition Graphics.cpp:234
std::uint64_t mesh3dDrawEpoch_
Advanced once per render3D(); virtual-texture materials tick at most once per value.
Definition Graphics.h:2323
virtual void popValidationScope()=0
Pops validation scope.
virtual void pushValidationScope()=0
Backend hooks so the platform-independent render3D() can wrap its work in a GPU validation error scop...
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)
Draw a Canvas color buffer as a textured rect (same batch order as other 2D).
Definition Graphics.cpp:266
Material * newMaterial()
Create a Material asset (shading model + textures + PBR knobs). Caller owns Material*; not tracked by...
Definition Graphics.cpp:277
void renderScene3DWithShadowsToCanvas(Canvas *canvas, Camera3D *camera)
Render an offscreen editor preview with directional CSM and per-material shadow flags....
Definition Graphics.cpp:227
std::unique_ptr< RenderControl > renderControl_
Definition Graphics.h:2340
AntiAliasing * pipelineAntiAliasing()
Pipeline anti aliasing.
virtual void render3D()
Run RenderSystem3D (begin3DFrame + draw visible Renderable3D).
Definition Graphics.cpp:210
~Graphics() override
Graphics.
Definition Graphics.cpp:191
virtual void drawTexturedRect(Texture *texture, float x, float y, float w, float h, float r, float g, float b, float a=1.f)
RGBA-float overload matching the script-facing drawTexturedRect name.
eve::cap::ProviderRef< IRayTracing > rayTracing_
Definition Graphics.h:2289
virtual Texture * getSceneColorTexture()
Sampleable 3D color target for the current frame (RGB = lit, A = linear depth). Valid after begin3DFr...
Definition Graphics.h:1075
RenderControl * getRenderControl()
Shared compilable 3D render control (features → pass list + GBuffer). Owned by Graphics; valid for th...
Definition Graphics.cpp:279
FrameCaptureStore & frameCaptures()
Graphics-owned frame capture authority. @thread Engine main thread only. @lifetime Borrowed until Gra...
Definition Graphics.cpp:202
Dense grass + sparse dark tufts on a mesh. Caller owns GrassField*; GPU Mesh / Shader / Texture are o...
Definition Grass.h:193
void setReflectionCaptureMask(uint32_t mask)
Set the reflection-capture visibility layer mask.
Definition Grass.h:288
void setFrameDuration(float seconds)
Definition Grass.cpp:714
uint32_t getReflectionCaptureMask() const
Return the reflection-capture visibility layer mask.
Definition Grass.h:290
bool getReflectionCaptureEnabled() const
Return whether this field is included in reflection-probe captures.
Definition Grass.h:286
Shader * getShader() const
Borrow the shader on the owner thread; valid until this field is destroyed.
Definition Grass.h:297
Mesh * getDenseMesh() const
Borrow the dense mesh on the owner thread; valid until this field rebakes or is destroyed.
Definition Grass.h:293
void setReflectionCaptureEnabled(bool enabled)
Enable or disable inclusion in reflection-probe captures.
Definition Grass.h:284
Texture * getAtlas() const
Borrow the atlas on the owner thread; valid until this field uploads another atlas or is destroyed.
Definition Grass.h:299
Mesh * getSparseMesh() const
Borrow the sparse mesh on the owner thread; valid until this field rebakes or is destroyed.
Definition Grass.h:295
int getDenseCount() const
Definition Grass.h:301
void bakePlane(float sizeX, float sizeZ, int segX, int segZ)
Definition Grass.cpp:693
void setTime(float seconds)
Definition Grass.cpp:709
float getTime() const
Definition Grass.h:276
void update(float dt)
Definition Grass.cpp:704
int getSparseCount() const
Definition Grass.h:302
float getFrameDuration() const
Definition Grass.h:278
Optional hardware ray-tracing backend (Vulkan KHR RT).
Definition IRayTracing.h:28
float getVolumetricIntensity()
Definition Light.cpp:84
void setDirection(float dx, float dy)
Definition Light.cpp:46
void setPosition(float x, float y)
Definition Light.cpp:38
void setColor(float r, float g, float b, float intensity=1.f)
Definition Light.cpp:54
static Light2D * createEmissiveProxy(float x, float y, float r, float g, float b, float intensity=1.f, float radius=200.f)
Create a volumetric-only glow proxy (skips surface lighting).
Definition Light.cpp:16
float getSpotSoftness()
Current spot softness in [0, 1].
Definition Light.cpp:73
void setVolumetric(bool enabled)
Definition Light.cpp:78
void setCanvas(Canvas *canvas)
Definition Light.cpp:89
void setVolumetricOnly(bool enabled)
Definition Light.cpp:86
void setVolumetricIntensity(float intensity)
Definition Light.cpp:81
float getSpotAngle()
Current outer half-angle in degrees.
Definition Light.cpp:68
void setType(const std::string &type)
Definition Light.cpp:28
void setEnabled(bool enabled)
Definition Light.cpp:75
void setSpotAngle(float degrees)
Outer half-angle of a spot cone in degrees (clamped to (0, 89]).
Definition Light.cpp:65
std::string getType()
Definition Light.cpp:36
static Light2D * createLight(const std::string &type="point")
Definition Light.cpp:8
void setRadius(float radius)
Definition Light.cpp:62
void setSpotSoftness(float softness)
Softness of the spot penumbra in [0, 1].
Definition Light.cpp:70
void setEnabled(bool enabled)
Definition Light.cpp:165
void setSpotAngle(float degrees)
Outer half-angle of a 3D spot cone in degrees (clamped to (0, 89]).
Definition Light.cpp:155
static Light3D * createEmissiveProxy(float x, float y, float z, float r, float g, float b, float intensity=1.f, float radius=8.f)
Create a volumetric-only point glow proxy for emissive props. Pair with a PBR emissive material + blo...
Definition Light.cpp:99
void setCastShadow(bool cast)
Definition Light.cpp:168
void setDirection(float dx, float dy, float dz)
Definition Light.cpp:133
void setShadowBias(float bias)
Definition Light.cpp:213
float getVolumetricIntensity()
Definition Light.cpp:227
void setVolumetricOnly(bool enabled)
Definition Light.cpp:229
float getShadowStrength()
Definition Light.cpp:219
void setShadowStrength(float strength)
Definition Light.cpp:216
void setPosition(float x, float y, float z)
Definition Light.cpp:122
static Light3D * createLight(const std::string &type="point")
Definition Light.cpp:91
void setType(const std::string &type)
Definition Light.cpp:112
void setVolumetricIntensity(float intensity)
Definition Light.cpp:224
void setShadowMethod(const std::string &method)
Request a shadow technique: auto, none, csm, perspective, cube. Invalid names leave the previous meth...
Definition Light.cpp:171
void setRadius(float radius)
Definition Light.cpp:152
void setColor(float r, float g, float b, float intensity=1.f)
Definition Light.cpp:144
void setSpotSoftness(float softness)
Softness of the spot penumbra in [0, 1].
Definition Light.cpp:160
float getSpotSoftness()
Current spot softness in [0, 1].
Definition Light.cpp:163
std::string getShadowMethod()
Current shadow method name (auto / none / csm / perspective / cube).
Definition Light.cpp:198
void setVolumetric(bool enabled)
Definition Light.cpp:221
float getSpotAngle()
Current spot outer half-angle in degrees.
Definition Light.cpp:158
std::string getType()
Definition Light.cpp:120
SLG / large-map war-fog overlay driven by a dual-scrolling cloud texture and an RGBA mask bridge (R u...
Definition MapFog.h:18
void setShadowEnabled(bool enabled)
Enable the pre-pass cloud shadow (must draw before the main pass).
Definition MapFog.cpp:344
void setEdgeSoftness(float softness)
Soft edge half-width around the mask R threshold.
Definition MapFog.cpp:342
float getCloudTileA() const
Returns the cloud tile a.
Definition MapFog.h:92
void draw(float x, float y, float width, float height)
Draw fog over a destination rectangle (shadow pass then main pass).
Definition MapFog.cpp:516
void setCloudMix(float mix)
Mix weight between the two scrolling cloud samples (0..1).
Definition MapFog.cpp:356
void setCloudTiling(float tileA, float tileB)
Dual-layer cloud tiling (layer A / B).
Definition MapFog.cpp:317
bool getShadowEnabled() const
Returns the shadow enabled.
Definition MapFog.h:106
void setMaskTexture(Texture *mask)
Set the RGBA mask bridge texture.
Definition MapFog.cpp:315
float getFogAlpha() const
Returns the fog alpha.
Definition MapFog.h:102
Texture * makeCloudTexture(int size=128)
Build a seamless procedural cloud noise texture owned by Graphics.
Definition MapFog.cpp:363
void setFogColor(float r, float g, float b)
Fog tint RGB in 0..1.
Definition MapFog.cpp:334
void setTime(float time)
Override the animated time used by cloud scroll (seconds).
Definition MapFog.cpp:306
void setDistortFix(float x, float y)
Correct additive UV drift introduced by distortion.
Definition MapFog.cpp:329
float getCloudTileB() const
Returns the cloud tile b.
Definition MapFog.h:94
void setCloudTexture(Texture *cloud)
Set or replace the repeating cloud/color texture.
Definition MapFog.cpp:308
void setDistort(float amount)
Mask-UV distortion amount from desaturated cloud noise.
Definition MapFog.cpp:327
void setFogAlpha(float alpha)
Overall fog opacity in 0..1.
Definition MapFog.cpp:340
void setSelectStrength(float strength)
Selection blink amplitude for mask G.
Definition MapFog.cpp:352
void setCloudSpeed(float speedA, float speedB)
Dual-layer scroll speeds in UV units per second.
Definition MapFog.cpp:322
float getTime() const
Return the current animation time in seconds.
Definition MapFog.h:34
void update(float dt)
Advance dual-scroll / blink timers.
Definition MapFog.cpp:302
void setCloudDensity(float contrast, float bias)
Shape cloud alpha: contrast (soft→hard) and bias (coverage).
Definition MapFog.cpp:358
Texture * getMaskTexture() const
Return the current mask texture, or null if unset. @ownership Borrowed; ownership stays with the prov...
Definition MapFog.h:62
void setShadow(float offsetX, float offsetY, float strength)
Shadow UV offset and strength.
Definition MapFog.cpp:346
Texture * getCloudTexture()
Return the active cloud texture (never null after first ensureCloudTexture). @ownership Borrowed; Gra...
Definition MapFog.cpp:310
void setDissolveScale(float scale)
Dissolve noise tiling scale.
Definition MapFog.cpp:354
Packages shading method + surface parameters into one attachable asset.
Definition Material.h:38
float getFloat(const std::string &name) const
Returns the float.
Definition Material.cpp:209
void setNormalTexture(Texture *texture)
Set the borrowed material texture. @ownership Graphics factory owns the resource. @lifetime Keep aliv...
Definition Material.h:172
void setAlbedoTexture(Texture *texture)
Set the borrowed material texture. @ownership Graphics factory owns the resource. @lifetime Keep aliv...
Definition Material.h:123
std::string getAlphaTechnique() const
Returns the alpha technique.
Definition Material.h:356
float getAlbedoUvOffsetV() const
Current base-color UV offset V.
Definition Material.h:143
bool hasParam(const std::string &name) const
Optional named float knobs (style / custom shader params).
Definition Material.cpp:205
bool getHair() const
Returns the hair.
Definition Material.h:294
void setCastShadow(bool cast)
Sets the cast shadow.
Definition Material.h:277
void setCastOcclusion(bool cast)
Sets the cast occlusion.
Definition Material.h:287
void setHeightTexture(Texture *texture)
Sets the height texture.
Definition Material.h:180
float getMetallic() const
Returns the metallic.
Definition Material.h:246
Texture * getAlbedoTexture() const
Get the borrowed material texture. @ownership Graphics factory owns the resource. @lifetime Keep aliv...
Definition Material.h:128
void setAlphaTechnique(const std::string &technique)
Optional masked transparency quality: "cutoff", "dither", "coverage".
Definition Material.cpp:201
void setBlendMode(const std::string &mode)
Set "alpha", "premultiplied", "additive", or "multiply".
Definition Material.cpp:183
std::string getBlendMode() const
Returns the blend mode.
Definition Material.cpp:194
void setMetallic(float metallic)
Sets the metallic.
Definition Material.cpp:131
void setReceiveShadow(bool receive)
Sets the receive shadow.
Definition Material.h:282
Texture * getNormalTexture() const
Get the borrowed material texture. @ownership Graphics factory owns the resource. @lifetime Keep aliv...
Definition Material.h:177
float getRoughness() const
Returns the roughness.
Definition Material.h:251
float getAlphaCutoff() const
Returns the alpha cutoff.
Definition Material.h:330
bool getReceiveShadow() const
Returns the receive shadow.
Definition Material.h:284
float getAlbedoUvScaleU() const
Current base-color UV scale U.
Definition Material.h:154
void setCameraFacing(bool enabled)
Keep a bottom-anchored card facing the active camera around world Y during GPU-driven draws.
Definition Material.h:346
void clearVirtualTexture()
Restore conventional albedo/normal/height interpretation and drop any owned streaming session.
Definition Material.cpp:71
void setRoughness(float roughness)
Sets the roughness.
Definition Material.cpp:133
int getSortPriority() const
Returns the sort priority.
Definition Material.h:352
bool getCameraFacing() const
Return whether GPU-driven card vertices use cylindrical camera-facing orientation.
Definition Material.h:348
void setAlphaCutoff(float cutoff)
Sets the alpha cutoff.
Definition Material.cpp:181
bool getCastOcclusion() const
Returns the cast occlusion.
Definition Material.h:289
bool getDoubleSided() const
Returns the double sided.
Definition Material.h:344
void setReceiveLight(bool receive)
Sets the receive light.
Definition Material.h:272
void setSurfaceMode(const std::string &mode)
Set "opaque", "masked", or "transparent" surface classification.
Definition Material.cpp:166
void setShadingModel(const std::string &model)
"pbr" | "unlit" | "hair" | "custom" (unknown → pbr).
Definition Material.cpp:106
void setTexCellBomb(float cellScale, float strength, float rotAmount=1.f)
Sets the tex cell bomb.
Definition Material.cpp:137
bool getDepthWrite() const
Returns the depth write.
Definition Material.h:340
void setTint(float r, float g, float b, float a=1.f)
Sets the tint.
Definition Material.cpp:124
Shader * getShader() const
Return the borrowed shader, or nullptr when the built-in path is active. @lifetime The pointer remain...
Definition Material.h:230
void setDepthWrite(bool enabled)
Sets the depth write.
Definition Material.h:338
std::string getShadingModel() const
Returns the shading model.
Definition Material.h:53
std::string getSurfaceMode() const
Returns the surface mode.
Definition Material.cpp:175
void setParallax(float scale, float minLayers=8.f, float maxLayers=32.f)
Sets the parallax.
Definition Material.cpp:143
float getAlbedoUvOffsetU() const
Current base-color UV offset U.
Definition Material.h:141
bool getCastShadow() const
Returns the cast shadow.
Definition Material.h:279
float getAlbedoUvRotation() const
Current base-color UV rotation in radians.
Definition Material.h:166
bool getReceiveLight() const
Returns the receive light.
Definition Material.h:274
void setFloat(const std::string &name, float value)
Sets the float.
Definition Material.cpp:207
float getAlbedoUvScaleV() const
Current base-color UV scale V.
Definition Material.h:156
void setSortPriority(int priority)
Sets the sort priority.
Definition Material.h:350
void setHair(bool hair)
Sets the hair.
Definition Material.cpp:152
Texture * getHeightTexture() const
Returns the height texture.
Definition Material.h:182
void setShader(Shader *shader)
Set an optional Mesh3D / hair shader; nullptr selects the built-in shading path.
Definition Material.h:227
void setDoubleSided(bool enabled)
Sets the double sided.
Definition Material.h:342
GPU mesh handle (+ optional CPU morph targets).
Definition Mesh.h:26
Screen-space model outline (t3ssel8r-style), computed from the GBuffer hardware depth + world-normal ...
Definition Outline.h:33
Pixel-space sub-rectangle of a Texture (atlas cell / sprite frame). UV conversion uses the texture's ...
Definition Quad.h:11
int getWidth() const
Returns the width.
Definition Quad.h:27
int getX() const
Returns the x.
Definition Quad.h:23
int getHeight() const
Returns the height.
Definition Quad.h:29
int getY() const
Returns the y.
Definition Quad.h:25
void setViewport(int x, int y, int w, int h)
Sets the viewport.
Definition Quad.cpp: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.
void setPostProcessQuality(const std::string &quality)
Set the unified post-process quality for TAA, RTGI and SSR.
void compile()
Rebuild the executable pass list from current feature flags.
bool isCompiled() const
True when compiled.
int getPassCount() const
Returns the pass count.
void enable(const std::string &feature)
Compatibility-only feature enablement; use requestFeature to observe failure.
std::string getReflectionQuality() const
Return the shared TAA/RTGI/SSR quality preset.
void disable(const std::string &feature)
Compatibility-only feature disablement; use requestFeature to observe failure.
bool isDeferredLightingAvailable() const
True when deferredLighting can be inserted for Hybrid. Requires an attached Graphics backend that imp...
std::string pathTracingDiagnostic() const
Owning diagnostic copy explaining the latest raster fallback.
std::string getPostProcessQuality() const
Return the unified post-process quality for TAA, RTGI and SSR.
bool hasHybridLightingFallback() const
True after compile() when Hybrid was requested but could not run (deferred lighting unavailable,...
bool isEnabled(const std::string &feature) const
True when enabled.
GBuffer * getGBuffer()
Returns the g buffer.
bool hasPass(const std::string &name) const
True when pass.
std::string getPassName(int index) const
Return the compiled pass name at index, or an empty string.
void setReflectionQuality(const std::string &quality)
Set the shared TAA/RTGI/SSR quality preset used by the automatic reflection chain.
bool supports(const std::string &feature) const
Supports.
static void setDirectionalLight(float dx, float dy, float dz, float r, float g, float b)
Legacy single directional light used when no enabled Light3D exists.
static void renderWithShadowsToCanvas(Graphics &gfx, Canvas &target, Camera3D &camera)
Render an editor preview with directional cascaded shadows before forward shading....
static void renderToCanvas(Graphics &gfx, Canvas *target, Camera3D *camera, uint32_t reflectionCaptureMask=0xffffffffu, float lodDistanceScale=1.f, bool includeTransparent=true, bool useClusteredLighting=true, Texture *skyFaceTexture=nullptr, Mesh *skyQuad=nullptr, float skyFaceTextureScale=1.f, bool includePrimitives=false)
Forward 3D pass into an offscreen canvas using multipart materials, LOD, masked surfaces and sorted t...
static void render(Graphics &gfx)
Renders .
Default renderable entity for declarative 2D sprites / solid quads.
void setCastOcclusion(bool cast)
Enable or disable volumetric occlusion casting.
void setVisible(bool visible)
Include or exclude the sprite from collection.
float getScaleY()
Return Y scale.
float getRotation()
Return center rotation in degrees.
void setBlend(const std::string &blend)
Set blend mode (alpha or additive).
void setScale(float sx, float sy)
Set independent X/Y scale.
void setPosition(float x, float y)
Set world-space position in pixels.
Texture * getTexture()
Return the assigned texture.
float getX()
Return world-space X position.
bool getReceiveLight()
Return whether the sprite receives 2D lights.
bool getFlipX()
Return horizontal mirror state.
void setNormalTexture(Texture *texture)
Assign an optional tangent-space normal map for the GPU lit2d path.
void setFrameLayout(int sourceW, int sourceH, int trimW, int trimH, int offsetX, int offsetY)
Apply trimmed-frame layout while preserving the original canvas origin.
void setRotation(float degrees)
Set center rotation in degrees.
void setLayer(int layer)
Set integer painter-order layer.
void setColor(float r, float g, float b, float a=1.f)
Set RGBA tint.
Quad * getQuad()
Return the assigned UV quad.
void setTexture(Texture *texture)
Assign the borrowed sprite texture.
float getScaleX()
Return X scale.
float getWidth()
Return unscaled width.
void setFlip(bool horizontal, bool vertical)
Mirror atlas UVs without changing transform scale.
Texture * getNormalTexture()
Return the assigned normal map, or nullptr when unlit/flat. @ownership Returns a borrowed Texture*; t...
std::string getBlend()
Return blend mode name.
bool getVisible()
Return whether the sprite is visible.
bool getCastOcclusion()
Return whether the sprite casts volumetric occlusion.
void setQuad(Quad *quad)
Assign the borrowed UV quad.
int getLayer()
Return painter-order layer.
void setAnchor(float x, float y)
Set normalized transform pivot; (0,0) top-left, (0.5,0.5) center.
float getAnchorY()
Return normalized vertical pivot.
float getY()
Return world-space Y position.
float getAnchorX()
Return normalized horizontal pivot.
void setSize(float width, float height)
Set unscaled sprite dimensions in pixels.
float getHeight()
Return unscaled height.
void setReceiveLight(bool receive)
Enable or disable 2D light reception.
bool getFlipY()
Return vertical mirror state.
Screen-space reflections (SSR) as a fullscreen post pass. @lifetime All Graphics and texture argument...
Custom GPU program.
Definition Shader.h:41
bool hasUniform(const std::string &name) const
Definition Shader.cpp:71
void sendVec2(const std::string &name, float x, float y)
Definition Shader.cpp:109
int declareVec2(const std::string &name)
Definition Shader.cpp:56
void sendFloat(const std::string &name, float x)
Definition Shader.cpp:107
void sendVec3(const std::string &name, float x, float y, float z)
Definition Shader.cpp:114
int declareMatrix(const std::string &name)
Definition Shader.cpp:59
int getUniformIndex(const std::string &name) const
Definition Shader.cpp:73
int declareVec3(const std::string &name)
Definition Shader.cpp:57
int declareVec4(const std::string &name)
Definition Shader.cpp:58
int declareFloat(const std::string &name)
Reserve sequential float slots in the push-constant block. Returns start index.
Definition Shader.cpp:55
void sendVec4(const std::string &name, float x, float y, float z, float w)
Definition Shader.cpp:119
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:15
int getMipmapCount() const
Returns the mipmap count.
Definition Texture.cpp:49
const char * getAlphaConvention() const
Returns the alpha convention spelling.
Definition Texture.cpp:58
void setAlphaConvention(const char *value)
Declare whether RGB is straight or already multiplied by alpha.
Definition Texture.cpp:54
int getWidth() const
Returns the width.
Definition Texture.cpp:29
int getHeight() const
Returns the height.
Definition Texture.cpp:34
Volumetric light + fog.
Definition Volumetric.h:38
void scatter(Graphics *gfx, Texture *occlusion)
Scatter-only: occlusion → shafts with alpha (draw over a prior scene). Writes to the currently bound ...
void scatterTo(Graphics *gfx, Texture *occlusion, Canvas *dest)
Same as scatter but into an explicit destination.
float getFloat(const std::string &name) const
Returns the float.
Shader * getCloudShader() const
Returns the cloud shader.
Definition Volumetric.h:329
void setFogNoise(float amount)
Sets the fog noise.
void drawOccluder(Graphics *gfx, Drawable *drawable, const glm::mat4 &matrix)
Drawable occlusion (respects Drawable::getCastOcclusion).
void setMode(const std::string &mode)
"screenspace" | "raymarch" | "fog" | "froxel" | "cloud".
void setCloudLightColor(float r, float g, float b)
Direct sunlight color used by cloud single scattering.
int getSampleCount() const
Returns the sample count.
void setLightScreenPos(float x, float y, float width, float height)
Pixel-space helper (converts with width/height).
void setFogEnd(float endDistance)
Sets the fog end.
void setCloudScale(float worldScale)
Horizontal size of procedural cloud features in world units.
void beginOcclusionMap(Graphics *gfx, float lightPixelX, float lightPixelY, float lightRadiusPixels=24.f)
Clear the current canvas to black and draw a bright light disc (start of an occlusion map)....
void setCloudLayer(float bottom, float top)
Set cloud layer world-space bottom and top heights.
void applyFromScene(Graphics *gfx, Texture *scene)
Single-pass: treat source as the scene (bright regions ≈ light), add shafts + dust/fog onto it....
void drawOccluders2D(Graphics *gfx)
Draw all visible Renderable2D with castOcclusion into the current canvas as black silhouettes (shadow...
void injectFroxelHeightFog(float extinction, float albedoR, float albedoG, float albedoB, float baseHeight, float heightFalloff, float minWorldY, float maxWorldY)
Inject an exponential global height layer into the froxel grid.
void rayMarchTo(Graphics *gfx, Texture *linearDepth, Canvas *dest)
Ray march to.
void uploadFroxel(Graphics *gfx)
Upload integrated froxels into a slice atlas sampled by applyFroxel.
void setFogHeightFalloff(float falloff)
Sets the fog height falloff.
void setCloudCoverage(float coverage)
Cloud cover fraction in [0,1].
float getDownscale() const
Returns the downscale.
Definition Volumetric.h:135
void setLightScreenUV(float u, float v)
Light position in UV (0..1), origin top-left to match 2D UVs.
void rayMarch(Graphics *gfx, Texture *linearDepth)
Ray march participating media using a linear-depth texture (R channel, 0=near .. 1=far)....
Shader * getShader() const
Returns the shader.
Definition Volumetric.h:323
void setCamera(float eyeX, float eyeY, float eyeZ, float targetX, float targetY, float targetZ, float upX, float upY, float upZ, float fovYDeg, float aspect, float nearZ, float farZ)
Camera for ray march reconstruction (RH + ZO). Builds inv(viewProj) and near/far used by rayMarch*.
std::string getMode() const
Returns the mode.
Definition Volumetric.h:56
void setIntensity(float intensity)
Sets the intensity.
void setAnisotropy(float g)
Henyey–Greenstein anisotropy for raymarch shafts in [-0.99, 0.99]. Positive values produce forward-sc...
bool hasParam(const std::string &name) const
True when param.
void injectFroxelLocalVolume(FogVolume *volume)
Inject an analytic local fog volume using the camera from setCamera().
std::string getQuality() const
Returns the quality.
Definition Volumetric.h:51
float getLightScreenU() const
Returns the light screen u.
void renderCloudsTo(Graphics *gfx, Texture *linearDepth, Canvas *dest)
Renders clouds to.
void setLightDirection(float dx, float dy, float dz)
World-space direction toward the lit surface (ray march / phase).
void applyFroxel(Graphics *gfx, Texture *linearDepth)
Composite the uploaded froxel volume over the current target using scene depth.
void setTime(float seconds)
Sets the time.
void renderClouds(Graphics *gfx, Texture *linearDepth)
Render the bounded cloud layer using scene linear depth for occlusion.
void setCloudWind(float x, float z)
Cloud wind velocity in world X/Z units per second.
void setFloat(const std::string &name, float value)
Sets the float.
void setShaftColor(float r, float g, float b)
Sets the shaft color.
void setQuality(const std::string &quality)
"low" | "medium" | "high" (unknown → medium).
void setFogHeight(float worldY)
Height fog: denser near world Y = fogHeight; falloff is 1/meters scale.
void integrateFroxel(float lightR, float lightG, float lightB, float phaseScale=1.f)
Integrate the current froxel media using a uniform incident light.
void applyFromSceneTo(Graphics *gfx, Texture *scene, Canvas *dest)
Applies from scene to.
float getLightScreenV() const
Returns the light screen v.
void configureFroxelGrid(int width, int height, int depth, float nearDistance, float farDistance)
Configure the CPU reference/fallback froxel grid used by the atlas renderer. Quality presets choose s...
void applyFogTo(Graphics *gfx, Texture *linearDepth, Canvas *dest)
Applies fog to.
void applyFroxelTo(Graphics *gfx, Texture *linearDepth, Canvas *dest)
Composite the uploaded froxel volume into an explicit destination.
void setDensity(float density)
Sets the density.
void drawOccluderTexture(Graphics *gfx, Texture *texture, float x, float y, float w, float h)
Draws occluder texture.
void setFogStart(float startDistance)
View-distance ramp where fog appears (world units along the ray).
void applyFog(Graphics *gfx, Texture *linearDepth)
Volumetric height/distance fog from a linear-depth texture. Writes fog RGB with alpha = 1-transmittan...
Shader * getRayMarchShader() const
Returns the ray march shader.
Definition Volumetric.h:325
void setCloudDensity(float density)
Cloud density multiplier, clamped non-negative.
void clearFroxelGrid()
Clear all media in the configured froxel grid.
void drawOccluderSolid(Graphics *gfx, float x, float y, float w, float h)
Convenience 2D black silhouette (solid or textured alpha).
float getAnisotropy() const
Current raymarch anisotropy.
int resolutionFor(int fullSize) const
Downscale helper: returns floor(dim / downscale), at least 1. Callers create occlusion / scatter canv...
Shader * getFogShader() const
Returns the fog shader.
Definition Volumetric.h:327
void setFogColor(float r, float g, float b)
Sets the fog color.
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:33
Runtime groom drawable (UE UGroomComponent analogue).
EVENGINE_API_BACKENDS public API.
Definition Graphics.h:360
EVENGINE_API_BACKENDS public API.
Definition Graphics.h:199
Represents raw pixel data.
Definition ImageData.h:38
Graphics-owned CPU resource provider for generated mesh artifacts.
const Value * field(const Value &value, const char *key)
Borrow an optional object field.
void rtBind(const char *kind, const char *name)
Rt bind.
Definition RenderTrace.h:69
void rtFrameBegin()
Rt frame begin.
Definition RenderTrace.h:49
void rtFrameEnd()
Rt frame end.
Definition RenderTrace.h:53
void rtDraw(const char *api, const char *detail=nullptr)
Rt draw.
Definition RenderTrace.h:73
eve::Diagnostic Diagnostic
eve::Result< T > Result
void exposeRenderable3DBindings(ssq::Table &table)
Expose renderable 3 d bindings.
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
Shader * createTreeWindShader(Graphics *graphics)
Create a backend-native tree Mesh3D shader using the engine PBR fragment stage.
Result< int > calculateWaterMeshTriangles(const WaterMeshSettings &settings)
Calculate Pcg PWS_WaterSystem's triangle count without allocating a mesh.
Definition Water.cpp:150
void exposePrimitiveScriptBindings(ssq::Table &table, ssq::Class &cls)
Registers owning primitive proxies on the VM owner thread; retains no table references.
void exposeWaterReflectionMaskerBindings(ssq::Table &table)
Register Pcg reflection-mask bindings.
Definition Water.cpp:707
void exposeGrassWindBindings(ssq::Table &table)
Register wind state/profile and checked operations on the VM owner thread, retaining no table referen...
Definition GrassWind.cpp:76
eve::Color Color
RGBA color used by every graphics draw call. Lives inside eve::graphics so including a graphics heade...
Definition Color.h:13
void exposeGraphicsMeshes(ssq::Table &table)
Register mesh script bindings; table is borrowed synchronously.
void exposeWaterPlanarReflectionBindings(ssq::Table &table)
Register planar water-reflection value types and checked planner with the VM owner thread.
Definition Water.cpp:550
uint32_t nextCodepointUtf8(const std::string &text, size_t &i)
Decodes one UTF-8 codepoint from text starting at byte offset i, advancing i past it....
Definition Font.cpp:17
void exposeCanvasScriptBindings(ssq::Table &table)
Register canvas bindings on the VM owner thread; retains no table reference.
Definition Canvas.cpp:15
WaterMeshType
Pcg procedural water mesh shape. Custom meshes remain caller-supplied Mesh resources.
Definition Water.h:14
void exposeShaderScriptBindings(ssq::Table &table, ssq::Class &cls)
Register shader loading and binary replacement on the VM owner thread. Borrows both tables for this c...
void detachGraphicsArtifactProvider(Graphics *graphics) noexcept
Detach a Graphics instance before its derived backend is destroyed.
void exposeWaterSystemBindings(ssq::Table &table)
Register water-system value types and checked operations with the VM owner thread.
void exposeDepthOfFieldFocusBindings(ssq::Table &table)
Register Pcg autofocus value types and evaluator.
void exposeWaterUnderwaterEffectsBindings(ssq::Table &table)
Register underwater-effects value types and checked transition with the VM owner thread.
void exposeFontAndDamageNumberBindings(ssq::Table &table, ssq::Class &graphicsClass)
Register font and popup script types on the VM owner thread; retain no table references.
int clampShadowMapSize(int size)
Clamp/round a requested map size to an allowed power-of-two.
Definition Shadow.cpp:218
void registerGraphicsArtifactProvider(Graphics *graphics)
Register the graphics provider in the common capability registry.
Result< void > setShadowSchemeMapSizes(int directionalMapSize, int localMapSize)
Apply directional (and optional local) map sizes with validation. @cost Cheap CPU clamp; GPU recreate...
Definition Shadow.cpp:253
void exposePcgWaterPhotoModeBindings(ssq::Table &t)
Register Pcg water photo-mode authority bindings.
Result< void > setShadowSchemeDirectionalMaxDistance(float meters)
Apply CSM max distance with validation.
Definition Shadow.cpp:269
void registerGraphicsCapabilities()
Registers graphics capabilities.
void exposeVegetationScriptBindings(ssq::Table &table, ssq::Class &graphicsClass)
Register vegetation field bindings on the VM owner thread. Borrows tables for this call; no script ca...
std::unordered_map< std::string, SkillDefinition > & table()
Definition Skill.cpp:73
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
DiagnosticCode
Stable machine-readable diagnostic codes.
Definition Diagnostic.h:47
std::optional< std::reference_wrapper< T > > OptionalRef
Optional borrowed reference; it does not extend T's lifetime.
Definition BorrowedRef.h:24
glm::vec4 Color
Render-neutral RGBA color shared by graphics-facing modules.
Definition RenderTypes.h:8
bool enabled
Glyph public API.
Definition Font.h:67
DeferredFileTexture public API.
Definition Graphics.h:2292
Linear RGB triple used by scene color-grade getters/setters.
Definition GraphicsRgb.h:11
Options for Graphics::newTexture / newCubemap. When generateMipmaps is true and sampler....
Sampler state for a Texture (filter, wrap, mip LOD, anisotropy). Defaults match historical engine beh...
glm::vec4 ambient
glm::uvec4 info
glm::vec4 color