载入中...
搜索中...
未找到
Graphics.cpp
浏览该文件的文档.
1#include "graphics/Graphics.h"
2#include "common/Capability.h"
4#include "common/config.h"
5#include "font/FontData.h"
7#include "graphics/Bloom.h"
11#include "graphics/Exposure.h"
13#include "graphics/Grass.h"
14#include "graphics/HairCards.h"
15#include "graphics/HairShader.h"
16#include "graphics/TreeWind.h"
18
19#ifdef EVENGINE_WEBGPU
21#else
23#endif
24#include "graphics/AlphaMask.h"
28#include "graphics/FogVolume.h"
29#include "graphics/Font.h"
30#include "graphics/GBuffer.h"
32#include "graphics/GrassWind.h"
33#include "graphics/Light.h"
35#include "graphics/MapFog.h"
36#include "graphics/Material.h"
37#include "graphics/Mesh.h"
38#include "graphics/Outline.h"
42#include "graphics/Quad.h"
51#include "graphics/Texture.h"
53#include "graphics/Volumetric.h"
54#include "graphics/Water.h"
59#include "graphics/Waterfall.h"
60#include "image/ImageData.h"
61
62#ifndef EVENGINE_WEBGPU
63#include "font/FontData.h"
64#endif
65#include "common/Diagnostic.h"
66#include "common/Exception.h"
67#include "common/RenderTrace.h"
68#include "common/Resource.h"
73#include "image/Image.h"
74#include "image/ImageData.h"
75
76
77#include <simplesquirrel/simplesquirrel.hpp>
78
79#include <algorithm>
80#include <cstdint>
81#include <filesystem>
82#include <fstream>
83#include <functional>
84#include <glm/gtc/type_ptr.hpp>
85#include <memory>
86
87namespace eve::graphics {
88
89namespace {
90
91
92bool copyArrayFloats(ssq::Array arr, std::vector<float>& out) {
93 const size_t n = arr.size();
94 out.resize(n);
95 for (size_t i = 0; i < n; ++i) out[i] = arr.get<float>(i);
96 return n > 0;
97}
98
99bool copyArrayUints(ssq::Array arr, std::vector<uint32_t>& out) {
100 const size_t n = arr.size();
101 out.resize(n);
102 for (size_t i = 0; i < n; ++i) out[i] = static_cast<uint32_t>(arr.get<int>(i));
103 return n > 0;
104}
105
106Mesh* newMeshFromArraysScript(Graphics* gfx, ssq::Array posArr, ssq::Array nrmArr, ssq::Array uvArr, int vertexCount,
107 ssq::Array idxArr, int indexCount) {
108 std::vector<float> pos, nrm, uv;
109 std::vector<uint32_t> idx;
110 copyArrayFloats(posArr, pos);
111 copyArrayFloats(nrmArr, nrm);
112 copyArrayFloats(uvArr, uv);
113 copyArrayUints(idxArr, idx);
114 return gfx->newMeshFromArrays(pos.data(), nrm.empty() ? nullptr : nrm.data(), uv.empty() ? nullptr : uv.data(),
115 vertexCount, idx.empty() ? nullptr : idx.data(), indexCount);
116}
117
118bool updateMeshVerticesScript(Graphics* gfx, Mesh* mesh, ssq::Array posArr, ssq::Array nrmArr, ssq::Array uvArr,
119 int vertexCount, ssq::Array idxArr, int indexCount) {
120 std::vector<float> pos, nrm, uv;
121 std::vector<uint32_t> idx;
122 copyArrayFloats(posArr, pos);
123 copyArrayFloats(nrmArr, nrm);
124 copyArrayFloats(uvArr, uv);
125 copyArrayUints(idxArr, idx);
126 return gfx->updateMeshVertices(mesh, pos.data(), nrm.empty() ? nullptr : nrm.data(),
127 uv.empty() ? nullptr : uv.data(), vertexCount, idx.empty() ? nullptr : idx.data(),
128 indexCount);
129}
130
131void setMesh3DViewProjScript(Graphics* gfx, ssq::Array a) {
132 if (a.size() != 16) throw eve::Exception("setMesh3DViewProj: expected 16 floats");
133 glm::mat4 m(1.f);
134 for (size_t i = 0; i < 16; ++i) glm::value_ptr(m)[i] = a.get<float>(i);
135 gfx->setMesh3DViewProj(m);
136}
137
138void setMesh3DViewScript(Graphics* gfx, ssq::Array a) {
139 if (a.size() != 16) throw eve::Exception("setMesh3DView: 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->setMesh3DView(m);
143}
144
145void setMesh3DCameraPosScript(Graphics* gfx, float x, float y, float z) { gfx->setMesh3DCameraPos(glm::vec3(x, y, z)); }
146
147void setCanvasScript(Graphics* gfx, ssq::Object obj) {
148 if (obj.isNull()) {
149 gfx->setCanvas(nullptr);
150 return;
151 }
152 gfx->setCanvas(obj.toPtrUnsafe<Canvas*>());
153}
154
155void setShaderScript(Graphics* gfx, ssq::Object obj) {
156 if (obj.isNull()) {
157 gfx->setShader();
158 return;
159 }
160 gfx->setShader(obj.toPtrUnsafe<Shader*>());
161}
162
163} // namespace
164
166 primitiveScene_ = std::make_shared<PrimitiveScene>();
167 // The window module owns the native window; we own the render surface.
168 // Register as its surface host so window never has to include graphics.
169 // The query happens after native window creation, so this pointer is valid
170 // by the time it is used; see common/WindowSurfaceHost.h.
171 eve::cap::provide<IWindowSurfaceHost>(this);
172 eve::cap::provide<IFramePresentation>(this);
175}
176
178 eve::cap::revoke<IFramePresentation>(this);
180 // Derived backends detach first, while their virtual releaseMesh boundary
181 // is still live. This base path covers host-only Graphics subclasses.
183 // Out-of-line so unique_ptr members of effect classes (Outline, AO, GI, …)
184 // are destroyed where the complete types are visible.
185}
186
187#ifdef EVENGINE_WEBGPU
189#else
191#endif
192
202
208
210 if (!scene) return nullptr;
212 const bool doAA = !renderControl_ || renderControl_->isEnabled("aa") || renderControl_->isEnabled("taa");
213 aa->setMode("fxaa");
214 if (doAA) {
215 const std::string requested = renderControl_ ? renderControl_->getPostProcessQuality() : "high";
216 const std::string quality = requested == "ultra" ? "high" : requested;
217 if (aa->getQuality() != quality) aa->setQuality(quality);
218 } else {
219 if (aa->getMode() == "fxaa") {
220 aa->setFloat("edgeThreshold", 1.f);
221 aa->setFloat("edgeThresholdMin", 1.f);
222 aa->setFloat("subpix", 0.f);
223 }
224 }
225 aa->prepareSource(scene);
226 return aa->getShader();
227}
228
229void Graphics::drawScene3DRGBA(float x, float y, float w, float h, float r, float g, float b, float a) {
231 if (!scene) return;
232 // Queue a scene-color blit at this 2D overlay slot so present() owns
233 // AA/Bloom/Exposure + ACES. Running prepareFinalSceneTexture here would
234 // setCanvas() (ending the still-open scene pass and queueing auto-resolve)
235 // then blit the HDR result through the LDR textured pipeline *on top of*
236 // the auto ACES composite — two fullscreen 3D quads that strobe.
237 drawTexturedRectShaderUV(scene, nullptr, x, y, w, h, 0.f, 0.f, 1.f, 1.f, Color(r, g, b, a), false,
239}
240
241void Graphics::drawCanvasRGBA(Canvas* canvas, float x, float y, float w, float h, float r, float g, float b, float a) {
242 if (!canvas) return;
243 Texture* tex = canvas->getTexture();
244 if (!tex) return;
245 drawTexturedRect(tex, x, y, w, h, Color(r, g, b, a));
246}
247
248void Graphics::setDirectionalLight(float dx, float dy, float dz, float r, float g, float b) {
250}
251
253
255 if (!renderControl_) {
256 renderControl_ = std::make_unique<RenderControl>();
257 renderControl_->attach(this);
258 // Phase D: desktop→Hybrid when deferred is available; CI/mobile stay ForwardPlus.
259 // Explicit EVENGINE_LIGHTING_MODE overrides the suggested preset.
260 auto applied = renderControl_->applySuggestedLightingPreset();
261 applied.ignore();
262 renderControl_->compile();
263 }
264 return renderControl_.get();
265}
266
267void Graphics::expose(ssq::Table& table) {
268 auto cls = table.addClass(name, Graphics::create, false);
269 expose(cls);
270
274 auto depthOfField = table.addClass<DepthOfField>(
275 "DepthOfField", std::function<DepthOfField*()>([]() -> DepthOfField* { return nullptr; }), true);
276 depthOfField.addFunc("apply", &DepthOfField::apply);
285
286#ifndef EVENGINE_WEBGPU
287 auto fontCls =
288 table.addClass<Font>("GraphicsFont", std::function<Font*()>([]() -> Font* { return nullptr; }), true);
289 fontCls.addFunc("getHeight", &Font::getHeight);
290 fontCls.addFunc("getAscent", &Font::getAscent);
291 fontCls.addFunc("getBaseline", &Font::getBaseline);
292 fontCls.addFunc("getWidth", &Font::getWidth);
293 fontCls.addFunc("hasGlyph", &Font::hasGlyph);
294#endif
295
296 auto maskCls = table.addClass<AlphaMask>("AlphaMask",
297 std::function<AlphaMask*()>([]() -> AlphaMask* { return nullptr; }), true);
298 maskCls.addFunc("setThreshold", &AlphaMask::setThreshold);
299 maskCls.addFunc("getThreshold", &AlphaMask::getThreshold);
300 maskCls.addFunc("setSoftness", &AlphaMask::setSoftness);
301 maskCls.addFunc("getSoftness", &AlphaMask::getSoftness);
302 maskCls.addFunc("setInverted", &AlphaMask::setInverted);
303 maskCls.addFunc("getInverted", &AlphaMask::getInverted);
304 maskCls.addFunc("draw", &AlphaMask::draw);
305
306 auto mapFogCls =
307 table.addClass<MapFog>("MapFog", std::function<MapFog*()>([]() -> MapFog* { return nullptr; }), true);
308 mapFogCls.addFunc("update", &MapFog::update);
309 mapFogCls.addFunc("setTime", &MapFog::setTime);
310 mapFogCls.addFunc("getTime", &MapFog::getTime);
311 mapFogCls.addFunc("setCloudTexture", &MapFog::setCloudTexture);
312 mapFogCls.addFunc("getCloudTexture", &MapFog::getCloudTexture);
313 mapFogCls.addFunc("setMaskTexture", &MapFog::setMaskTexture);
314 mapFogCls.addFunc("getMaskTexture", &MapFog::getMaskTexture);
315 mapFogCls.addFunc("setCloudTiling", &MapFog::setCloudTiling);
316 mapFogCls.addFunc("setCloudSpeed", &MapFog::setCloudSpeed);
317 mapFogCls.addFunc("setDistort", &MapFog::setDistort);
318 mapFogCls.addFunc("setDistortFix", &MapFog::setDistortFix);
319 mapFogCls.addFunc("setFogColor", &MapFog::setFogColor);
320 mapFogCls.addFunc("setFogAlpha", &MapFog::setFogAlpha);
321 mapFogCls.addFunc("setEdgeSoftness", &MapFog::setEdgeSoftness);
322 mapFogCls.addFunc("setShadowEnabled", &MapFog::setShadowEnabled);
323 mapFogCls.addFunc("setShadow", &MapFog::setShadow);
324 mapFogCls.addFunc("setSelectStrength", &MapFog::setSelectStrength);
325 mapFogCls.addFunc("setDissolveScale", &MapFog::setDissolveScale);
326 mapFogCls.addFunc("setCloudMix", &MapFog::setCloudMix);
327 mapFogCls.addFunc("setCloudDensity", &MapFog::setCloudDensity);
328 mapFogCls.addFunc("getCloudTileA", &MapFog::getCloudTileA);
329 mapFogCls.addFunc("getCloudTileB", &MapFog::getCloudTileB);
330 mapFogCls.addFunc("getFogAlpha", &MapFog::getFogAlpha);
331 mapFogCls.addFunc("getShadowEnabled", &MapFog::getShadowEnabled);
332 mapFogCls.addFunc("makeCloudTexture", &MapFog::makeCloudTexture);
333 mapFogCls.addFunc("draw", &MapFog::draw);
334
335 auto texCls =
336 table.addClass<Texture>("Texture", std::function<Texture*()>([]() -> Texture* { return nullptr; }), true);
337 texCls.addFunc("setCastOcclusion", &Texture::setCastOcclusion);
338 texCls.addFunc("getCastOcclusion", &Texture::getCastOcclusion);
339 texCls.addFunc("getWidth", &Texture::getWidth);
340 texCls.addFunc("getHeight", &Texture::getHeight);
341 texCls.addFunc("getMipmapCount", &Texture::getMipmapCount);
342 texCls.addFunc("setAlphaConvention", &Texture::setAlphaConvention);
343 texCls.addFunc("getAlphaConvention", &Texture::getAlphaConvention);
344
345 // Texture / Mesh expose occlusion flags used by volumetric light shafts.
346 // (create returns null — instances come from Graphics::newTexture / newMesh*)
347
348 auto meshCls = table.addClass<Mesh>("Mesh", std::function<Mesh*()>([]() -> Mesh* { return nullptr; }), true);
349 meshCls.addFunc("getVertexCount", &Mesh::getVertexCount);
350 meshCls.addFunc("getIndexCount", std::function<int(Mesh*)>([](Mesh* mesh) { return mesh->indexCount; }));
351 meshCls.addFunc("getMorphCount", &Mesh::getMorphCount);
352 meshCls.addFunc("getMorphName", &Mesh::getMorphName);
353 meshCls.addFunc("hasMorph", &Mesh::hasMorph);
354 meshCls.addFunc("setMorphWeight", &Mesh::setMorphWeight);
355 meshCls.addFunc("getMorphWeight", &Mesh::getMorphWeight);
356 meshCls.addFunc("clearMorphWeights", &Mesh::clearMorphWeights);
357 meshCls.addFunc("hasMorphData", &Mesh::hasMorphData);
358 meshCls.addFunc("isMorphDirty", &Mesh::isMorphDirty);
359 meshCls.addFunc("setCastOcclusion", &Mesh::setCastOcclusion);
360 meshCls.addFunc("getCastOcclusion", &Mesh::getCastOcclusion);
361
362 auto quad = table.addClass<Quad>("Quad", std::function<Quad*()>([]() -> Quad* { return nullptr; }), true);
363 quad.addFunc("setViewport", &Quad::setViewport);
364 quad.addFunc("getX", &Quad::getX);
365 quad.addFunc("getY", &Quad::getY);
366 quad.addFunc("getWidth", &Quad::getWidth);
367 quad.addFunc("getHeight", &Quad::getHeight);
368
369 auto shader = table.addClass<Shader>("Shader", std::function<Shader*()>([]() -> Shader* { return nullptr; }), true);
370 shader.addFunc("declareFloat", &Shader::declareFloat);
371 shader.addFunc("declareVec2", &Shader::declareVec2);
372 shader.addFunc("declareVec3", &Shader::declareVec3);
373 shader.addFunc("declareVec4", &Shader::declareVec4);
374 shader.addFunc("declareMatrix", &Shader::declareMatrix);
375 shader.addFunc("sendFloat", &Shader::sendFloat);
376 shader.addFunc("sendVec2", &Shader::sendVec2);
377 shader.addFunc("sendVec3", &Shader::sendVec3);
378 shader.addFunc("sendVec4", &Shader::sendVec4);
379 shader.addFunc("setMeshTexture", [](Shader* self, int slot, Texture* texture) {
380 if (slot < 0) throw Exception("Shader.setMeshTexture: slot must be in [0,4)");
381 auto result = self->setMeshTexture(static_cast<std::size_t>(slot), texture);
382 if (!result) throw Exception("Shader.setMeshTexture: slot must be in [0,4)");
383 });
384 shader.addFunc("hasUniform", &Shader::hasUniform);
385 shader.addFunc("getUniformIndex", &Shader::getUniformIndex);
386
387 // ECS entities live in the registry buffer (not standalone new/delete).
388 // Squirrel must not delete them on VM shutdown or close asserts
389 // _CrtIsValidHeapPointer.
390 auto cam2d = table.addClass<Camera2D>("Camera2D",
391 std::function<Camera2D*()>([]() { return Camera2D::createCamera(); }), false);
392 cam2d.addFunc("setAmbient", &Camera2D::setAmbient);
393 cam2d.addFunc("setPosition", &Camera2D::setPosition);
394 cam2d.addFunc("getX", &Camera2D::getX);
395 cam2d.addFunc("getY", &Camera2D::getY);
396 cam2d.addFunc("setZoom", &Camera2D::setZoom);
397 cam2d.addFunc("getZoom", &Camera2D::getZoom);
398 cam2d.addFunc("screenToWorldX", &Camera2D::screenToWorldX);
399 cam2d.addFunc("screenToWorldY", &Camera2D::screenToWorldY);
400 cam2d.addFunc("worldToScreenX", &Camera2D::worldToScreenX);
401 cam2d.addFunc("worldToScreenY", &Camera2D::worldToScreenY);
402
403 auto light = table.addClass<Light2D>(
404 "Light2D", std::function<Light2D*()>([]() { return Light2D::createLight("point"); }), false);
405 light.addFunc("setType", &Light2D::setType);
406 light.addFunc("getType", &Light2D::getType);
407 light.addFunc("setPosition", &Light2D::setPosition);
408 light.addFunc("getX", &Light2D::getX);
409 light.addFunc("getY", &Light2D::getY);
410 light.addFunc("setDirection", &Light2D::setDirection);
411 light.addFunc("getDirX", &Light2D::getDirX);
412 light.addFunc("getDirY", &Light2D::getDirY);
413 light.addFunc("setColor", &Light2D::setColor);
414 light.addFunc("setRadius", &Light2D::setRadius);
415 light.addFunc("getRadius", &Light2D::getRadius);
416 light.addFunc("setSpotAngle", &Light2D::setSpotAngle);
417 light.addFunc("getSpotAngle", &Light2D::getSpotAngle);
418 light.addFunc("setSpotSoftness", &Light2D::setSpotSoftness);
419 light.addFunc("getSpotSoftness", &Light2D::getSpotSoftness);
420 light.addFunc("setEnabled", &Light2D::setEnabled);
421 light.addFunc("isEnabled", &Light2D::isEnabled);
422 light.addFunc("setVolumetric", &Light2D::setVolumetric);
423 light.addFunc("getVolumetric", &Light2D::getVolumetric);
424 light.addFunc("setVolumetricIntensity", &Light2D::setVolumetricIntensity);
425 light.addFunc("getVolumetricIntensity", &Light2D::getVolumetricIntensity);
426 light.addFunc("setVolumetricOnly", &Light2D::setVolumetricOnly);
427 light.addFunc("getVolumetricOnly", &Light2D::getVolumetricOnly);
428 light.addFunc("setCanvas", &Light2D::setCanvas);
429 table.addFunc("createEmissiveLight2D",
430 std::function<Light2D *(float, float, float, float, float, float, float)>(
431 [](float x, float y, float r, float g, float b, float intensity, float radius) {
432 return Light2D::createEmissiveProxy(x, y, r, g, b, intensity, radius);
433 }));
434
435 auto cam = table.addClass<Camera3D>("Camera3D",
436 std::function<Camera3D*()>([]() { return Camera3D::createCamera(); }), false);
437 cam.addFunc("setEye", &Camera3D::setEye);
438 cam.addFunc("getEyeX", &Camera3D::getEyeX);
439 cam.addFunc("getEyeY", &Camera3D::getEyeY);
440 cam.addFunc("getEyeZ", &Camera3D::getEyeZ);
441 cam.addFunc("setTarget", &Camera3D::setTarget);
442 cam.addFunc("getTargetX", &Camera3D::getTargetX);
443 cam.addFunc("getTargetY", &Camera3D::getTargetY);
444 cam.addFunc("getTargetZ", &Camera3D::getTargetZ);
445 cam.addFunc("setUp", &Camera3D::setUp);
446 cam.addFunc("setFov", &Camera3D::setFov);
447 cam.addFunc("getFov", &Camera3D::getFov);
448 cam.addFunc("setOrthographic", &Camera3D::setOrthographic);
449 cam.addFunc("setPerspective", &Camera3D::setPerspective);
450 cam.addFunc("setClipPlanes", &Camera3D::setClipPlanes);
451 cam.addFunc("getNearClip", &Camera3D::getNearClip);
452 cam.addFunc("getFarClip", &Camera3D::getFarClip);
453 cam.addFunc("setPhysicalLens", &Camera3D::setPhysicalLens);
454 cam.addFunc("getAperture", &Camera3D::getAperture);
455 cam.addFunc("getFocalLength", &Camera3D::getFocalLength);
456 cam.addFunc("setLayerCullDistance", &Camera3D::setLayerCullDistance);
457 cam.addFunc("getLayerCullDistance", &Camera3D::getLayerCullDistance);
458 cam.addFunc("setShadowLayerCullDistance", &Camera3D::setShadowLayerCullDistance);
459 cam.addFunc("getShadowLayerCullDistance", &Camera3D::getShadowLayerCullDistance);
460 cam.addFunc("setActive", &Camera3D::setActive);
461 cam.addFunc("setAmbient", &Camera3D::setAmbient);
462 cam.addFunc("setEnvMap", &Camera3D::setEnvMap);
463 cam.addFunc("setEnvIntensity", &Camera3D::setEnvIntensity);
464 cam.addFunc("setExposure", &Camera3D::setExposure);
465 cam.addFunc("getExposure", &Camera3D::getExposure);
466 cam.addFunc("setAutoExposure", &Camera3D::setAutoExposure);
467 cam.addFunc("isAutoExposure", &Camera3D::isAutoExposure);
468 cam.addFunc("setBloom", &Camera3D::setBloom);
469 cam.addFunc("getBloomIntensity", &Camera3D::getBloomIntensity);
470 cam.addFunc("getBloomThreshold", &Camera3D::getBloomThreshold);
471 cam.addFunc("setDepthOfField", &Camera3D::setDepthOfField);
472 cam.addFunc("clearDepthOfField", &Camera3D::clearDepthOfField);
473 cam.addFunc("getDofFocusDistance", &Camera3D::getDofFocusDistance);
474 cam.addFunc("getDofMaxBlur", &Camera3D::getDofMaxBlur);
475 cam.addFunc("getDofFocusRange", &Camera3D::getDofFocusRange);
476 cam.addFunc("setEnvProbe", &Camera3D::setEnvProbe);
477 cam.addFunc("clearEnvProbe", &Camera3D::clearEnvProbe);
478 cam.addFunc("hasEnvProbe", &Camera3D::hasEnvProbe);
479 cam.addFunc("getEnvProbeCenterX", &Camera3D::getEnvProbeCenterX);
480 cam.addFunc("getEnvProbeCenterY", &Camera3D::getEnvProbeCenterY);
481 cam.addFunc("getEnvProbeCenterZ", &Camera3D::getEnvProbeCenterZ);
482 cam.addFunc("getEnvProbeExtentX", &Camera3D::getEnvProbeExtentX);
483 cam.addFunc("getEnvProbeExtentY", &Camera3D::getEnvProbeExtentY);
484 cam.addFunc("getEnvProbeExtentZ", &Camera3D::getEnvProbeExtentZ);
485 cam.addFunc("setReflectionProbe", &Camera3D::setReflectionProbe);
486 cam.addFunc("clearReflectionProbe", &Camera3D::clearReflectionProbe);
487 cam.addFunc("getReflectionProbeCount", &Camera3D::getReflectionProbeCount);
488 cam.addFunc("screenToRay", &Camera3D::screenToRay);
489 cam.addFunc("getScreenRayOriginX", &Camera3D::getScreenRayOriginX);
490 cam.addFunc("getScreenRayOriginY", &Camera3D::getScreenRayOriginY);
491 cam.addFunc("getScreenRayOriginZ", &Camera3D::getScreenRayOriginZ);
492 cam.addFunc("getScreenRayDirX", &Camera3D::getScreenRayDirX);
493 cam.addFunc("getScreenRayDirY", &Camera3D::getScreenRayDirY);
494 cam.addFunc("getScreenRayDirZ", &Camera3D::getScreenRayDirZ);
495
496 auto light3d = table.addClass<Light3D>(
497 "Light3D", std::function<Light3D*()>([]() { return Light3D::createLight("point"); }), false);
498 light3d.addFunc("setType", &Light3D::setType);
499 light3d.addFunc("getType", &Light3D::getType);
500 light3d.addFunc("setPosition", &Light3D::setPosition);
501 light3d.addFunc("getX", &Light3D::getX);
502 light3d.addFunc("getY", &Light3D::getY);
503 light3d.addFunc("getZ", &Light3D::getZ);
504 light3d.addFunc("setDirection", &Light3D::setDirection);
505 light3d.addFunc("getDirX", &Light3D::getDirX);
506 light3d.addFunc("getDirY", &Light3D::getDirY);
507 light3d.addFunc("getDirZ", &Light3D::getDirZ);
508 light3d.addFunc("setColor", &Light3D::setColor);
509 light3d.addFunc("setRadius", &Light3D::setRadius);
510 light3d.addFunc("getRadius", &Light3D::getRadius);
511 light3d.addFunc("setSpotAngle", &Light3D::setSpotAngle);
512 light3d.addFunc("getSpotAngle", &Light3D::getSpotAngle);
513 light3d.addFunc("setSpotSoftness", &Light3D::setSpotSoftness);
514 light3d.addFunc("getSpotSoftness", &Light3D::getSpotSoftness);
515 light3d.addFunc("setEnabled", &Light3D::setEnabled);
516 light3d.addFunc("isEnabled", &Light3D::isEnabled);
517 light3d.addFunc("setCastShadow", &Light3D::setCastShadow);
518 light3d.addFunc("getCastShadow", &Light3D::getCastShadow);
519 light3d.addFunc("setShadowMethod", &Light3D::setShadowMethod);
520 light3d.addFunc("getShadowMethod", &Light3D::getShadowMethod);
521 light3d.addFunc("setShadowBias", &Light3D::setShadowBias);
522 light3d.addFunc("getShadowBias", &Light3D::getShadowBias);
523 light3d.addFunc("setShadowStrength", &Light3D::setShadowStrength);
524 light3d.addFunc("getShadowStrength", &Light3D::getShadowStrength);
525 light3d.addFunc("setVolumetric", &Light3D::setVolumetric);
526 light3d.addFunc("getVolumetric", &Light3D::getVolumetric);
527 light3d.addFunc("setVolumetricIntensity", &Light3D::setVolumetricIntensity);
528 light3d.addFunc("getVolumetricIntensity", &Light3D::getVolumetricIntensity);
529 light3d.addFunc("setVolumetricOnly", &Light3D::setVolumetricOnly);
530 light3d.addFunc("getVolumetricOnly", &Light3D::getVolumetricOnly);
531 table.addFunc("createEmissiveLight3D",
532 std::function<Light3D *(float, float, float, float, float, float, float, float)>(
533 [](float x, float y, float z, float r, float g, float b, float intensity,
534 float radius) {
535 return Light3D::createEmissiveProxy(x, y, z, r, g, b, intensity, radius);
536 }));
538
539 auto sprite2d = table.addClass<Renderable2D>(
540 "Sprite2D", std::function<Renderable2D*()>([]() { return Renderable2D::create(); }), false);
541 sprite2d.addFunc("setPosition", &Renderable2D::setPosition);
542 sprite2d.addFunc("getX", &Renderable2D::getX);
543 sprite2d.addFunc("getY", &Renderable2D::getY);
544 sprite2d.addFunc("setRotation", &Renderable2D::setRotation);
545 sprite2d.addFunc("getRotation", &Renderable2D::getRotation);
546 sprite2d.addFunc("setScale", &Renderable2D::setScale);
547 sprite2d.addFunc("getScaleX", &Renderable2D::getScaleX);
548 sprite2d.addFunc("getScaleY", &Renderable2D::getScaleY);
549 sprite2d.addFunc("setSize", &Renderable2D::setSize);
550 sprite2d.addFunc("getWidth", &Renderable2D::getWidth);
551 sprite2d.addFunc("getHeight", &Renderable2D::getHeight);
552 sprite2d.addFunc("setTexture", &Renderable2D::setTexture);
553 sprite2d.addFunc("getTexture", &Renderable2D::getTexture);
554 sprite2d.addFunc("setNormalTexture", &Renderable2D::setNormalTexture);
555 sprite2d.addFunc("getNormalTexture", &Renderable2D::getNormalTexture);
556 sprite2d.addFunc("setQuad", &Renderable2D::setQuad);
557 sprite2d.addFunc("getQuad", &Renderable2D::getQuad);
558 sprite2d.addFunc("setColor", &Renderable2D::setColor);
559 sprite2d.addFunc("setLayer", &Renderable2D::setLayer);
560 sprite2d.addFunc("getLayer", &Renderable2D::getLayer);
561 sprite2d.addFunc("setVisible", &Renderable2D::setVisible);
562 sprite2d.addFunc("getVisible", &Renderable2D::getVisible);
563 sprite2d.addFunc("setReceiveLight", &Renderable2D::setReceiveLight);
564 sprite2d.addFunc("getReceiveLight", &Renderable2D::getReceiveLight);
565 sprite2d.addFunc("setBlend", &Renderable2D::setBlend);
566 sprite2d.addFunc("getBlend", &Renderable2D::getBlend);
567 sprite2d.addFunc("setAnchor", &Renderable2D::setAnchor);
568 sprite2d.addFunc("getAnchorX", &Renderable2D::getAnchorX);
569 sprite2d.addFunc("getAnchorY", &Renderable2D::getAnchorY);
570 sprite2d.addFunc("setFlip", &Renderable2D::setFlip);
571 sprite2d.addFunc("getFlipX", &Renderable2D::getFlipX);
572 sprite2d.addFunc("getFlipY", &Renderable2D::getFlipY);
573 sprite2d.addFunc("setFrameLayout", &Renderable2D::setFrameLayout);
574 sprite2d.addFunc("setCastOcclusion", &Renderable2D::setCastOcclusion);
575 sprite2d.addFunc("getCastOcclusion", &Renderable2D::getCastOcclusion);
576 sprite2d.addFunc("destroy", [](Renderable2D* self) { self->release(); });
577
578 auto material =
579 table.addClass<Material>("Material", std::function<Material*()>([]() -> Material* { return nullptr; }), true);
580 material.addFunc("setShadingModel", &Material::setShadingModel);
581 material.addFunc("getShadingModel", &Material::getShadingModel);
582 material.addFunc(
583 "setFoliageTranslucency",
584 [vm = table.getHandle()](Material* self, float red, float green, float blue, float intensity, float strength,
585 float normalDistortion, float scattering, float direct, float ambient, float shadow) {
586 return eve::script::projectResult(
587 vm, self->setFoliageTranslucency(red, green, blue, intensity, strength, normalDistortion, scattering,
588 direct, ambient, shadow));
589 });
590 material.addFunc("setFoliageWindTime", [vm = table.getHandle()](Material* self, float seconds) {
591 return eve::script::projectResult(vm, self->setFoliageWindTime(seconds));
592 });
593 material.addFunc("setAlbedoTexture", &Material::setAlbedoTexture);
594 material.addFunc("getAlbedoTexture", &Material::getAlbedoTexture);
595 material.addFunc("setNormalTexture", &Material::setNormalTexture);
596 material.addFunc("getNormalTexture", &Material::getNormalTexture);
597 material.addFunc("setHeightTexture", &Material::setHeightTexture);
598 material.addFunc("getHeightTexture", &Material::getHeightTexture);
599 material.addFunc("setVirtualTexture",
600 [](Material* self, Texture* albedoAtlas, Texture* normalAtlas, Texture* pageTable, int pageCountX,
601 int pageCountY, int atlasSlotsX, int atlasSlotsY, float borderFraction) {
602 auto result = self->setVirtualTexture(albedoAtlas, normalAtlas, pageTable, pageCountX,
603 pageCountY, atlasSlotsX, atlasSlotsY, borderFraction);
604 if (!result.ok()) throw eve::Exception("%s", result.status().describe().c_str());
605 });
606 material.addFunc("clearVirtualTexture", &Material::clearVirtualTexture);
607 material.addFunc("usesVirtualTexture", [](Material* self) {
608 return self->virtualTextureMode() == MaterialVirtualTextureMode::AtlasPageTable;
609 });
610 material.addFunc("setShader", &Material::setShader);
611 material.addFunc("getShader", &Material::getShader);
612 material.addFunc("setTint", &Material::setTint);
613 material.addFunc("setMetallic", &Material::setMetallic);
614 material.addFunc("getMetallic", &Material::getMetallic);
615 material.addFunc("setRoughness", &Material::setRoughness);
616 material.addFunc("getRoughness", &Material::getRoughness);
617 material.addFunc("setTexCellBomb", &Material::setTexCellBomb);
618 material.addFunc("setParallax", &Material::setParallax);
619 material.addFunc("setReceiveLight", &Material::setReceiveLight);
620 material.addFunc("getReceiveLight", &Material::getReceiveLight);
621 material.addFunc("setCastShadow", &Material::setCastShadow);
622 material.addFunc("getCastShadow", &Material::getCastShadow);
623 material.addFunc("setReceiveShadow", &Material::setReceiveShadow);
624 material.addFunc("getReceiveShadow", &Material::getReceiveShadow);
625 material.addFunc("setCastOcclusion", &Material::setCastOcclusion);
626 material.addFunc("getCastOcclusion", &Material::getCastOcclusion);
627 material.addFunc("setHair", &Material::setHair);
628 material.addFunc("getHair", &Material::getHair);
629 material.addFunc("setSurfaceMode", &Material::setSurfaceMode);
630 material.addFunc("getSurfaceMode", &Material::getSurfaceMode);
631 material.addFunc("setAlphaCutoff", &Material::setAlphaCutoff);
632 material.addFunc("getAlphaCutoff", &Material::getAlphaCutoff);
633 material.addFunc("setBlendMode", &Material::setBlendMode);
634 material.addFunc("getBlendMode", &Material::getBlendMode);
635 material.addFunc("setDepthWrite", &Material::setDepthWrite);
636 material.addFunc("getDepthWrite", &Material::getDepthWrite);
637 material.addFunc("setDoubleSided", &Material::setDoubleSided);
638 material.addFunc("getDoubleSided", &Material::getDoubleSided);
639 material.addFunc("setCameraFacing", &Material::setCameraFacing);
640 material.addFunc("getCameraFacing", &Material::getCameraFacing);
641 material.addFunc("setSortPriority", &Material::setSortPriority);
642 material.addFunc("getSortPriority", &Material::getSortPriority);
643 material.addFunc("setAlphaTechnique", &Material::setAlphaTechnique);
644 material.addFunc("getAlphaTechnique", &Material::getAlphaTechnique);
645 material.addFunc("hasParam", &Material::hasParam);
646 material.addFunc("setFloat", &Material::setFloat);
647 material.addFunc("getFloat", &Material::getFloat);
648
649 auto gbuffer =
650 table.addClass<GBuffer>("GBuffer", std::function<GBuffer*()>([]() -> GBuffer* { return nullptr; }), true);
651 gbuffer.addFunc("isValid", &GBuffer::isValid);
652 gbuffer.addFunc("getWidth", &GBuffer::getWidth);
653 gbuffer.addFunc("getHeight", &GBuffer::getHeight);
654 gbuffer.addFunc("getDepthTexture", &GBuffer::getDepthTexture);
655 gbuffer.addFunc("getHwDepthTexture", &GBuffer::getHwDepthTexture);
656 gbuffer.addFunc("getNormalTexture", &GBuffer::getNormalTexture);
657 gbuffer.addFunc("getAlbedoTexture", &GBuffer::getAlbedoTexture);
658 gbuffer.addFunc("hasBuffer", &GBuffer::hasBuffer);
659 gbuffer.addFunc("getBuffer", &GBuffer::getBuffer);
660
661 auto rctrl = table.addClass<RenderControl>(
662 "RenderControl", std::function<RenderControl*()>([]() -> RenderControl* { return nullptr; }), true);
663 rctrl.addFunc("supports", &RenderControl::supports);
664 rctrl.addFunc("enable", &RenderControl::enable);
665 rctrl.addFunc("disable", &RenderControl::disable);
666 rctrl.addFunc("isEnabled", &RenderControl::isEnabled);
667 rctrl.addFunc("setLightingMode", [](RenderControl* rc, const std::string& name) -> bool {
668 if (!rc) return false;
669 return rc->setLightingMode(name).ok();
670 });
671 rctrl.addFunc("getLightingMode", [](RenderControl* rc) -> std::string {
672 return rc && rc->getLightingMode() == LightingMode::Hybrid ? "hybrid" : "forwardPlus";
673 });
674 rctrl.addFunc("getEffectiveLightingMode", [](RenderControl* rc) -> std::string {
675 return rc && rc->getEffectiveLightingMode() == LightingMode::Hybrid ? "hybrid" : "forwardPlus";
676 });
677 rctrl.addFunc("isDeferredLightingAvailable", &RenderControl::isDeferredLightingAvailable);
678 rctrl.addFunc("hasHybridLightingFallback", &RenderControl::hasHybridLightingFallback);
679 rctrl.addFunc("applyLightingPreset", [](RenderControl* rc, const std::string& name) -> bool {
680 if (!rc) return false;
681 return rc->applyLightingPreset(name).ok();
682 });
683 rctrl.addFunc("applySuggestedLightingPreset", [](RenderControl* rc) -> bool {
684 if (!rc) return false;
685 return rc->applySuggestedLightingPreset().ok();
686 });
687 rctrl.addFunc("getLightingPreset", [](RenderControl* rc) -> std::string {
688 if (!rc) return "desktop";
689 switch (rc->getLightingPreset()) {
690 case LightingPreset::Mobile: return "mobile";
691 case LightingPreset::Ci: return "ci";
693 default: return "desktop";
694 }
695 });
696 rctrl.addFunc("setReflectionQuality", &RenderControl::setReflectionQuality);
697 rctrl.addFunc("getReflectionQuality", &RenderControl::getReflectionQuality);
698 rctrl.addFunc("setPostProcessQuality", &RenderControl::setPostProcessQuality);
699 rctrl.addFunc("getPostProcessQuality", &RenderControl::getPostProcessQuality);
700 rctrl.addFunc("compile", &RenderControl::compile);
701 rctrl.addFunc("isCompiled", &RenderControl::isCompiled);
702 rctrl.addFunc("getPassCount", &RenderControl::getPassCount);
703 rctrl.addFunc("getPassName", &RenderControl::getPassName);
704 rctrl.addFunc("hasPass", &RenderControl::hasPass);
705 rctrl.addFunc("getGBuffer", static_cast<GBuffer* (RenderControl::*)()>(&RenderControl::getGBuffer));
706
707 auto vol = table.addClass<Volumetric>("Volumetric",
708 std::function<Volumetric*()>([]() -> Volumetric* { return nullptr; }), true);
709 vol.addFunc("setQuality", &Volumetric::setQuality);
710 vol.addFunc("getQuality", &Volumetric::getQuality);
711 vol.addFunc("setMode", &Volumetric::setMode);
712 vol.addFunc("getMode", &Volumetric::getMode);
713 vol.addFunc("setLightScreenUV", &Volumetric::setLightScreenUV);
714 vol.addFunc("getLightScreenU", &Volumetric::getLightScreenU);
715 vol.addFunc("getLightScreenV", &Volumetric::getLightScreenV);
716 vol.addFunc("setLightScreenPos", &Volumetric::setLightScreenPos);
717 vol.addFunc("setLightDirection", &Volumetric::setLightDirection);
718 vol.addFunc("setCamera", &Volumetric::setCamera);
719 vol.addFunc("setShaftColor", &Volumetric::setShaftColor);
720 vol.addFunc("setFogColor", &Volumetric::setFogColor);
721 vol.addFunc("setIntensity", &Volumetric::setIntensity);
722 vol.addFunc("setTime", &Volumetric::setTime);
723 vol.addFunc("setDensity", &Volumetric::setDensity);
724 vol.addFunc("setAnisotropy", &Volumetric::setAnisotropy);
725 vol.addFunc("getAnisotropy", &Volumetric::getAnisotropy);
726 vol.addFunc("hasParam", &Volumetric::hasParam);
727 vol.addFunc("setFloat", &Volumetric::setFloat);
728 vol.addFunc("getFloat", &Volumetric::getFloat);
729 vol.addFunc("getSampleCount", &Volumetric::getSampleCount);
730 vol.addFunc("getDownscale", &Volumetric::getDownscale);
731 vol.addFunc("resolutionFor", &Volumetric::resolutionFor);
732 vol.addFunc("beginOcclusionMap", &Volumetric::beginOcclusionMap);
733 vol.addFunc("drawOccluder", &Volumetric::drawOccluder);
734 vol.addFunc("drawOccluderSolid", &Volumetric::drawOccluderSolid);
735 vol.addFunc("drawOccluderTexture", &Volumetric::drawOccluderTexture);
736 vol.addFunc("drawOccluders2D", &Volumetric::drawOccluders2D);
737 vol.addFunc("scatter", &Volumetric::scatter);
738 vol.addFunc("scatterTo", &Volumetric::scatterTo);
739 vol.addFunc("applyFromScene", &Volumetric::applyFromScene);
740 vol.addFunc("applyFromSceneTo", &Volumetric::applyFromSceneTo);
741 vol.addFunc("rayMarch", &Volumetric::rayMarch);
742 vol.addFunc("rayMarchTo", &Volumetric::rayMarchTo);
743 vol.addFunc("setFogHeight", &Volumetric::setFogHeight);
744 vol.addFunc("setFogHeightFalloff", &Volumetric::setFogHeightFalloff);
745 vol.addFunc("setFogStart", &Volumetric::setFogStart);
746 vol.addFunc("setFogEnd", &Volumetric::setFogEnd);
747 vol.addFunc("setFogNoise", &Volumetric::setFogNoise);
748 vol.addFunc("setCloudLayer", &Volumetric::setCloudLayer);
749 vol.addFunc("setCloudCoverage", &Volumetric::setCloudCoverage);
750 vol.addFunc("setCloudDensity", &Volumetric::setCloudDensity);
751 vol.addFunc("setCloudScale", &Volumetric::setCloudScale);
752 vol.addFunc("setCloudWind", &Volumetric::setCloudWind);
753 vol.addFunc("setCloudLightColor", &Volumetric::setCloudLightColor);
754 vol.addFunc("applyFog", &Volumetric::applyFog);
755 vol.addFunc("applyFogTo", &Volumetric::applyFogTo);
756 vol.addFunc("projectDirectionalCookie",
757 [vm = table.getHandle()](Volumetric* value, Graphics* graphics, Texture* depth, Texture* cookie,
758 float worldSize, float intensity) {
759 auto result = value ? value->projectDirectionalCookie(graphics, depth, cookie, worldSize, intensity)
760 : Result<void>::failure(Diagnostic::error(
761 DiagnosticCode::InvalidArgument,
762 "Volumetric.projectDirectionalCookie: non-null provider required"));
763 return eve::script::projectResult(vm, std::move(result));
764 });
765 vol.addFunc("renderClouds", &Volumetric::renderClouds);
766 vol.addFunc("renderCloudsTo", &Volumetric::renderCloudsTo);
767 vol.addFunc("configureFroxelGrid", &Volumetric::configureFroxelGrid);
768 vol.addFunc("clearFroxelGrid", &Volumetric::clearFroxelGrid);
769 vol.addFunc("injectFroxelHeightFog", &Volumetric::injectFroxelHeightFog);
770 vol.addFunc("injectFroxelLocalVolume", &Volumetric::injectFroxelLocalVolume);
771 vol.addFunc("integrateFroxel", &Volumetric::integrateFroxel);
772 vol.addFunc("driveFromLight3D",
773 [vm = table.getHandle()](Volumetric *value, Light3D *light, float viewportW,
774 float viewportH) {
775 auto result = value ? value->driveFromLight3D(light, viewportW, viewportH)
776 : Result<void>::failure(Diagnostic::error(
777 DiagnosticCode::InvalidArgument,
778 "Volumetric.driveFromLight3D: non-null provider required"));
779 return eve::script::projectResult(vm, std::move(result));
780 });
781 vol.addFunc("driveFromPrimarySceneLight3D",
782 [vm = table.getHandle()](Volumetric *value, float viewportW, float viewportH) {
783 auto result = value ? value->driveFromPrimarySceneLight3D(viewportW, viewportH)
784 : Result<void>::failure(Diagnostic::error(
785 DiagnosticCode::InvalidArgument,
786 "Volumetric.driveFromPrimarySceneLight3D: non-null provider required"));
787 return eve::script::projectResult(vm, std::move(result));
788 });
789 vol.addFunc("integrateFroxelFromSceneLights",
790 [vm = table.getHandle()](Volumetric *value, float ambientR, float ambientG,
791 float ambientB, float minX, float minY, float minZ,
792 float maxX, float maxY, float maxZ, int maxLights) {
793 auto result =
794 value ? value->integrateFroxelFromSceneLights(
795 ambientR, ambientG, ambientB, glm::vec3(minX, minY, minZ),
796 glm::vec3(maxX, maxY, maxZ), maxLights)
797 : Result<void>::failure(Diagnostic::error(
798 DiagnosticCode::InvalidArgument,
799 "Volumetric.integrateFroxelFromSceneLights: non-null provider required"));
800 return eve::script::projectResult(vm, std::move(result));
801 });
802 vol.addFunc("beginOcclusionMapFromSceneLights2D",
803 [vm = table.getHandle()](Volumetric *value, Graphics *graphics, Canvas *canvas,
804 float defaultRadiusPixels) {
805 auto result =
806 value ? value->beginOcclusionMapFromSceneLights2D(graphics, canvas,
807 defaultRadiusPixels)
808 : Result<int>::failure(Diagnostic::error(
809 DiagnosticCode::InvalidArgument,
810 "Volumetric.beginOcclusionMapFromSceneLights2D: non-null provider required"));
811 return eve::script::projectResult(vm, std::move(result),
812 [](int count) { return count; });
813 });
814 vol.addFunc("scatterFromSceneLights2D",
815 [vm = table.getHandle()](Volumetric *value, Graphics *graphics, Texture *occlusion,
816 Canvas *canvas) {
817 auto result = value ? value->scatterFromSceneLights2D(graphics, occlusion, canvas)
820 "Volumetric.scatterFromSceneLights2D: non-null provider required"));
821 return eve::script::projectResult(vm, std::move(result),
822 [](int count) { return count; });
823 });
824 vol.addFunc("injectEmissiveLightProxy",
825 [vm = table.getHandle()](Volumetric *value, float x, float y, float z, float r,
826 float g, float b, float radius, float intensity) {
827 auto result =
828 value ? value->injectEmissiveLightProxy(x, y, z, r, g, b, radius, intensity)
831 "Volumetric.injectEmissiveLightProxy: non-null provider required"));
832 return eve::script::projectResult(vm, std::move(result));
833 });
834 vol.addFunc("uploadFroxel", &Volumetric::uploadFroxel);
835 vol.addFunc("applyFroxel", &Volumetric::applyFroxel);
836 vol.addFunc("applyFroxelTo", &Volumetric::applyFroxelTo);
837 vol.addFunc("getShader", &Volumetric::getShader);
838 vol.addFunc("getRayMarchShader", &Volumetric::getRayMarchShader);
839 vol.addFunc("getFogShader", &Volumetric::getFogShader);
840 vol.addFunc("getCloudShader", &Volumetric::getCloudShader);
841
842 auto fogVolume = table.addClass<FogVolume>("FogVolume");
843 fogVolume.addFunc("setShape", &FogVolume::setShape);
844 fogVolume.addFunc("getShape", &FogVolume::getShapeName);
845 fogVolume.addFunc("setPosition", &FogVolume::setPosition);
846 fogVolume.addFunc("setSize", &FogVolume::setSize);
847 fogVolume.addFunc("setExtinction", &FogVolume::setExtinction);
848 fogVolume.addFunc("getExtinction", &FogVolume::getExtinction);
849 fogVolume.addFunc("setAlbedo", &FogVolume::setAlbedo);
850 fogVolume.addFunc("setEmissive", &FogVolume::setEmissive);
851 fogVolume.addFunc("setAnisotropy", &FogVolume::setAnisotropy);
852 fogVolume.addFunc("getAnisotropy", &FogVolume::getAnisotropy);
853 fogVolume.addFunc("setEdgeFalloff", &FogVolume::setEdgeFalloff);
854 fogVolume.addFunc("getEdgeFalloff", &FogVolume::getEdgeFalloff);
855 fogVolume.addFunc("setNoise", &FogVolume::setNoise);
856 fogVolume.addFunc("getNoiseAmount", &FogVolume::getNoiseAmount);
857 fogVolume.addFunc("getNoiseScale", &FogVolume::getNoiseScale);
858 fogVolume.addFunc("getNoiseSeed", &FogVolume::getNoiseSeed);
859
860 auto foliage = table.addClass<grass::GrassFoliageSettings>("GrassFoliageSettings");
861 foliage.addVar("baseR", &grass::GrassFoliageSettings::baseR);
862 foliage.addVar("baseG", &grass::GrassFoliageSettings::baseG);
863 foliage.addVar("baseB", &grass::GrassFoliageSettings::baseB);
864 foliage.addVar("alphaCutoff", &grass::GrassFoliageSettings::alphaCutoff);
865 foliage.addVar("normalStrength", &grass::GrassFoliageSettings::normalStrength);
866 foliage.addVar("renderDistance", &grass::GrassFoliageSettings::renderDistance);
867 foliage.addVar("fadeRange", &grass::GrassFoliageSettings::fadeRange);
868 foliage.addVar("hardRenderDistance", &grass::GrassFoliageSettings::hardRenderDistance);
869 foliage.addVar("density", &grass::GrassFoliageSettings::density);
870 foliage.addVar("snowMinimumHeight", &grass::GrassFoliageSettings::snowMinimumHeight);
871 foliage.addVar("snowFadeDistance", &grass::GrassFoliageSettings::snowFadeDistance);
872 foliage.addVar("snowProgress", &grass::GrassFoliageSettings::snowProgress);
873 foliage.addVar("snowR", &grass::GrassFoliageSettings::snowR);
874 foliage.addVar("snowG", &grass::GrassFoliageSettings::snowG);
875 foliage.addVar("snowB", &grass::GrassFoliageSettings::snowB);
876 auto detailOverwrite = table.addClass<grass::TerrainDetailOverwriteSettings>("TerrainDetailOverwriteSettings");
877 detailOverwrite.addVar("pcgDetailDistance", &grass::TerrainDetailOverwriteSettings::pcgDetailDistance);
878 detailOverwrite.addVar("pcgFadeoutDistance", &grass::TerrainDetailOverwriteSettings::pcgFadeoutDistance);
879 detailOverwrite.addVar("unityDetailDistance", &grass::TerrainDetailOverwriteSettings::unityDetailDistance);
880 detailOverwrite.addVar("unityDetailDensity", &grass::TerrainDetailOverwriteSettings::unityDetailDensity);
881 detailOverwrite.addVar("detailResolutionPerPatch",
883
884 auto grassField = table.addClass<GrassField>(
885 "GrassField", std::function<GrassField*()>([]() -> GrassField* { return nullptr; }), true);
886 grassField.addFunc("bakePlane", static_cast<void (GrassField::*)(float, float, int, int)>(&GrassField::bakePlane));
887 grassField.addFunc("update", &GrassField::update);
888 grassField.addFunc("setTime", &GrassField::setTime);
889 grassField.addFunc("getTime", &GrassField::getTime);
890 grassField.addFunc("setFrameDuration", &GrassField::setFrameDuration);
891 grassField.addFunc("getFrameDuration", &GrassField::getFrameDuration);
892 grassField.addFunc("draw", static_cast<void (GrassField::*)()>(&GrassField::draw));
893 grassField.addFunc("setReflectionCaptureEnabled", &GrassField::setReflectionCaptureEnabled);
894 grassField.addFunc("getReflectionCaptureEnabled", &GrassField::getReflectionCaptureEnabled);
895 grassField.addFunc("setReflectionCaptureMask", &GrassField::setReflectionCaptureMask);
896 grassField.addFunc("getReflectionCaptureMask", &GrassField::getReflectionCaptureMask);
897 grassField.addFunc("getDenseMesh", &GrassField::getDenseMesh);
898 grassField.addFunc("getSparseMesh", &GrassField::getSparseMesh);
899 grassField.addFunc("getShader", &GrassField::getShader);
900 grassField.addFunc("getAtlas", &GrassField::getAtlas);
901 grassField.addFunc("getDenseCount", &GrassField::getDenseCount);
902 grassField.addFunc("getSparseCount", &GrassField::getSparseCount);
903 grassField.addFunc(
904 "setTerrainDetailOverwrite",
905 [vm = table.getHandle()](GrassField* field, const grass::TerrainDetailOverwriteSettings& settings) {
906 return eve::script::projectResult(vm, field->setTerrainDetailOverwrite(settings),
907 [](int value) { return value; });
908 });
909 grassField.addFunc("getTerrainDetailHardDistance",
910 [](const GrassField* field) { return field->getTerrainDetailHardDistance(); });
911 grassField.addFunc("getTerrainDetailDensity",
912 [](const GrassField* field) { return field->getTerrainDetailDensity(); });
913 grassField.addFunc("setPhotoModeAuthority", &GrassField::setPhotoModeAuthority);
914 grassField.addFunc("getPhotoModeDensity", [](const GrassField* field) { return field->getPhotoModeDensity(); });
915 grassField.addFunc("getPhotoModeDistance", [](const GrassField* field) { return field->getPhotoModeDistance(); });
916 grassField.addFunc("getPhotoModeCellDistance",
917 [](const GrassField* field) { return field->getPhotoModeCellDistance(); });
918 grassField.addFunc("getPhotoModeCellSubdivision",
919 [](const GrassField* field) { return field->getPhotoModeCellSubdivision(); });
920
921 auto groomInstance = table.addClass<hair::GroomInstance>(
922 "GroomInstance", std::function<hair::GroomInstance*()>([]() -> hair::GroomInstance* { return nullptr; }), true);
923 // Fallible bake/rebuild stay C++-only (Result); scripts use factory + draw getters.
924 groomInstance.addFunc("draw", static_cast<void (hair::GroomInstance::*)()>(&hair::GroomInstance::draw));
925 groomInstance.addFunc("setForcedLod", &hair::GroomInstance::setForcedLod);
926 groomInstance.addFunc("getForcedLod", &hair::GroomInstance::getForcedLod);
927 groomInstance.addFunc("setScreenSize", &hair::GroomInstance::setScreenSize);
928 groomInstance.addFunc("getScreenSize", &hair::GroomInstance::getScreenSize);
929 groomInstance.addFunc("setWidthScale", &hair::GroomInstance::setWidthScale);
930 groomInstance.addFunc("getWidthScale", &hair::GroomInstance::getWidthScale);
931 groomInstance.addFunc("setSideHint", &hair::GroomInstance::setSideHint);
932 groomInstance.addFunc("getMesh", &hair::GroomInstance::getMesh);
933 groomInstance.addFunc("getShader", &hair::GroomInstance::getShader);
934 groomInstance.addFunc("getTexture", &hair::GroomInstance::getTexture);
935 groomInstance.addFunc("getCurveCount", &hair::GroomInstance::getCurveCount);
936 groomInstance.addFunc("getPointCount", &hair::GroomInstance::getPointCount);
937 groomInstance.addFunc("getGroupCount", &hair::GroomInstance::getGroupCount);
938 groomInstance.addFunc("setClusterCullingEnabled", &hair::GroomInstance::setClusterCullingEnabled);
939 groomInstance.addFunc("isClusterCullingEnabled", &hair::GroomInstance::isClusterCullingEnabled);
940 groomInstance.addFunc("getActiveLodIndex", &hair::GroomInstance::getActiveLodIndex);
941 groomInstance.addFunc("getActiveRepresentation", &hair::GroomInstance::getActiveRepresentation);
942 groomInstance.addFunc("getClusterCount", &hair::GroomInstance::getClusterCount);
943 groomInstance.addFunc("getVisibleCurveCount", &hair::GroomInstance::getVisibleCurveCount);
944 groomInstance.addFunc("setMarschnerLobes", &hair::GroomInstance::setMarschnerLobes);
945 groomInstance.addFunc("getMarschnerR", &hair::GroomInstance::getMarschnerR);
946 groomInstance.addFunc("getMarschnerTT", &hair::GroomInstance::getMarschnerTT);
947 groomInstance.addFunc("getMarschnerTRT", &hair::GroomInstance::getMarschnerTRT);
948 groomInstance.addFunc("setSelfShadow", &hair::GroomInstance::setSelfShadow);
949 groomInstance.addFunc("getSelfShadowStrength", &hair::GroomInstance::getSelfShadowStrength);
950 groomInstance.addFunc("getSelfShadowBias", &hair::GroomInstance::getSelfShadowBias);
951 groomInstance.addFunc("getRootAoStrength", &hair::GroomInstance::getRootAoStrength);
952 groomInstance.addFunc("isGuideSimulationEnabled", &hair::GroomInstance::isGuideSimulationEnabled);
953
954 auto waterfall = table.addClass<Waterfall>(
955 "Waterfall", std::function<Waterfall*()>([]() -> Waterfall* { return nullptr; }), true);
956 waterfall.addFunc("createSheet", &Waterfall::createSheet);
957 waterfall.addFunc("createCurvedSheet", &Waterfall::createCurvedSheet);
958 waterfall.addFunc("update", &Waterfall::update);
959 waterfall.addFunc("setTime", &Waterfall::setTime);
960 waterfall.addFunc("getTime", &Waterfall::getTime);
961 waterfall.addFunc("setFlowSpeed", &Waterfall::setFlowSpeed);
962 waterfall.addFunc("getFlowSpeed", &Waterfall::getFlowSpeed);
963 waterfall.addFunc("setTurbulence", &Waterfall::setTurbulence);
964 waterfall.addFunc("getTurbulence", &Waterfall::getTurbulence);
965 waterfall.addFunc("setStreakCount", &Waterfall::setStreakCount);
966 waterfall.addFunc("getStreakCount", &Waterfall::getStreakCount);
967 waterfall.addFunc("setStreakScale", &Waterfall::setStreakScale);
968 waterfall.addFunc("getStreakScale", &Waterfall::getStreakScale);
969 waterfall.addFunc("setTopFoam", &Waterfall::setTopFoam);
970 waterfall.addFunc("getTopFoam", &Waterfall::getTopFoam);
971 waterfall.addFunc("setBottomFoam", &Waterfall::setBottomFoam);
972 waterfall.addFunc("getBottomFoam", &Waterfall::getBottomFoam);
973 waterfall.addFunc("setFoamAmount", &Waterfall::setFoamAmount);
974 waterfall.addFunc("getFoamAmount", &Waterfall::getFoamAmount);
975 waterfall.addFunc("setWaterColor", &Waterfall::setWaterColor);
976 waterfall.addFunc("setReflectionIntensity", &Waterfall::setReflectionIntensity);
977 waterfall.addFunc("getReflectionIntensity", &Waterfall::getReflectionIntensity);
978 waterfall.addFunc("setSunIntensity", &Waterfall::setSunIntensity);
979 waterfall.addFunc("getSunIntensity", &Waterfall::getSunIntensity);
980 waterfall.addFunc("bindParams", &Waterfall::bindParams);
981 waterfall.addFunc("draw", &Waterfall::draw);
982 waterfall.addFunc("setReflectionCaptureEnabled", &Waterfall::setReflectionCaptureEnabled);
983 waterfall.addFunc("getReflectionCaptureEnabled", &Waterfall::getReflectionCaptureEnabled);
984 waterfall.addFunc("setReflectionCaptureMask", &Waterfall::setReflectionCaptureMask);
985 waterfall.addFunc("getReflectionCaptureMask", &Waterfall::getReflectionCaptureMask);
986 waterfall.addFunc("getShader", &Waterfall::getShader);
987 waterfall.addFunc("getMesh", &Waterfall::getMesh);
988 auto probeCapture = table.addClass<ReflectionProbeCapture>(
989 "ReflectionProbeCapture",
990 std::function<ReflectionProbeCapture*()>([]() -> ReflectionProbeCapture* { return nullptr; }), true);
991 probeCapture.addFunc("configure", &ReflectionProbeCapture::configure);
992 probeCapture.addFunc("requestCapture", &ReflectionProbeCapture::requestCapture);
993 probeCapture.addFunc("queueCapture", &ReflectionProbeCapture::queueCapture);
994 probeCapture.addFunc("update", &ReflectionProbeCapture::update);
995 probeCapture.addFunc("getFaceCanvas", &ReflectionProbeCapture::getFaceCanvas);
996 probeCapture.addFunc("isCapturePending", &ReflectionProbeCapture::isCapturePending);
997 probeCapture.addFunc("isRecaptureQueued", &ReflectionProbeCapture::isRecaptureQueued);
998 probeCapture.addFunc("isCaptureComplete", &ReflectionProbeCapture::isCaptureComplete);
999 probeCapture.addFunc("getRevision", &ReflectionProbeCapture::getRevision);
1000 probeCapture.addFunc("stageCapturedFaces", &ReflectionProbeCapture::stageCapturedFaces);
1001 probeCapture.addFunc("getStagingCubemap", &ReflectionProbeCapture::getStagingCubemap);
1002 probeCapture.addFunc("getStagedRevision", &ReflectionProbeCapture::getStagedRevision);
1003 probeCapture.addFunc("filterAndPublish", &ReflectionProbeCapture::filterAndPublish);
1004 probeCapture.addFunc("getActiveCubemap", &ReflectionProbeCapture::getActiveCubemap);
1005 probeCapture.addFunc("getPublishedRevision", &ReflectionProbeCapture::getPublishedRevision);
1006 probeCapture.addFunc("setUpdateMode", &ReflectionProbeCapture::setUpdateMode);
1007 probeCapture.addFunc("getUpdateMode", &ReflectionProbeCapture::getUpdateMode);
1008 probeCapture.addFunc("setRefreshInterval", &ReflectionProbeCapture::setRefreshInterval);
1009 probeCapture.addFunc("getRefreshInterval", &ReflectionProbeCapture::getRefreshInterval);
1010 probeCapture.addFunc("setCaptureMask", &ReflectionProbeCapture::setCaptureMask);
1011 probeCapture.addFunc("getCaptureMask", &ReflectionProbeCapture::getCaptureMask);
1012 probeCapture.addFunc("setEnvironmentLighting", &ReflectionProbeCapture::setEnvironmentLighting);
1013 probeCapture.addFunc("getEnvironmentLighting", &ReflectionProbeCapture::getEnvironmentLighting);
1014 probeCapture.addFunc("getEnvironmentLightingIntensity", &ReflectionProbeCapture::getEnvironmentLightingIntensity);
1015 probeCapture.addFunc("setSkyColor", &ReflectionProbeCapture::setSkyColor);
1016 probeCapture.addFunc("setSkyFaceColor", &ReflectionProbeCapture::setSkyFaceColor);
1017 probeCapture.addFunc("setSkyFaceTexture", &ReflectionProbeCapture::setSkyFaceTexture);
1018 probeCapture.addFunc("getSkyFaceTexture", &ReflectionProbeCapture::getSkyFaceTexture);
1019 probeCapture.addFunc("setSkyFaceTextureScale", &ReflectionProbeCapture::setSkyFaceTextureScale);
1020 probeCapture.addFunc("getSkyFaceTextureScale", &ReflectionProbeCapture::getSkyFaceTextureScale);
1021 probeCapture.addFunc("getSkyFaceColor", &ReflectionProbeCapture::getSkyFaceColor);
1022 probeCapture.addFunc("getSkyR", &ReflectionProbeCapture::getSkyR);
1023 probeCapture.addFunc("getSkyG", &ReflectionProbeCapture::getSkyG);
1024 probeCapture.addFunc("getSkyB", &ReflectionProbeCapture::getSkyB);
1025 probeCapture.addFunc("getSkyIntensity", &ReflectionProbeCapture::getSkyIntensity);
1026 probeCapture.addFunc("getPendingFaceCount", &ReflectionProbeCapture::getPendingFaceCount);
1027 probeCapture.addFunc("getLastCapturedFaceCount", &ReflectionProbeCapture::getLastCapturedFaceCount);
1028 probeCapture.addFunc("getTotalCapturedFaceCount", &ReflectionProbeCapture::getTotalCapturedFaceCount);
1029 probeCapture.addFunc("getLastFilterSampleCount", &ReflectionProbeCapture::getLastFilterSampleCount);
1030 probeCapture.addFunc("setGpuBudgetMs", &ReflectionProbeCapture::setGpuBudgetMs);
1031 probeCapture.addFunc("getGpuBudgetMs", &ReflectionProbeCapture::getGpuBudgetMs);
1032 probeCapture.addFunc("reportGpuDurationMs", &ReflectionProbeCapture::reportGpuDurationMs);
1033 probeCapture.addFunc("getSmoothedGpuDurationMs", &ReflectionProbeCapture::getSmoothedGpuDurationMs);
1034 probeCapture.addFunc("getAdaptiveFaceBudget", &ReflectionProbeCapture::getAdaptiveFaceBudget);
1035 probeCapture.addFunc("getAdaptiveFilterSamples", &ReflectionProbeCapture::getAdaptiveFilterSamples);
1036 probeCapture.addFunc("tickAdaptive", &ReflectionProbeCapture::tickAdaptive);
1037 probeCapture.addFunc("tick", &ReflectionProbeCapture::tick);
1038 probeCapture.addFunc("configureInfluence", &ReflectionProbeCapture::configureInfluence);
1039 probeCapture.addFunc("getInfluenceExtentX", &ReflectionProbeCapture::getInfluenceExtentX);
1040 probeCapture.addFunc("getInfluenceExtentY", &ReflectionProbeCapture::getInfluenceExtentY);
1041 probeCapture.addFunc("getInfluenceExtentZ", &ReflectionProbeCapture::getInfluenceExtentZ);
1042 probeCapture.addFunc("getInfluenceIntensity", &ReflectionProbeCapture::getInfluenceIntensity);
1043 probeCapture.addFunc("getInfluenceBlendDistance", &ReflectionProbeCapture::getInfluenceBlendDistance);
1044 probeCapture.addFunc("getInfluencePriority", &ReflectionProbeCapture::getInfluencePriority);
1045 probeCapture.addFunc("applyConfiguredToCamera", &ReflectionProbeCapture::applyConfiguredToCamera);
1046 probeCapture.addFunc("applyToCamera", &ReflectionProbeCapture::applyToCamera);
1047 probeCapture.addFunc("getResolution", &ReflectionProbeCapture::getResolution);
1048 probeCapture.addFunc("getCenterX", &ReflectionProbeCapture::getCenterX);
1049 probeCapture.addFunc("getCenterY", &ReflectionProbeCapture::getCenterY);
1050 probeCapture.addFunc("getCenterZ", &ReflectionProbeCapture::getCenterZ);
1051 probeCapture.addFunc("getCaptureFarDistance", &ReflectionProbeCapture::getCaptureFarDistance);
1052 probeCapture.addFunc("setCaptureLodDistanceScale", &ReflectionProbeCapture::setCaptureLodDistanceScale);
1053 probeCapture.addFunc("getCaptureLodDistanceScale", &ReflectionProbeCapture::getCaptureLodDistanceScale);
1054 probeCapture.addFunc("setCaptureTransparent", &ReflectionProbeCapture::setCaptureTransparent);
1055 probeCapture.addFunc("getCaptureTransparent", &ReflectionProbeCapture::getCaptureTransparent);
1056 probeCapture.addFunc("setCaptureClusteredLighting", &ReflectionProbeCapture::setCaptureClusteredLighting);
1057 probeCapture.addFunc("getCaptureClusteredLighting", &ReflectionProbeCapture::getCaptureClusteredLighting);
1058 auto probeRegistry = table.addClass<ReflectionProbeRegistry>(
1059 "ReflectionProbeRegistry",
1060 std::function<ReflectionProbeRegistry*()>([]() -> ReflectionProbeRegistry* { return nullptr; }), true);
1061 probeRegistry.addFunc("add", &ReflectionProbeRegistry::add);
1062 probeRegistry.addFunc("remove", &ReflectionProbeRegistry::remove);
1063 probeRegistry.addFunc("clear", &ReflectionProbeRegistry::clear);
1064 probeRegistry.addFunc("getCount", &ReflectionProbeRegistry::getCount);
1065 probeRegistry.addFunc("getLastSelectedCount", &ReflectionProbeRegistry::getLastSelectedCount);
1066 probeRegistry.addFunc("getLastCapturedFaceCount", &ReflectionProbeRegistry::getLastCapturedFaceCount);
1067 probeRegistry.addFunc("getLastPublishedCount", &ReflectionProbeRegistry::getLastPublishedCount);
1068 probeRegistry.addFunc("setSelectionHysteresis", &ReflectionProbeRegistry::setSelectionHysteresis);
1069 probeRegistry.addFunc("getSelectionHysteresis", &ReflectionProbeRegistry::getSelectionHysteresis);
1070 probeRegistry.addFunc("getLastCandidateCount", &ReflectionProbeRegistry::getLastCandidateCount);
1071 probeRegistry.addFunc("setDistanceCullingEnabled", &ReflectionProbeRegistry::setDistanceCullingEnabled);
1072 probeRegistry.addFunc("getDistanceCullingEnabled", &ReflectionProbeRegistry::getDistanceCullingEnabled);
1073 probeRegistry.addFunc("setMaxRenderDistance",
1074 [vm = table.getHandle()](ReflectionProbeRegistry* self, float distance) {
1075 return eve::script::projectResult(vm, self->setMaxRenderDistance(distance));
1076 });
1077 probeRegistry.addFunc("getMaxRenderDistance", &ReflectionProbeRegistry::getMaxRenderDistance);
1078 probeRegistry.addFunc("getLastDistanceCulledCount", &ReflectionProbeRegistry::getLastDistanceCulledCount);
1079 probeRegistry.addFunc("queueCapture", &ReflectionProbeRegistry::queueCapture);
1080 probeRegistry.addFunc("queueCaptureAABB", &ReflectionProbeRegistry::queueCaptureAABB);
1081 probeRegistry.addFunc("tick", &ReflectionProbeRegistry::tick);
1082 probeRegistry.addFunc("updateCamera", &ReflectionProbeRegistry::updateCamera);
1083 auto water = table.addClass<Water>("Water", std::function<Water*()>([]() -> Water* { return nullptr; }), true);
1084 water.addFunc("createPlane", &Water::createPlane);
1085 auto waterMeshSettings = table.addClass("WaterMeshSettings", ssq::Class::Ctor<WaterMeshSettings()>());
1086 waterMeshSettings.addVar("sizeX", &WaterMeshSettings::sizeX);
1087 waterMeshSettings.addVar("sizeY", &WaterMeshSettings::sizeY);
1088 waterMeshSettings.addVar("sizeZ", &WaterMeshSettings::sizeZ);
1089 waterMeshSettings.addVar("densityX", &WaterMeshSettings::densityX);
1090 waterMeshSettings.addVar("densityY", &WaterMeshSettings::densityY);
1091 waterMeshSettings.addVar("height", &WaterMeshSettings::height);
1092 waterMeshSettings.addFunc(
1093 "setType", [](WaterMeshSettings* value, int type) { value->type = static_cast<WaterMeshType>(type); });
1094 auto waterGradient = table.addClass("WaterDepthGradient", ssq::Class::Ctor<WaterDepthGradient()>());
1095 waterGradient.addFunc("addColorStop", [vm = table.getHandle()](WaterDepthGradient* value, float time, float red,
1096 float green, float blue) {
1097 auto result = value ? value->addColorStop(time, red, green, blue)
1099 "water.gradient: non-null gradient required"));
1100 return eve::script::projectResult(vm, std::move(result));
1101 });
1102 waterGradient.addFunc("addAlphaStop", [vm = table.getHandle()](WaterDepthGradient* value, float time, float alpha) {
1103 auto result = value ? value->addAlphaStop(time, alpha)
1105 "water.gradient: non-null gradient required"));
1106 return eve::script::projectResult(vm, std::move(result));
1107 });
1108 waterGradient.addFunc("clear", &WaterDepthGradient::clear);
1109 table.addFunc("calculateWaterMeshTriangles", [vm = table.getHandle()](const WaterMeshSettings* settings) {
1112 "water.mesh: non-null settings required"));
1113 return eve::script::projectResult(vm, std::move(result), [](int value) { return value; });
1114 });
1115 water.addFunc("createProceduralMesh", [vm = table.getHandle()](Water* value, const WaterMeshSettings* settings) {
1116 auto result = value && settings
1117 ? value->createProceduralMesh(*settings)
1119 "water.mesh: non-null water and settings required"));
1120 return eve::script::projectResult(vm, std::move(result), [](int count) { return count; });
1121 });
1122 water.addFunc(
1123 "setDepthGradient", [vm = table.getHandle()](Water* value, const WaterDepthGradient* gradient, int resolution) {
1124 auto result =
1125 value && gradient
1126 ? value->setDepthGradient(*gradient, resolution)
1128 "water.gradient: non-null water and gradient required"));
1129 return eve::script::projectResult(vm, std::move(result), [](int count) { return count; });
1130 });
1131 water.addFunc("getDepthGradientTexture", &Water::getDepthGradientTexture);
1132 water.addFunc("clearDepthGradient", &Water::clearDepthGradient);
1133 water.addFunc("update", &Water::update);
1134 water.addFunc("setTime", &Water::setTime);
1135 water.addFunc("getTime", &Water::getTime);
1136 water.addFunc("setWaveSpeed", &Water::setWaveSpeed);
1137 water.addFunc("getWaveSpeed", &Water::getWaveSpeed);
1138 water.addFunc("setWaveAmplitude", &Water::setWaveAmplitude);
1139 water.addFunc("getWaveAmplitude", &Water::getWaveAmplitude);
1140 water.addFunc("setRippleAmplitude", &Water::setRippleAmplitude);
1141 water.addFunc("getRippleAmplitude", &Water::getRippleAmplitude);
1142 water.addFunc("setEdgeFalloff", &Water::setEdgeFalloff);
1143 water.addFunc("getEdgeFalloff", &Water::getEdgeFalloff);
1144 water.addFunc("setRippleCount", &Water::setRippleCount);
1145 water.addFunc("getRippleCount", &Water::getRippleCount);
1146 water.addFunc("setRippleInterval", &Water::setRippleInterval);
1147 water.addFunc("getRippleInterval", &Water::getRippleInterval);
1148 water.addFunc("setWaveScale", &Water::setWaveScale);
1149 water.addFunc("getWaveScale", &Water::getWaveScale);
1150 water.addFunc("setWaveDirectionAngle", [vm = table.getHandle()](Water* value, float degrees) {
1151 auto result = value ? value->setWaveDirectionAngle(degrees)
1153 "water.direction: non-null water required"));
1154 return eve::script::projectResult(vm, std::move(result));
1155 });
1156 water.addFunc("getWaveDirectionAngle", &Water::getWaveDirectionAngle);
1157 water.addFunc("setWaterColor", &Water::setWaterColor);
1158 water.addFunc("setReflectionTint", &Water::setReflectionTint);
1159 water.addFunc("setReflectionIntensity", &Water::setReflectionIntensity);
1160 water.addFunc("getReflectionIntensity", &Water::getReflectionIntensity);
1161 water.addFunc("setSunIntensity", &Water::setSunIntensity);
1162 water.addFunc("getSunIntensity", &Water::getSunIntensity);
1163 water.addFunc("setScreenSpaceReflection", &Water::setScreenSpaceReflection);
1164 water.addFunc("getScreenSpaceReflection", &Water::getScreenSpaceReflection);
1165 water.addFunc("getScreenSpaceReflectionStrength", &Water::getScreenSpaceReflectionStrength);
1166 water.addFunc("applyConfigJson", [vm = table.getHandle()](Water* value, const std::string& json) {
1167 return eve::script::projectResult(vm, value->applyConfigJson(json));
1168 });
1169 water.addFunc("configJson", [vm = table.getHandle()](Water* value) {
1170 return eve::script::projectResult(vm, value->configJson(), [](std::string json) { return json; });
1171 });
1172 water.addFunc("setViewport", &Water::setViewport);
1173 water.addFunc("getViewportWidth", &Water::getViewportWidth);
1174 water.addFunc("getViewportHeight", &Water::getViewportHeight);
1175 water.addFunc("bindParams", &Water::bindParams);
1176 water.addFunc("draw", &Water::draw);
1177 water.addFunc("setReflectionCaptureEnabled", &Water::setReflectionCaptureEnabled);
1178 water.addFunc("getReflectionCaptureEnabled", &Water::getReflectionCaptureEnabled);
1179 water.addFunc("setReflectionCaptureMask", &Water::setReflectionCaptureMask);
1180 water.addFunc("getReflectionCaptureMask", &Water::getReflectionCaptureMask);
1181 water.addFunc("getShader", &Water::getShader);
1182 water.addFunc("getMesh", &Water::getMesh);
1183
1184 auto ao = table.addClass<AmbientOcclusion>(
1185 "AmbientOcclusion", std::function<AmbientOcclusion*()>([]() -> AmbientOcclusion* { return nullptr; }), true);
1186 ao.addFunc("setQuality", &AmbientOcclusion::setQuality);
1187 ao.addFunc("getQuality", &AmbientOcclusion::getQuality);
1188 ao.addFunc("setMode", &AmbientOcclusion::setMode);
1189 ao.addFunc("getMode", &AmbientOcclusion::getMode);
1190 ao.addFunc("setCamera", &AmbientOcclusion::setCamera);
1191 ao.addFunc("setRadius", &AmbientOcclusion::setRadius);
1192 ao.addFunc("setBias", &AmbientOcclusion::setBias);
1193 ao.addFunc("setIntensity", &AmbientOcclusion::setIntensity);
1194 ao.addFunc("setPower", &AmbientOcclusion::setPower);
1195 ao.addFunc("setThickness", &AmbientOcclusion::setThickness);
1196 ao.addFunc("getRadius", &AmbientOcclusion::getRadius);
1197 ao.addFunc("getBias", &AmbientOcclusion::getBias);
1198 ao.addFunc("getIntensity", &AmbientOcclusion::getIntensity);
1199 ao.addFunc("getPower", &AmbientOcclusion::getPower);
1200 ao.addFunc("hasParam", &AmbientOcclusion::hasParam);
1201 ao.addFunc("setFloat", &AmbientOcclusion::setFloat);
1202 ao.addFunc("getFloat", &AmbientOcclusion::getFloat);
1203 ao.addFunc("getSampleCount", &AmbientOcclusion::getSampleCount);
1204 ao.addFunc("getDownscale", &AmbientOcclusion::getDownscale);
1205 ao.addFunc("resolutionFor", &AmbientOcclusion::resolutionFor);
1206 ao.addFunc("compute", &AmbientOcclusion::compute);
1207 ao.addFunc("computeTo", &AmbientOcclusion::computeTo);
1208 ao.addFunc("blur", &AmbientOcclusion::blur);
1209 ao.addFunc("blurTo", &AmbientOcclusion::blurTo);
1210 ao.addFunc("applyOverlay", &AmbientOcclusion::applyOverlay);
1211 ao.addFunc("applyOverlayTo", &AmbientOcclusion::applyOverlayTo);
1212 ao.addFunc("applyFromDepth", &AmbientOcclusion::applyFromDepth);
1213 ao.addFunc("applyFromDepthTo", &AmbientOcclusion::applyFromDepthTo);
1214 ao.addFunc("applyFromGBuffer", &AmbientOcclusion::applyFromGBuffer);
1215 ao.addFunc("getShader", &AmbientOcclusion::getShader);
1216 ao.addFunc("getSsaoShader", &AmbientOcclusion::getSsaoShader);
1217 ao.addFunc("getHbaoShader", &AmbientOcclusion::getHbaoShader);
1218 ao.addFunc("getGtaoShader", &AmbientOcclusion::getGtaoShader);
1219 ao.addFunc("getBlurShader", &AmbientOcclusion::getBlurShader);
1220 ao.addFunc("getOverlayShader", &AmbientOcclusion::getOverlayShader);
1221 ao.addFunc("getFromDepthShader", &AmbientOcclusion::getFromDepthShader);
1222
1223 auto outline =
1224 table.addClass<Outline>("Outline", std::function<Outline*()>([]() -> Outline* { return nullptr; }), true);
1225 outline.addFunc("setColor", &Outline::setColor);
1226 outline.addFunc("getColorR", &Outline::getColorR);
1227 outline.addFunc("getColorG", &Outline::getColorG);
1228 outline.addFunc("getColorB", &Outline::getColorB);
1229 outline.addFunc("setWidth", &Outline::setWidth);
1230 outline.addFunc("getWidth", &Outline::getWidth);
1231 outline.addFunc("setDepthThreshold", &Outline::setDepthThreshold);
1232 outline.addFunc("getDepthThreshold", &Outline::getDepthThreshold);
1233 outline.addFunc("setDepthSensitivity", &Outline::setDepthSensitivity);
1234 outline.addFunc("getDepthSensitivity", &Outline::getDepthSensitivity);
1235 outline.addFunc("setNormalThreshold", &Outline::setNormalThreshold);
1236 outline.addFunc("getNormalThreshold", &Outline::getNormalThreshold);
1237 outline.addFunc("setSoftness", &Outline::setSoftness);
1238 outline.addFunc("getSoftness", &Outline::getSoftness);
1239 outline.addFunc("setClip", &Outline::setClip);
1240 outline.addFunc("hasParam", &Outline::hasParam);
1241 outline.addFunc("setFloat", &Outline::setFloat);
1242 outline.addFunc("getFloat", &Outline::getFloat);
1243 outline.addFunc("apply", &Outline::apply);
1244 outline.addFunc("applyTo", &Outline::applyTo);
1245 outline.addFunc("getShader", &Outline::getShader);
1246
1247 auto gi = table.addClass<GlobalIllumination>(
1248 "GlobalIllumination", std::function<GlobalIllumination*()>([]() -> GlobalIllumination* { return nullptr; }),
1249 true);
1250 gi.addFunc("setQuality", &GlobalIllumination::setQuality);
1251 gi.addFunc("getQuality", &GlobalIllumination::getQuality);
1252 gi.addFunc("setCamera", &GlobalIllumination::setCamera);
1253 gi.addFunc("setRadius", &GlobalIllumination::setRadius);
1254 gi.addFunc("setIntensity", &GlobalIllumination::setIntensity);
1255 gi.addFunc("setThickness", &GlobalIllumination::setThickness);
1256 gi.addFunc("setResolutionScale", &GlobalIllumination::setResolutionScale);
1257 gi.addFunc("setLightDirection", &GlobalIllumination::setLightDirection);
1258 gi.addFunc("setLightColor", &GlobalIllumination::setLightColor);
1259 gi.addFunc("getRadius", &GlobalIllumination::getRadius);
1260 gi.addFunc("getIntensity", &GlobalIllumination::getIntensity);
1261 gi.addFunc("getThickness", &GlobalIllumination::getThickness);
1262 gi.addFunc("getResolutionScale", &GlobalIllumination::getResolutionScale);
1263 gi.addFunc("hasParam", &GlobalIllumination::hasParam);
1264 gi.addFunc("setFloat", &GlobalIllumination::setFloat);
1265 gi.addFunc("getFloat", &GlobalIllumination::getFloat);
1266 gi.addFunc("getSampleCount", &GlobalIllumination::getSampleCount);
1267 gi.addFunc("applyFromDepth", &GlobalIllumination::applyFromDepth);
1268 gi.addFunc("applyFromDepthTo", &GlobalIllumination::applyFromDepthTo);
1269 gi.addFunc("applyFromScene", &GlobalIllumination::applyFromScene);
1270 gi.addFunc("getShader", &GlobalIllumination::getShader);
1271
1272 auto ssr = table.addClass<ScreenSpaceReflection>(
1273 "ScreenSpaceReflection",
1274 std::function<ScreenSpaceReflection*()>([]() -> ScreenSpaceReflection* { return nullptr; }), true);
1275 ssr.addFunc("setCamera", &ScreenSpaceReflection::setCamera);
1276 ssr.addFunc("setEnabled", &ScreenSpaceReflection::setEnabled);
1277 ssr.addFunc("getEnabled", &ScreenSpaceReflection::getEnabled);
1278 ssr.addFunc("setQuality", &ScreenSpaceReflection::setQuality);
1279 ssr.addFunc("getQuality", &ScreenSpaceReflection::getQuality);
1280 ssr.addFunc("setMaxDistance", &ScreenSpaceReflection::setMaxDistance);
1281 ssr.addFunc("setStepLength", &ScreenSpaceReflection::setStepLength);
1282 ssr.addFunc("setMaxSteps", &ScreenSpaceReflection::setMaxSteps);
1283 ssr.addFunc("setThickness", &ScreenSpaceReflection::setThickness);
1284 ssr.addFunc("setStrength", &ScreenSpaceReflection::setStrength);
1285 ssr.addFunc("setMaxRoughness", &ScreenSpaceReflection::setMaxRoughness);
1286 ssr.addFunc("setResolutionScale", &ScreenSpaceReflection::setResolutionScale);
1287 ssr.addFunc("getStrength", &ScreenSpaceReflection::getStrength);
1288 ssr.addFunc("getMaxRoughness", &ScreenSpaceReflection::getMaxRoughness);
1289 ssr.addFunc("getResolutionScale", &ScreenSpaceReflection::getResolutionScale);
1290 ssr.addFunc("hasParam", &ScreenSpaceReflection::hasParam);
1291 ssr.addFunc("setFloat", &ScreenSpaceReflection::setFloat);
1292 ssr.addFunc("getFloat", &ScreenSpaceReflection::getFloat);
1293 ssr.addFunc("applyFromScene", &ScreenSpaceReflection::applyFromScene);
1294 ssr.addFunc(
1295 "applyFromSceneTo",
1296 static_cast<void (ScreenSpaceReflection::*)(Graphics*, Texture*, Texture*, Texture*, Texture*, Canvas*)>(
1297 &ScreenSpaceReflection::applyFromSceneTo));
1298 ssr.addFunc("getShader", &ScreenSpaceReflection::getShader);
1299
1300 auto aa = table.addClass<AntiAliasing>(
1301 "AntiAliasing", std::function<AntiAliasing*()>([]() -> AntiAliasing* { return nullptr; }), true);
1302 aa.addFunc("setQuality", &AntiAliasing::setQuality);
1303 aa.addFunc("getQuality", &AntiAliasing::getQuality);
1304 aa.addFunc("setMode", &AntiAliasing::setMode);
1305 aa.addFunc("getMode", &AntiAliasing::getMode);
1306 aa.addFunc("hasParam", &AntiAliasing::hasParam);
1307 aa.addFunc("setFloat", &AntiAliasing::setFloat);
1308 aa.addFunc("getFloat", &AntiAliasing::getFloat);
1309 aa.addFunc("suggestScale", &AntiAliasing::suggestScale);
1310 aa.addFunc("resolutionFor", &AntiAliasing::resolutionFor);
1311 aa.addFunc("apply", &AntiAliasing::apply);
1312 aa.addFunc("applyTo", &AntiAliasing::applyTo);
1313 aa.addFunc("applyCanvas", &AntiAliasing::applyCanvas);
1314 aa.addFunc("applyCanvasTo", &AntiAliasing::applyCanvasTo);
1315 aa.addFunc("getShader", &AntiAliasing::getShader);
1316 aa.addFunc("getFxaaShader", &AntiAliasing::getFxaaShader);
1317 aa.addFunc("getSmaaShader", &AntiAliasing::getSmaaShader);
1318 aa.addFunc("getSsaaShader", &AntiAliasing::getSsaaShader);
1319 aa.addFunc("getNfaaShader", &AntiAliasing::getNfaaShader);
1320}
1321
1322void Graphics::expose(ssq::Class& cls) {
1323 cls.addFunc("getName", &Graphics::getName);
1324 cls.addFunc("reset", &Graphics::reset);
1325 cls.addFunc("present", &Graphics::present);
1326 cls.addFunc("clear", &Graphics::clearScreen);
1327 cls.addFunc("setBackgroundColor", &Graphics::setBackgroundColorRGBA);
1328 cls.addFunc("drawSolidRect", &Graphics::drawSolidRectRGBA);
1329 cls.addFunc("drawTexturedRect", &Graphics::drawTexturedRectRGBA);
1330 cls.addFunc("renderSprites", &Graphics::renderSprites);
1331 cls.addFunc("newSprite2D", &Graphics::newSprite2D);
1332 cls.addFunc("drawTexturedRectRotated", &Graphics::drawTexturedRectRotatedRGBA);
1333 cls.addFunc("newFont", &Graphics::newFont);
1334 cls.addFunc("setFont", &Graphics::setFont);
1335 cls.addFunc("getFont", &Graphics::getFont);
1336 cls.addFunc("drawText", &Graphics::drawTextRGBA);
1337 cls.addFunc("print", &Graphics::printRGBA);
1338 cls.addFunc("newTextureFromFile", &Graphics::newTextureFromFile);
1339 cls.addFunc("newTexture",
1340 static_cast<Texture* (Graphics::*)(image::ImageData*, bool, bool)>(&Graphics::newTextureFromImageData));
1341 cls.addFunc(
1342 "setRenderableTextureFromImageData",
1343 [](Graphics* self, Renderable3D* renderable, image::ImageData* data, bool repeatU, bool repeatV) -> Texture* {
1344 if (!renderable) throw eve::Exception("setRenderableTextureFromImageData: null Renderable3D");
1345 Texture* texture = self->newTextureFromImageData(data, repeatU, repeatV);
1346 if (Material* material = renderable->getMaterial())
1347 material->setAlbedoTexture(texture);
1348 else
1349 renderable->setTexture(texture);
1350 return texture;
1351 });
1352 cls.addFunc("updateTextureFromImageData", [](Graphics* self, Texture* texture, image::ImageData* data) {
1353 auto updated = self->updateTextureFromImageData(texture, data);
1354 if (!updated.ok()) throw eve::Exception("%s", updated.status().describe().c_str());
1355 });
1356 cls.addFunc("newTextureFromFile", &Graphics::newTextureFromFile);
1357 cls.addFunc("newTextureFromFileRepeated", &Graphics::newTextureFromFileRepeated);
1358 cls.addFunc("newTextureWithSampler", &Graphics::newTextureWithSampler);
1359 cls.addFunc("setTextureSampler",
1360 static_cast<void (Graphics::*)(Texture*, const std::string&, const std::string&, float, float)>(
1361 &Graphics::setTextureSampler));
1362 cls.addFunc("getMaxAnisotropy", &Graphics::getMaxAnisotropy);
1363 cls.addFunc("newMeshSphere", &Graphics::newMeshSphere);
1364 cls.addFunc("newMeshCylinder", &Graphics::newMeshCylinder);
1365 cls.addFunc("newMeshCube", &Graphics::newMeshCube);
1366 cls.addFunc("newMeshFromArrays",
1367 std::function<Mesh*(Graphics*, ssq::Array, ssq::Array, ssq::Array, int, ssq::Array, int)>(
1368 newMeshFromArraysScript));
1369 cls.addFunc("updateMeshVertices",
1370 std::function<bool(Graphics*, Mesh*, ssq::Array, ssq::Array, ssq::Array, int, ssq::Array, int)>(
1371 updateMeshVerticesScript));
1372 cls.addFunc("bakeMeshMorph", &Graphics::bakeMeshMorph);
1373 cls.addFunc("newShader", static_cast<Shader* (Graphics::*)(const std::string&)>(&Graphics::newShader));
1374 cls.addFunc("newShaderFromWgsl", &Graphics::newShaderFromWgsl);
1375 cls.addFunc("newMeshShader", static_cast<Shader* (Graphics::*)(const std::string&)>(&Graphics::newMeshShader));
1376 cls.addFunc("newMeshShaderVF", &Graphics::newMeshShaderVF);
1377 cls.addFunc("newHairShader", &Graphics::newHairShader);
1378 cls.addFunc("newHairCardMesh", &Graphics::newHairCardMesh);
1379 cls.addFunc("newHairCardMaterial", &Graphics::newHairCardMaterial);
1380 cls.addFunc("newGrassShader", &Graphics::newGrassShader);
1381 cls.addFunc("newTreeWindShader", &Graphics::newTreeWindShader);
1382 cls.addFunc("newGrassField", &Graphics::newGrassField);
1383 cls.addFunc("newGroomInstance", &Graphics::newGroomInstance);
1384 cls.addFunc("newWaterfall", &Graphics::newWaterfall);
1385 cls.addFunc("newReflectionProbeCapture", &Graphics::newReflectionProbeCapture);
1386 cls.addFunc("newReflectionProbeRegistry", &Graphics::newReflectionProbeRegistry);
1387 cls.addFunc("newWater", &Graphics::newWater);
1388 cls.addFunc(
1389 "configureFoliageWind",
1390 [vm = cls.getHandle()](Graphics* self, Material* material, float directionX, float directionZ, float strength,
1391 float bending, float bendingSpeed, float branch, float branchSpeed, float flutter,
1392 float flutterSpeed, float fadeDistance, float bendFactor) {
1394 vm, self->configureFoliageWind(material, directionX, directionZ, strength, bending, bendingSpeed,
1395 branch, branchSpeed, flutter, flutterSpeed, fadeDistance, bendFactor));
1396 });
1397 cls.addFunc("newShaderFromSpvFile",
1398 static_cast<Shader* (Graphics::*)(const std::string&)>(&Graphics::newShaderFromSpvFile));
1399 cls.addFunc("setShader", std::function<void(Graphics*, ssq::Object)>(setShaderScript));
1400 cls.addFunc("getShader", &Graphics::getShader);
1401 cls.addFunc("render3D", &Graphics::render3D);
1402 cls.addFunc("begin3DFrame", &Graphics::begin3DFrame);
1403 cls.addFunc("setMesh3DViewProj", std::function<void(Graphics*, ssq::Array)>(setMesh3DViewProjScript));
1404 cls.addFunc("setMesh3DView", std::function<void(Graphics*, ssq::Array)>(setMesh3DViewScript));
1405 cls.addFunc("setMesh3DCameraPos", std::function<void(Graphics*, float, float, float)>(setMesh3DCameraPosScript));
1406 cls.addFunc("renderScene3DToCanvas", &Graphics::renderScene3DToCanvas);
1407 cls.addFunc("drawScene3DRGBA", &Graphics::drawScene3DRGBA);
1408 cls.addFunc("saveFramePng", &Graphics::saveFramePng);
1409 cls.addFunc("drawScene3D", &Graphics::drawScene3D);
1410 cls.addFunc("drawCanvas", &Graphics::drawCanvas);
1411 cls.addFunc("newCanvas", &Graphics::newCanvas);
1412 cls.addFunc("setCanvas", std::function<void(Graphics*, ssq::Object)>(setCanvasScript));
1413 cls.addFunc("getCanvas", &Graphics::getCanvas);
1414 cls.addFunc("getWidth", &Graphics::getWidth);
1415 cls.addFunc("getHeight", &Graphics::getHeight);
1416 cls.addFunc("setDirectionalLight", &Graphics::setDirectionalLight);
1417 // Process-wide shadow scheme toggles (dir CSM / spot perspective / point cube).
1418 cls.addFunc("setShadowSchemeDirectionalEnabled", [](Graphics*, bool enabled) {
1419 ShadowSchemeSettings::current().enableDirectionalCsm = enabled;
1420 });
1421 cls.addFunc("setShadowSchemeSpotEnabled", [](Graphics*, bool enabled) {
1422 ShadowSchemeSettings::current().enableSpotPerspective = enabled;
1423 });
1424 cls.addFunc("setShadowSchemePointEnabled", [](Graphics*, bool enabled) {
1425 ShadowSchemeSettings::current().enablePointCube = enabled;
1426 });
1427 cls.addFunc("setShadowSchemeMaxSpotCasters", [](Graphics*, int count) {
1428 ShadowSchemeSettings::current().maxSpotShadowCasters = count;
1429 });
1430 cls.addFunc("getShadowSchemeMaxSpotCasters",
1431 [](Graphics*) { return ShadowSchemeSettings::current().maxSpotShadowCasters; });
1432 cls.addFunc("setShadowSchemePagingEnabled", [](Graphics*, bool enabled) {
1433 ShadowSchemeSettings::current().enableLocalPaging = enabled;
1434 });
1435 cls.addFunc("setShadowSchemeMaxLocalUpdates", [](Graphics*, int count) {
1436 ShadowSchemeSettings::current().maxLocalUpdatesPerFrame = count;
1437 });
1438 cls.addFunc("getShadowSchemeMaxLocalUpdates",
1439 [](Graphics*) { return ShadowSchemeSettings::current().maxLocalUpdatesPerFrame; });
1440 cls.addFunc("setShadowSchemeHysteresisBonus", [](Graphics*, float bonus) {
1441 ShadowSchemeSettings::current().hysteresisBonus = bonus;
1442 });
1443 cls.addFunc("setCloudShadows", &Graphics::setCloudShadows);
1444 cls.addFunc("newMaterial", &Graphics::newMaterial);
1445 cls.addFunc("getRenderControl", &Graphics::getRenderControl);
1446 cls.addFunc("setMsaaSamples", &Graphics::setMsaaSamples);
1447 cls.addFunc("getMsaaSamples", &Graphics::getMsaaSamples);
1448 cls.addFunc("getSceneColorTexture", &Graphics::getSceneColorTexture);
1449 cls.addFunc("newQuad", &Graphics::newQuad);
1450 cls.addFunc("newVolumetric", &Graphics::newVolumetric);
1451 cls.addFunc("newDepthOfField", &Graphics::newDepthOfField);
1452 cls.addFunc("newAmbientOcclusion", &Graphics::newAmbientOcclusion);
1453 cls.addFunc("newOutline", &Graphics::newOutline);
1454 cls.addFunc("newAlphaMask", &Graphics::newAlphaMask);
1455 cls.addFunc("newMapFog", &Graphics::newMapFog);
1456 cls.addFunc("getOutline", &Graphics::pipelineOutline);
1457 cls.addFunc("newGlobalIllumination", &Graphics::newGlobalIllumination);
1458 cls.addFunc("newScreenSpaceReflection", &Graphics::newScreenSpaceReflection);
1459 cls.addFunc("newAntiAliasing", &Graphics::newAntiAliasing);
1460 cls.addFunc("drawOcclusionSolid", &Graphics::drawOcclusionSolid);
1461 cls.addFunc("drawOcclusionTexture", &Graphics::drawOcclusionTexture);
1462}
1463
1464void Graphics::reset() {
1465 currentShader = nullptr;
1466 currentFont = nullptr;
1467}
1468
1469Renderable2D* Graphics::newSprite2D() { return Renderable2D::create(); }
1470
1471void Graphics::renderSprites() {
1472 std::vector<DrawItem2D> items;
1473 RenderSystem::collectSprites(items);
1474 RenderSystem::drawItems(*this, items, false);
1475}
1476
1477void Graphics::initHeadless(int width, int height) {
1478 (void)width;
1479 (void)height;
1480 throw Exception("Graphics::initHeadless: not supported on this backend");
1481}
1482
1483void Graphics::setShader(Shader* shader) { currentShader = shader; }
1484
1485void Graphics::setShader() { currentShader = nullptr; }
1486
1487Volumetric* Graphics::newVolumetric() { return new Volumetric(this); }
1488
1489DepthOfField* Graphics::newDepthOfField() { return new DepthOfField(this); }
1490
1491AmbientOcclusion* Graphics::newAmbientOcclusion() { return new AmbientOcclusion(this); }
1492
1493Outline* Graphics::newOutline() { return new Outline(this); }
1494AlphaMask* Graphics::newAlphaMask() { return new AlphaMask(this); }
1495
1496MapFog* Graphics::newMapFog() { return new MapFog(this); }
1497
1498GlobalIllumination* Graphics::newGlobalIllumination() { return new GlobalIllumination(this); }
1499
1500ScreenSpaceReflection* Graphics::newScreenSpaceReflection() { return new ScreenSpaceReflection(this); }
1501
1502AmbientOcclusion* Graphics::pipelineAmbientOcclusion() {
1503 if (!pipelineAO_) pipelineAO_ = std::make_unique<AmbientOcclusion>(this);
1504 return pipelineAO_.get();
1505}
1506
1507GlobalIllumination* Graphics::pipelineGlobalIllumination() {
1508 if (!pipelineGI_) pipelineGI_ = std::make_unique<GlobalIllumination>(this);
1509 return pipelineGI_.get();
1510}
1511
1512AntiAliasing* Graphics::pipelineAntiAliasing() {
1513 if (!pipelineAA_) pipelineAA_ = std::make_unique<AntiAliasing>(this);
1514 return pipelineAA_.get();
1515}
1516
1517Bloom* Graphics::pipelineBloom() {
1518 if (!pipelineBloom_) pipelineBloom_ = std::make_unique<Bloom>(this);
1519 return pipelineBloom_.get();
1520}
1521
1522DepthOfField* Graphics::pipelineDepthOfField() {
1523 if (!pipelineDof_) pipelineDof_ = std::make_unique<DepthOfField>(this);
1524 return pipelineDof_.get();
1525}
1526
1527Exposure* Graphics::pipelineExposure() {
1528 if (!pipelineExposure_) pipelineExposure_ = std::make_unique<Exposure>(this);
1529 return pipelineExposure_.get();
1530}
1531
1532DepthPyramid* Graphics::pipelineDepthPyramid() {
1533 if (!pipelineDepthPyramid_) pipelineDepthPyramid_ = std::make_unique<DepthPyramid>(this);
1534 return pipelineDepthPyramid_.get();
1535}
1536
1537void Graphics::setSceneDepthOfField(float focusDistance, float maximumBlurPixels, float focusRange, float nearPlane,
1538 float farPlane) {
1539 sceneDepthOfFieldEnabled_ = maximumBlurPixels > 0.f;
1540 sceneDepthOfFieldFocusDistance_ = focusDistance;
1541 sceneDepthOfFieldFocusRange_ = focusRange;
1542 sceneDepthOfFieldMaximumBlurPixels_ = maximumBlurPixels;
1543 sceneDepthOfFieldNearPlane_ = nearPlane;
1544 sceneDepthOfFieldFarPlane_ = farPlane;
1545}
1546Texture* Graphics::prepareFinalSceneTexture(Texture* scene, Texture* motion) {
1547 if (!scene) return nullptr;
1548 Texture* resolved = scene;
1549 AntiAliasing* aa = pipelineAntiAliasing();
1550 const bool temporal = renderControl_ && renderControl_->isEnabled("taa");
1551 const bool spatial = !renderControl_ || renderControl_->isEnabled("aa");
1552 const std::string requested = renderControl_ ? renderControl_->getPostProcessQuality() : "high";
1553 const std::string quality = requested == "ultra" ? "high" : requested;
1554 if (aa->getQuality() != quality) aa->setQuality(quality);
1555 if (temporal) {
1556 aa->setMode("taa");
1557 resolved = aa->resolveTemporal(this, scene, motion);
1558 } else if (spatial) {
1559 aa->setMode("fxaa");
1560 const int width = std::max(scene->getWidth(), 1);
1561 const int height = std::max(scene->getHeight(), 1);
1562 if (!spatialAAResolve_ || spatialAAResolveWidth_ != width || spatialAAResolveHeight_ != height) {
1563 spatialAAResolve_ = newHDRCanvas(width, height);
1564 spatialAAResolveWidth_ = width;
1565 spatialAAResolveHeight_ = height;
1566 }
1567 aa->applyTo(this, scene, spatialAAResolve_);
1568 resolved = spatialAAResolve_->getTexture();
1569 }
1570 if (getSceneDofMaxBlur() > 0.f && renderControl_) {
1571 GBuffer* gb = renderControl_->getGBuffer();
1572 if (gb && gb->isValid()) {
1573 Texture* depth = getBackendName() == "webgpu" ? gb->getDepthTexture() : gb->getHwDepthTexture();
1574 if (depth) {
1575 resolved =
1576 pipelineDepthOfField()->apply(resolved, depth, getSceneDofFocusDistance(), getSceneDofMaxBlur(),
1577 getSceneDofFocusRange(), getSceneDofNearZ(), getSceneDofFarZ());
1578 }
1579 }
1580 }
1581 Texture* meterSource = resolved;
1582 resolved = pipelineBloom()->apply(resolved, getSceneBloomIntensity(), getSceneBloomThreshold());
1583 return pipelineExposure()->apply(resolved, getSceneExposure(), getSceneAutoExposure(), getSceneAutoExposureMinEV(),
1584 getSceneAutoExposureMaxEV(), getSceneColorFilter(), getSceneLift(),
1585 getSceneInverseGamma(), getSceneGain(), getSceneTransitionVignette(),
1586 getSceneTransitionVignetteSmoothness(), getSceneTransitionLensDistortion(),
1587 getSceneTransitionLensScale(), meterSource);
1588}
1589
1590Canvas* Graphics::pipelineReflectionComposite(int width, int height) {
1591 width = std::max(width, 1);
1592 height = std::max(height, 1);
1593 if (!reflectionComposite_ || reflectionCompositeWidth_ != width || reflectionCompositeHeight_ != height) {
1594 reflectionComposite_ = newHDRCanvas(width, height);
1595 reflectionCompositeWidth_ = width;
1596 reflectionCompositeHeight_ = height;
1597 }
1598 return reflectionComposite_;
1599}
1600
1601ScreenSpaceReflection* Graphics::pipelineScreenSpaceReflection() {
1602 if (!pipelineSSR_) pipelineSSR_ = std::make_unique<ScreenSpaceReflection>(this);
1603 return pipelineSSR_.get();
1604}
1605
1606Outline* Graphics::pipelineOutline() {
1607 if (!pipelineOutline_) pipelineOutline_ = std::make_unique<Outline>(this);
1608 return pipelineOutline_.get();
1609}
1610
1611AntiAliasing* Graphics::newAntiAliasing() { return new AntiAliasing(this); }
1612
1613Shader* Graphics::newHairShader() { return hair::createShader(this); }
1614
1615Mesh* Graphics::newHairCardMesh(float width, float height) { return hair::newCardMesh(this, width, height); }
1616
1617Material* Graphics::newHairCardMaterial(Texture* albedo) { return hair::makeCardMaterial(this, albedo, nullptr); }
1618
1619Shader* Graphics::newGrassShader() { return grass::createShader(this); }
1620
1621Shader* Graphics::newTreeWindShader() { return createTreeWindShader(this); }
1622
1623GrassField* Graphics::newGrassField() { return new GrassField(this); }
1624
1625hair::GroomInstance* Graphics::newGroomInstance() { return new hair::GroomInstance(this); }
1626
1627Waterfall* Graphics::newWaterfall() { return new Waterfall(this); }
1628Water* Graphics::newWater() { return new Water(this); }
1629
1630ReflectionProbeCapture* Graphics::newReflectionProbeCapture() { return new ReflectionProbeCapture(this); }
1631
1632ReflectionProbeRegistry* Graphics::newReflectionProbeRegistry() { return new ReflectionProbeRegistry(); }
1633
1634Mesh* Graphics::newMeshCube(float size) {
1635 const float h = size * 0.5f;
1636 // 6 faces x 4 corners (per-face normal + full 0..1 UV), outward CCW for RH Y-up.
1637 const float kFaces[6][4][3] = {
1638 {{-h, -h, h}, {h, -h, h}, {h, h, h}, {-h, h, h}}, // +Z
1639 {{h, -h, -h}, {-h, -h, -h}, {-h, h, -h}, {h, h, -h}}, // -Z
1640 {{h, -h, h}, {h, -h, -h}, {h, h, -h}, {h, h, h}}, // +X
1641 {{-h, -h, -h}, {-h, -h, h}, {-h, h, h}, {-h, h, -h}}, // -X
1642 {{-h, h, h}, {h, h, h}, {h, h, -h}, {-h, h, -h}}, // +Y
1643 {{-h, -h, -h}, {h, -h, -h}, {h, -h, h}, {-h, -h, h}}, // -Y
1644 };
1645 const float kN[6][3] = {{0, 0, 1}, {0, 0, -1}, {1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}};
1646 const float kUV[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
1647
1648 std::vector<float> pos, nrm, uv;
1649 pos.reserve(6 * 4 * 3);
1650 nrm.reserve(6 * 4 * 3);
1651 uv.reserve(6 * 4 * 2);
1652 std::vector<uint32_t> indices;
1653 indices.reserve(6 * 6);
1654 for (int f = 0; f < 6; ++f) {
1655 const uint32_t base = uint32_t(f * 4);
1656 for (int c = 0; c < 4; ++c) {
1657 pos.insert(pos.end(), kFaces[f][c], kFaces[f][c] + 3);
1658 nrm.insert(nrm.end(), kN[f], kN[f] + 3);
1659 uv.insert(uv.end(), kUV[c], kUV[c] + 2);
1660 }
1661 indices.push_back(base + 0);
1662 indices.push_back(base + 1);
1663 indices.push_back(base + 2);
1664 indices.push_back(base + 0);
1665 indices.push_back(base + 2);
1666 indices.push_back(base + 3);
1667 }
1668 return newMeshFromArrays(pos.data(), nrm.data(), uv.data(), int(pos.size() / 3), indices.data(),
1669 int(indices.size()));
1670}
1671
1672bool Graphics::saveFramePng(const std::string& path) {
1673 if (!screenReadbackEnabled) setScreenReadbackEnabled(true);
1674 std::unique_ptr<eve::image::ImageData> frame;
1675 try {
1676 frame.reset(newImageData());
1677 } catch (...) {
1678 return false; // no presented frame yet
1679 }
1680 if (!frame) return false;
1681 std::unique_ptr<eve::filesystem::FileData> png(
1682 frame->encode(medialoader::FormatHandler::ENCODED_PNG, path.c_str(), false));
1683 if (!png) return false;
1684 std::error_code ec;
1685 std::filesystem::create_directories(std::filesystem::path(path).parent_path(), ec);
1686 std::ofstream out(path, std::ios::binary);
1687 if (!out.good()) return false;
1688 out.write(static_cast<const char*>(png->getData()), static_cast<std::streamsize>(png->getSize()));
1689 return out.good();
1690}
1691
1692void Graphics::draw(Drawable* drawable, const glm::mat4& m) {
1693 if (drawable) drawable->draw(this, m);
1694}
1695
1696void Graphics::drawOcclusion(Drawable* drawable, const glm::mat4& m) {
1697 if (drawable && drawable->getCastOcclusion()) drawable->drawOcclusion(this, m);
1698}
1699
1700void Graphics::drawOcclusionSolid(float x, float y, float w, float h) {
1701 drawSolidRect(x, y, w, h, Color(0.f, 0.f, 0.f, 1.f));
1702}
1703
1704void Graphics::drawOcclusionTexture(Texture* texture, float x, float y, float w, float h) {
1705 // Black RGB keeps silhouette; texture alpha cuts soft edges (same idea as shadow masks).
1706 drawTexturedRect(texture, x, y, w, h, Color(0.f, 0.f, 0.f, 1.f));
1707}
1708
1709void Graphics::clearScreen() { clear(std::nullopt, std::nullopt, std::nullopt); }
1710
1711void Graphics::setBackgroundColorRGBA(float r, float g, float b, float a) { setBackgroundColor(Color(r, g, b, a)); }
1712
1713void Graphics::drawSolidRectRGBA(float x, float y, float w, float h, float r, float g, float b, float a) {
1714 drawSolidRect(x, y, w, h, Color(r, g, b, a));
1715}
1716
1717void Graphics::drawTexturedRectRGBA(Texture* texture, float x, float y, float w, float h, float r, float g, float b,
1718 float a) {
1719 drawTexturedRect(texture, x, y, w, h, Color(r, g, b, a));
1720}
1721
1722void Graphics::drawTexturedRectRotatedRGBA(Texture* texture, float cx, float cy, float w, float h, float degrees,
1723 float r, float g, float b, float a) {
1724 drawTexturedRectShaderUVRotated(texture, nullptr, cx, cy, w, h, degrees, 0.f, 0.f, 1.f, 1.f, Color(r, g, b, a),
1725 false, BlendMode::Alpha);
1726}
1727
1728void Graphics::drawSolidRect(float x, float y, float w, float h, float r, float g, float b, float a) {
1729 drawSolidRectRGBA(x, y, w, h, r, g, b, a);
1730}
1731
1732void Graphics::drawTexturedRect(Texture* texture, float x, float y, float w, float h, float r, float g, float b,
1733 float a) {
1734 drawTexturedRectRGBA(texture, x, y, w, h, r, g, b, a);
1735}
1736
1737Texture* Graphics::newTextureFromImageData(image::ImageData* data, bool repeatU, bool repeatV) {
1738 if (!data) throw eve::Exception("newTextureFromImageData: null ImageData");
1739 if (data->getFormat() != "RGBA8") throw eve::Exception("newTextureFromImageData: only RGBA8 supported");
1742 info.sampler.repeatV = repeatV;
1743 return newTexture(data->getWidth(), data->getHeight(), static_cast<const uint8_t*>(data->getData()), info);
1744}
1745
1746Texture* Graphics::newTextureFromImageData(image::ImageData* data, const TextureCreateInfo& info) {
1747 if (!data) throw eve::Exception("newTextureFromImageData: null ImageData");
1748 if (data->getFormat() != "RGBA8") throw eve::Exception("newTextureFromImageData: only RGBA8 supported");
1749 return newTexture(data->getWidth(), data->getHeight(), static_cast<const uint8_t*>(data->getData()), info);
1750}
1751
1752eve::Result<void> Graphics::updateTextureFromImageData(Texture* texture, image::ImageData* data) {
1753 ensureFileTexturesReady();
1754 if (!texture || !data)
1756 "texture and ImageData must be non-null",
1757 "graphics.updateTextureFromImageData"));
1758 if (data->getFormat() != "RGBA8")
1760 "only RGBA8 ImageData is supported",
1761 "graphics.updateTextureFromImageData.format"));
1762 if (!updateTexture(texture, data->getWidth(), data->getHeight(), static_cast<const uint8_t*>(data->getData())))
1764 eve::DiagnosticCode::Failed, "texture is not owned by this backend, dimensions differ, or upload failed",
1765 "graphics.updateTextureFromImageData"));
1767}
1768
1769void Graphics::requestFileImageDecode(const std::string& key) {
1771 if (!queued.ok()) throw eve::Exception("%s", queued.status().describe().c_str());
1772}
1773
1774bool Graphics::fileTextureSourceExists(const std::string& filename) const {
1775 auto* fs = eve::filesystem::Filesystem::create();
1776 if (!fs) return false;
1778 return fs->getInfo(filename, info);
1779}
1780
1781void Graphics::dropDeferredFileTexture(Texture* texture) {
1782 if (!texture) return;
1783 deferredFileTextures_.erase(
1784 std::remove_if(deferredFileTextures_.begin(), deferredFileTextures_.end(),
1785 [texture](const DeferredFileTexture& item) { return item.texture == texture; }),
1786 deferredFileTextures_.end());
1787 texture->clearDeferredFilePixels();
1788}
1789
1790bool Graphics::uploadDeferredFileTexture(Texture* texture, image::ImageData* data) {
1791 if (!texture || !data) return false;
1792 if (data->getFormat() != "RGBA8") return false;
1793 return updateTexture(texture, data->getWidth(), data->getHeight(), static_cast<const uint8_t*>(data->getData()));
1794}
1795
1796void Graphics::ensureFileTexturesReady() {
1797 if (deferredFileTextures_.empty() || realizingFileTextures_) return;
1798 realizingFileTextures_ = true;
1799 StartupStage stage("graphics: realize file textures");
1800 struct Guard {
1801 Graphics* g;
1802 ~Guard() { g->realizingFileTextures_ = false; }
1803 } guard{this};
1804
1805 std::vector<DeferredFileTexture> pending = std::move(deferredFileTextures_);
1806 deferredFileTextures_.clear();
1807
1808 auto restoreUnrealized = [&]() {
1809 for (const auto& item : pending) {
1810 if (item.texture && item.texture->hasDeferredFilePixels()) deferredFileTextures_.push_back(item);
1811 }
1812 };
1813
1815 for (const auto& item : pending) {
1816 auto waited = resources.waitFor(item.key);
1817 if (!waited.ok()) {
1818 restoreUnrealized();
1819 throw eve::Exception("%s", waited.status().describe().c_str());
1820 }
1821 }
1822
1823 try {
1824 for (const auto& item : pending) {
1825 auto waited = resources.waitFor(item.key);
1826 if (!waited.ok()) throw eve::Exception("%s", waited.status().describe().c_str());
1827 auto* data = dynamic_cast<image::ImageData*>(&waited.value().get());
1828 if (!data || !uploadDeferredFileTexture(item.texture, data))
1829 throw eve::Exception("newTextureFromFile: GPU upload failed '%s'", item.key.c_str());
1830 if (item.texture) item.texture->clearDeferredFilePixels();
1831 }
1832 } catch (...) {
1833 restoreUnrealized();
1834 throw;
1835 }
1836}
1837
1838Texture* Graphics::newTextureFromFileRepeated(const std::string& filename, bool repeatU, bool repeatV) {
1839 if (filename.empty()) throw eve::Exception("newTextureFromFileRepeated: empty filename");
1840 auto* fs = eve::filesystem::Filesystem::create();
1841 std::unique_ptr<eve::filesystem::FileData> fileData(fs->read(filename));
1842 if (!fileData) throw eve::Exception("newTextureFromFileRepeated: failed to read '%s'", filename.c_str());
1843 auto* imgMod = eve::image::Image::create();
1844 std::unique_ptr<eve::image::ImageData> data(imgMod->newImageData(fileData.get()));
1845 return newTextureFromImageData(data.get(), repeatU, repeatV);
1846}
1847
1848Texture* Graphics::newTextureWithSampler(image::ImageData* data, bool repeatU, bool repeatV, bool generateMipmaps,
1849 float maxAnisotropy, const std::string& filter, const std::string& mipmap,
1850 float lodBias) {
1852 info.generateMipmaps = generateMipmaps;
1853 info.sampler.min = TextureSampler::parseFilter(filter);
1854 info.sampler.mag = info.sampler.min;
1855 info.sampler.mipmap = TextureSampler::parseMipmap(mipmap);
1856 if (generateMipmaps && info.sampler.mipmap == MipmapMode::Disabled) info.sampler.mipmap = MipmapMode::Linear;
1857 info.sampler.repeatU = repeatU;
1858 info.sampler.repeatV = repeatV;
1859 info.sampler.maxAnisotropy = maxAnisotropy;
1860 info.sampler.lodBias = lodBias;
1861 return newTextureFromImageData(data, info);
1862}
1863
1864void Graphics::setTextureSampler(Texture* texture, const std::string& filter, const std::string& mipmap,
1865 float maxAnisotropy, float lodBias) {
1866 if (!texture) return;
1867 // Fail fast on typos instead of silently treating an unknown filter as linear.
1868 if (filter != "nearest" && filter != "Nearest" && filter != "NEAREST" && filter != "linear" && filter != "Linear" &&
1869 filter != "LINEAR") {
1870 throw eve::Exception("Graphics::setTextureSampler: unknown filter '%s'", filter.c_str());
1871 }
1872 if (mipmap != "none" && mipmap != "None" && mipmap != "NONE" && mipmap != "nearest" && mipmap != "Nearest" &&
1873 mipmap != "NEAREST" && mipmap != "linear" && mipmap != "Linear" && mipmap != "LINEAR") {
1874 throw eve::Exception("Graphics::setTextureSampler: unknown mipmap mode '%s'", mipmap.c_str());
1875 }
1876 TextureSampler s = texture->getSampler();
1877 s.min = TextureSampler::parseFilter(filter);
1878 s.mag = s.min;
1879 s.mipmap = TextureSampler::parseMipmap(mipmap);
1880 s.maxAnisotropy = maxAnisotropy;
1881 s.lodBias = lodBias;
1882 setTextureSampler(texture, s);
1883}
1884
1885Quad* Graphics::newQuad(int x, int y, int w, int h) { return new Quad(x, y, w, h); }
1886
1887Font* Graphics::newFont(font::FontData* data, std::string charset) { return new Font(this, data, std::move(charset)); }
1888
1889void Graphics::print(const std::string& text, float x, float y, const Color& color, float scale) {
1890 if (currentFont == nullptr) {
1891 eve::debug::rtDraw("print", "no-font");
1892 throw eve::Exception("Graphics::print: no font set (call setFont first)");
1893 }
1894 drawText(currentFont, text, x, y, color, scale);
1895}
1896
1897void Graphics::drawText(Font* font, const std::string& text, float x, float y, const Color& color, float scale) {
1898 if (font == nullptr) {
1899 eve::debug::rtDraw("drawText", "no-font");
1900 throw eve::Exception("Graphics::drawText: font must not be null");
1901 }
1902 eve::debug::rtBind("font", "explicit");
1903 eve::debug::rtDraw("drawText", text.empty() ? "" : "text");
1904
1905 eve::font::FontData* data = font->getData();
1906 float penX = x;
1907 float baseline = y + font->getBaseline() * scale;
1908 int prevCodepoint = -1;
1909
1910 size_t i = 0;
1911 while (i < text.size()) {
1912 uint32_t cp = nextCodepointUtf8(text, i);
1913 if (cp == 0) continue;
1914 int code = static_cast<int>(cp);
1915
1916 if (prevCodepoint >= 0) penX += data->getKerning(prevCodepoint, code) * scale;
1917
1918 if (const Font::Glyph* g = font->findGlyph(code)) {
1919 if (g->width > 0 && g->height > 0) {
1920 float gx = penX + static_cast<float>(g->bearingX) * scale;
1921 float gy = baseline - static_cast<float>(g->bearingY) * scale;
1922 drawTexturedRectUV(font->getTexture(), gx, gy, static_cast<float>(g->width) * scale,
1923 static_cast<float>(g->height) * scale, g->u0, g->v0, g->u1, g->v1, color);
1924 }
1925 penX += static_cast<float>(g->advance) * scale;
1926 } else {
1927 // Not pre-rasterized into this Font's atlas — still advance the pen.
1928 penX += static_cast<float>(data->getGlyphAdvance(code)) * scale;
1929 }
1930
1931 prevCodepoint = code;
1932 }
1933}
1934
1935} // namespace eve::graphics
double value
float w
Definition AnimClip.cpp:738
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float z
Definition AnimClip.cpp:738
eve::action::ActionSpatialBinding spatial
const std::string & s
std::vector< QuestEvent > pending
float cx
Definition CardTypes.cpp:33
float cy
Definition CardTypes.cpp:34
float degrees
Definition CardTypes.cpp:35
float uv
graphics::Texture * albedo
Stable, structured diagnostics shared by engine modules.
HSQUIRRELVM vm
Definition ECS.cpp:20
HSQOBJECT cls
Definition ECS.cpp:21
DiagnosticCode code
std::uint32_t vertexCount
std::uint32_t indexCount
tensor::Graph g
Definition GpuGraph.cpp:7
float camera[2]
std::uint32_t key
glm::vec3 n
Definition Grass.cpp:63
double r
std::uint32_t aa
std::vector< std::uint32_t > indices
std::int32_t c
int h
std::uint32_t height
std::uint32_t width
std::string text
std::array< float, 3 > scale
std::string name
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
float distance
#define Module_IMPL(ModuleName, newExpr)
Definition Module.h:26
std::vector< std::weak_ptr< DeviceBytes > > resources
Definition OnnxGpgpu.cpp:55
size_t queued
Definition OnnxGpgpu.cpp:60
std::string error
Definition Package.cpp:60
int idx
float f
std::array< std::uint64_t, kPixelChunkSize *kPixelChunkSize > updated
float radius
std::string path
Definition PlayHost.cpp:110
std::weak_ptr< PrimitiveScene > scene
Mesh * mesh
Shader * shader
Material * material
float ambientG
float ambientR
float ambientB
bool repeatV
std::string filter
std::string mipmap
bool repeatU
float dz
Light3D::Data * light
float dy
float dx
Vec scattering
std::uint32_t count
The single Squirrel projection for common Result, Status and Value.
Explicit Value/Owned/Borrowed semantics at the Squirrel boundary.
TerrainWaterField water
TerrainThermalSettings settings
float size
Definition TreeMesh.cpp:156
std::uint32_t depth
float m[16]
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
EVENGINE_API_FOUNDATION public API.
Definition Exception.h:13
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
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:164
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
StartupStage public API.
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)
float worldToScreenY(float worldX, float worldY, float viewW, float viewH)
float worldToScreenX(float worldX, float worldY, float viewW, float viewH)
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).
static Camera2D * createCamera()
EVENGINE_API_BACKENDS public API.
void setBloom(float intensity, float threshold=1.f)
Configure HDR bloom. Zero intensity disables it.
float getEyeX()
Camera eye position (world space).
float getDofFocusDistance()
Return DOF focus distance.
float getNearClip()
Return the positive near clipping distance.
float getDofFocusRange()
Return DOF focus range.
void setShadowLayerCullDistance(int layer, float distance)
Set the shadow-caster cull distance for one render layer; zero disables it.
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.
float getExposure()
Return exposure compensation in photographic stops.
void setUp(float x, float y, float z)
void setOrthographic(float height)
Enable an orthographic projection with the given vertical world-space span.
void clearEnvProbe()
Disable box projection and return to an infinite-distance environment.
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.
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.
static Camera3D * createCamera()
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 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.
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.
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:17
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:37
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:28
void setCastOcclusion(bool cast)
Sets the cast occlusion.
Definition Drawable.h:30
GPU percentile metering, eye adaptation, and linear HDR pre-exposure.
Definition Exposure.h:13
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
float getAscent() const
Returns the ascent.
Definition Font.cpp:173
bool hasGlyph(int codepoint) const
Whether codepoint was rasterized into this Font's atlas.
Definition Font.cpp:178
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
float getHeight() const
Line height in pixels at the FontData's decoded pixel size.
Definition Font.cpp:172
float getWidth(const std::string &text) const
Pixel width of text (UTF-8), including kerning; delegates to FontData.
Definition Font.cpp:176
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:248
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:2265
bool recordingEngine3D_
True while RenderSystem3D is submitting (AO / engine overlays).
Definition Graphics.h:2249
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:229
virtual void renderScene3DToCanvas(Canvas *canvas, Camera3D *camera)
Preview-quality 3D pass into an offscreen Canvas (editor viewport): renders visible Renderable3D with...
Definition Graphics.cpp:203
Shader * prepareSceneColorResolveShader(Texture *scene)
FXAA resolve shader that writes opaque RGB (ignores scene-color depth alpha).
Definition Graphics.cpp:209
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:241
Material * newMaterial()
Create a Material asset (shading model + textures + PBR knobs). Caller owns Material*; not tracked by...
Definition Graphics.cpp:252
std::unique_ptr< RenderControl > renderControl_
Definition Graphics.h:2264
AntiAliasing * pipelineAntiAliasing()
Pipeline anti aliasing.
virtual void render3D()
Run RenderSystem3D (begin3DFrame + draw visible Renderable3D).
Definition Graphics.cpp:193
~Graphics() override
Graphics.
Definition Graphics.cpp:177
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.
virtual Texture * getSceneColorTexture()
Sampleable 3D color target for the current frame (RGB = lit, A = linear depth). Valid after begin3DFr...
Definition Graphics.h:1047
RenderControl * getRenderControl()
Shared compilable 3D render control (features → pass list + GBuffer). Owned by Graphics; valid for th...
Definition Graphics.cpp:254
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
float getVolumetricIntensity()
Definition Light.cpp:83
void setDirection(float dx, float dy)
Definition Light.cpp:45
void setPosition(float x, float y)
Definition Light.cpp:37
void setColor(float r, float g, float b, float intensity=1.f)
Definition Light.cpp:53
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:15
float getSpotSoftness()
Current spot softness in [0, 1].
Definition Light.cpp:72
void setVolumetric(bool enabled)
Definition Light.cpp:77
void setCanvas(Canvas *canvas)
Definition Light.cpp:88
void setVolumetricOnly(bool enabled)
Definition Light.cpp:85
void setVolumetricIntensity(float intensity)
Definition Light.cpp:80
float getSpotAngle()
Current outer half-angle in degrees.
Definition Light.cpp:67
void setType(const std::string &type)
Definition Light.cpp:27
void setEnabled(bool enabled)
Definition Light.cpp:74
void setSpotAngle(float degrees)
Outer half-angle of a spot cone in degrees (clamped to (0, 89]).
Definition Light.cpp:64
std::string getType()
Definition Light.cpp:35
static Light2D * createLight(const std::string &type="point")
Definition Light.cpp:7
void setRadius(float radius)
Definition Light.cpp:61
void setSpotSoftness(float softness)
Softness of the spot penumbra in [0, 1].
Definition Light.cpp:69
void setEnabled(bool enabled)
Definition Light.cpp:164
void setSpotAngle(float degrees)
Outer half-angle of a 3D spot cone in degrees (clamped to (0, 89]).
Definition Light.cpp:154
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:98
void setCastShadow(bool cast)
Definition Light.cpp:167
void setDirection(float dx, float dy, float dz)
Definition Light.cpp:132
void setShadowBias(float bias)
Definition Light.cpp:212
float getVolumetricIntensity()
Definition Light.cpp:226
void setVolumetricOnly(bool enabled)
Definition Light.cpp:228
float getShadowStrength()
Definition Light.cpp:218
void setShadowStrength(float strength)
Definition Light.cpp:215
void setPosition(float x, float y, float z)
Definition Light.cpp:121
static Light3D * createLight(const std::string &type="point")
Definition Light.cpp:90
void setType(const std::string &type)
Definition Light.cpp:111
void setVolumetricIntensity(float intensity)
Definition Light.cpp:223
void setShadowMethod(const std::string &method)
Request a shadow technique: auto, none, csm, perspective, cube. Invalid names leave the previous meth...
Definition Light.cpp:170
void setRadius(float radius)
Definition Light.cpp:151
void setColor(float r, float g, float b, float intensity=1.f)
Definition Light.cpp:143
void setSpotSoftness(float softness)
Softness of the spot penumbra in [0, 1].
Definition Light.cpp:159
float getSpotSoftness()
Current spot softness in [0, 1].
Definition Light.cpp:162
std::string getShadowMethod()
Current shadow method name (auto / none / csm / perspective / cube).
Definition Light.cpp:197
void setVolumetric(bool enabled)
Definition Light.cpp:220
float getSpotAngle()
Current spot outer half-angle in degrees.
Definition Light.cpp:157
std::string getType()
Definition Light.cpp:119
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:35
float getFloat(const std::string &name) const
Returns the float.
Definition Material.cpp:152
void setNormalTexture(Texture *texture)
Set the borrowed material texture. @ownership Graphics factory owns the resource. @lifetime Keep aliv...
Definition Material.h:123
void setAlbedoTexture(Texture *texture)
Set the borrowed material texture. @ownership Graphics factory owns the resource. @lifetime Keep aliv...
Definition Material.h:112
std::string getAlphaTechnique() const
Returns the alpha technique.
Definition Material.h:287
bool hasParam(const std::string &name) const
Optional named float knobs (style / custom shader params).
Definition Material.cpp:148
bool getHair() const
Returns the hair.
Definition Material.h:230
void setCastShadow(bool cast)
Sets the cast shadow.
Definition Material.h:213
void setCastOcclusion(bool cast)
Sets the cast occlusion.
Definition Material.h:223
void setHeightTexture(Texture *texture)
Sets the height texture.
Definition Material.h:131
float getMetallic() const
Returns the metallic.
Definition Material.h:182
Texture * getAlbedoTexture() const
Get the borrowed material texture. @ownership Graphics factory owns the resource. @lifetime Keep aliv...
Definition Material.h:117
void setAlphaTechnique(const std::string &technique)
Optional masked transparency quality: "cutoff", "dither", "coverage".
Definition Material.cpp:144
void setBlendMode(const std::string &mode)
Set "alpha", "premultiplied", "additive", or "multiply".
Definition Material.cpp:126
std::string getBlendMode() const
Returns the blend mode.
Definition Material.cpp:137
void setMetallic(float metallic)
Sets the metallic.
Definition Material.cpp:74
void setReceiveShadow(bool receive)
Sets the receive shadow.
Definition Material.h:218
Texture * getNormalTexture() const
Get the borrowed material texture. @ownership Graphics factory owns the resource. @lifetime Keep aliv...
Definition Material.h:128
float getRoughness() const
Returns the roughness.
Definition Material.h:187
float getAlphaCutoff() const
Returns the alpha cutoff.
Definition Material.h:261
bool getReceiveShadow() const
Returns the receive shadow.
Definition Material.h:220
void setCameraFacing(bool enabled)
Keep a bottom-anchored card facing the active camera around world Y during GPU-driven draws.
Definition Material.h:277
void clearVirtualTexture()
Restore conventional albedo/normal/height interpretation.
Definition Material.cpp:40
void setRoughness(float roughness)
Sets the roughness.
Definition Material.cpp:76
int getSortPriority() const
Returns the sort priority.
Definition Material.h:283
bool getCameraFacing() const
Return whether GPU-driven card vertices use cylindrical camera-facing orientation.
Definition Material.h:279
void setAlphaCutoff(float cutoff)
Sets the alpha cutoff.
Definition Material.cpp:124
bool getCastOcclusion() const
Returns the cast occlusion.
Definition Material.h:225
bool getDoubleSided() const
Returns the double sided.
Definition Material.h:275
void setReceiveLight(bool receive)
Sets the receive light.
Definition Material.h:208
void setSurfaceMode(const std::string &mode)
Set "opaque", "masked", or "transparent" surface classification.
Definition Material.cpp:109
void setShadingModel(const std::string &model)
"pbr" | "unlit" | "hair" | "custom" (unknown → pbr).
Definition Material.cpp:49
void setTexCellBomb(float cellScale, float strength, float rotAmount=1.f)
Sets the tex cell bomb.
Definition Material.cpp:80
bool getDepthWrite() const
Returns the depth write.
Definition Material.h:271
void setTint(float r, float g, float b, float a=1.f)
Sets the tint.
Definition Material.cpp:67
Shader * getShader() const
Return the borrowed shader, or nullptr when the built-in path is active. @lifetime The pointer remain...
Definition Material.h:166
void setDepthWrite(bool enabled)
Sets the depth write.
Definition Material.h:269
std::string getShadingModel() const
Returns the shading model.
Definition Material.h:50
std::string getSurfaceMode() const
Returns the surface mode.
Definition Material.cpp:118
void setParallax(float scale, float minLayers=8.f, float maxLayers=32.f)
Sets the parallax.
Definition Material.cpp:86
bool getCastShadow() const
Returns the cast shadow.
Definition Material.h:215
bool getReceiveLight() const
Returns the receive light.
Definition Material.h:210
void setFloat(const std::string &name, float value)
Sets the float.
Definition Material.cpp:150
void setSortPriority(int priority)
Sets the sort priority.
Definition Material.h:281
void setHair(bool hair)
Sets the hair.
Definition Material.cpp:95
Texture * getHeightTexture() const
Returns the height texture.
Definition Material.h:133
void setShader(Shader *shader)
Set an optional Mesh3D / hair shader; nullptr selects the built-in shading path.
Definition Material.h:163
void setDoubleSided(bool enabled)
Sets the double sided.
Definition Material.h:273
GPU mesh handle (+ optional CPU morph targets).
Definition Mesh.h:25
bool hasMorphData() const
True when morph data.
Definition Mesh.h:110
bool isMorphDirty() const
True when morph dirty.
Definition Mesh.h:106
bool setMorphWeight(const std::string &name, float weight)
Sets the morph weight.
Definition Mesh.cpp:202
bool hasMorph(const std::string &name) const
True when morph.
Definition Mesh.cpp:198
float getMorphWeight(const std::string &name) const
Returns the morph weight.
Definition Mesh.cpp:214
void clearMorphWeights()
Clears morph weights.
Definition Mesh.cpp:219
int getMorphCount() const
Returns the morph count.
Definition Mesh.cpp:191
std::string getMorphName(int index) const
Returns the morph name.
Definition Mesh.cpp:193
int getVertexCount() const
Returns the vertex count.
Definition Mesh.cpp:186
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)
Enables .
std::string getReflectionQuality() const
Return the shared TAA/RTGI/SSR quality preset.
void disable(const std::string &feature)
Disables .
bool isDeferredLightingAvailable() const
True when deferredLighting can be inserted for Hybrid. Requires an attached Graphics backend that imp...
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 or GB...
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 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)
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:39
bool hasUniform(const std::string &name) const
Definition Shader.cpp:59
void sendVec2(const std::string &name, float x, float y)
Definition Shader.cpp:97
int declareVec2(const std::string &name)
Definition Shader.cpp:44
void sendFloat(const std::string &name, float x)
Definition Shader.cpp:95
void sendVec3(const std::string &name, float x, float y, float z)
Definition Shader.cpp:102
int declareMatrix(const std::string &name)
Definition Shader.cpp:47
int getUniformIndex(const std::string &name) const
Definition Shader.cpp:61
int declareVec3(const std::string &name)
Definition Shader.cpp:45
int declareVec4(const std::string &name)
Definition Shader.cpp:46
int declareFloat(const std::string &name)
Reserve sequential float slots in the push-constant block. Returns start index.
Definition Shader.cpp:43
void sendVec4(const std::string &name, float x, float y, float z, float w)
Definition Shader.cpp:107
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:18
void clearDeferredFilePixels()
Clears deferred file pixels.
Definition Texture.cpp:22
int getMipmapCount() const
Returns the mipmap count.
Definition Texture.cpp:48
const TextureSampler & getSampler() const
Returns the sampler.
Definition Texture.h:41
std::string getAlphaConvention() const
Returns the alpha convention.
Definition Texture.h:47
void setAlphaConvention(const std::string &value)
Declare whether RGB is straight or already multiplied by alpha.
Definition Texture.h:43
int getWidth() const
Returns the width.
Definition Texture.cpp:28
int getHeight() const
Returns the height.
Definition Texture.cpp:33
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:34
Runtime groom drawable (UE UGroomComponent analogue).
EVENGINE_API_BACKENDS public API.
Definition Graphics.h:342
EVENGINE_API_BACKENDS public API.
Definition Graphics.h:191
Represents raw pixel data.
Definition ImageData.h:38
Graphics-owned CPU resource provider for generated mesh artifacts.
void rtBind(const char *kind, const char *name)
Rt bind.
Definition RenderTrace.h:62
void rtFrameBegin()
Rt frame begin.
Definition RenderTrace.h:42
void rtFrameEnd()
Rt frame end.
Definition RenderTrace.h:46
void rtDraw(const char *api, const char *detail=nullptr)
Rt draw.
Definition RenderTrace.h:66
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:117
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.
eve::Color Color
RGBA color used by every graphics draw call. Lives inside eve::graphics so including a graphics heade...
Definition Color.h:13
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.
WaterMeshType
Pcg procedural water mesh shape. Custom meshes remain caller-supplied Mesh resources.
Definition Water.h:15
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.
EVENGINE_API_BACKENDS void exposeGrassWindBindings(ssq::Table &table)
Register wind state/profile and checked operations on the VM owner thread, retaining no table referen...
EVENGINE_API_BACKENDS void exposeWaterPlanarReflectionBindings(ssq::Table &table)
Register planar water-reflection value types and checked planner with the VM owner thread.
void registerGraphicsArtifactProvider(Graphics *graphics)
Register the graphics provider in the common capability registry.
void exposePcgWaterPhotoModeBindings(ssq::Table &t)
Register Pcg water photo-mode authority bindings.
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...
const EditorValue * field(const EditorValue &value, const char *name)
std::unordered_map< std::string, SkillDefinition > & table()
Definition Skill.cpp:65
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
DiagnosticCode
Stable machine-readable diagnostic codes.
Definition Diagnostic.h:47
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:2225
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