VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
graphicsDevice.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3//
4// Created by Arnis Lektauers on 11.09.2025.
5//
6#pragma once
7
8#include <array>
9#include <map>
10#include <memory>
11#include <string>
12#include <unordered_map>
13#include <unordered_set>
14#include <vector>
15
16#include "blendState.h"
17#include "depthState.h"
18#include "dynamicBuffers.h"
19#include "gpuProfiler.h"
20#include "indexBuffer.h"
21#include "renderPass.h"
22#include "renderTarget.h"
23#include "shader.h"
24#include "stencilParameters.h"
25#include "vertexBuffer.h"
26#include "core/math/color.h"
27#include "core/math/matrix4.h"
28#include "core/math/vector3.h"
29#include "core/eventHandler.h"
30#include "scene/mesh.h"
31
32namespace visutwin::canvas
33{
34 class Compute;
35 class Texture;
36 class Material;
38
39 enum class GpuLightType : uint32_t
40 {
42 Point = 1u,
43 Spot = 2u,
45 };
46
50 {
53 Vector3 direction = Vector3(0.0f, -1.0f, 0.0f);
54 Color color = Color(1.0f, 1.0f, 1.0f, 1.0f);
55 float intensity = 0.0f;
56 float range = 0.0f;
57 float innerConeCos = 1.0f;
58 float outerConeCos = 1.0f;
59 bool falloffModeLinear = true;
60 bool castShadows = false;
61
62 // Local light shadow data (spot/point).
63 int shadowMapIndex = -1; // -1 = no shadow, 0 = slot 11, 1 = slot 12
64
65 // Area rect light: half-extents and local right axis (world space).
66 float areaHalfWidth = 0.0f;
67 float areaHalfHeight = 0.0f;
68 Vector3 areaRight = Vector3(1.0f, 0.0f, 0.0f);
69 };
70
71 struct FogParams
72 {
73 bool enabled = false;
74 Color color = Color(0.0f, 0.0f, 0.0f, 1.0f);
75 float start = 10.0f;
76 float end = 100.0f;
77 float density = 0.01f;
78 };
79
81 {
82 bool enabled = false;
83 float bias = 0.001f;
84 float normalBias = 0.0f;
85 float strength = 1.0f;
86 Texture* shadowMap = nullptr;
87
88 // Single VP matrix for backward compat (cascade 0).
90
91 // CSM data (_shadowMatrixPalette, _shadowCascadeDistances).
92 int numCascades = 1;
93 float cascadeBlend = 0.0f;
94 float shadowMatrixPalette[64] = {}; // 4 cascade VP matrices (viewport-scaled)
95 float shadowCascadeDistances[4] = {}; // per-cascade split distances
96
97 // Local light shadows (up to 2 simultaneous shadow-casting local lights).
98 static constexpr int kMaxLocalShadows = 2;
100 struct LocalShadow {
101 Texture* shadowMap = nullptr;
103 float bias = 0.0001f;
104 float normalBias = 0.0f;
105 float intensity = 1.0f;
106 bool isOmni = false; // true = cubemap shadow (omni), false = 2D shadow (spot)
108 };
109
111 {
114 Texture* cocTexture = nullptr;
117 float bloomIntensity = 0.01f;
118 float dofIntensity = 1.0f;
119 float sharpness = 0.0f;
120 int toneMapping = 0;
121 float exposure = 1.0f;
122 bool dofEnabled = false;
123 bool taaEnabled = false;
124 bool blurTextureUpscale = false;
125
126 // Single-pass DOF (computed in compose shader from depth buffer)
127 Texture* depthTexture = nullptr; // scene depth buffer
128 float dofFocusDistance = 1.0f; // linear depth at perfect focus
129 float dofFocusRange = 0.5f; // transition zone width
130 float dofBlurRadius = 3.0f; // max blur in pixels
131 float dofCameraNear = 0.01f;
132 float dofCameraFar = 100.0f;
133
134 // Vignette
135 bool vignetteEnabled = false;
136 float vignetteInner = 0.5f; // inner radius — fully clear inside this
137 float vignetteOuter = 1.0f; // outer radius — darkest at this edge
138 float vignetteCurvature = 0.5f; // edge curvature (higher = more rounded)
139 float vignetteIntensity = 0.3f; // max darkness
140 float vignetteColor[3] = {0.0f, 0.0f, 0.0f}; // darkening color (black)
141 };
142
144 {
146 float aspect = 1.0f;
147 float invResolutionX = 0.0f;
148 float invResolutionY = 0.0f;
149 int sampleCount = 12;
150 float spiralTurns = 10.0f;
151 float angleIncCos = 0.0f;
152 float angleIncSin = 0.0f;
153 float invRadiusSquared = 0.0f;
155 float bias = 0.001f;
156 float peak2 = 0.0f;
157 float intensity = 0.0f;
158 float power = 6.0f;
160 float randomize = 0.0f;
161 float cameraNear = 0.1f;
162 float cameraFar = 1000.0f;
163 };
164
166 {
168 float focusDistance = 100.0f;
169 float focusRange = 10.0f;
170 float cameraNear = 0.1f;
171 float cameraFar = 1000.0f;
172 bool nearBlur = false;
173 };
174
176 {
177 Texture* nearTexture = nullptr; // half-res scene (for near blur)
178 Texture* farTexture = nullptr; // far-field pre-multiplied texture
179 Texture* cocTexture = nullptr; // CoC texture from the CoC pass
180 float blurRadiusNear = 3.0f;
181 float blurRadiusFar = 3.0f;
182 int blurRings = 4;
184 float invResolutionX = 0.0f;
185 float invResolutionY = 0.0f;
186 };
187
189 {
192 int filterSize = 4;
195 float cameraNear = 0.1f;
196 float cameraFar = 1000.0f;
197 };
198
199 // DEVIATION: blurred planar reflection parameters.
200 // Upstream implements these as per-material parameters on the BlurredPlanarReflection script;
201 // we promote them to device-level so the forward pass can read them from LightingData.
203 {
204 float intensity = 1.0f; // Reflection intensity (0..1). 0 = no reflection visible.
205 float blurAmount = 0.0f; // Blur radius multiplier (0..2). 0 = sharp, 1+ = blurry.
206 float fadeStrength = 1.0f; // Distance-based fade strength (0..5). Higher = quicker fade.
207 float angleFade = 0.5f; // Fresnel fade exponent (0..1). Higher = more fade when looking straight down.
208 Color fadeColor = Color(0.5f, 0.5f, 0.5f, 1.0f); // Color to fade reflections into.
209 float planeDistance = 0.0f; // World Y of reflection plane (negated: d = -dot(normal, pointOnPlane)).
210 float heightRange = 10.0f; // Height normalization range for depth pass distance output.
211 };
212
214 {
215 int texShadow = 0;
216 int texAsset = 0;
217 int texLightmap = 0;
218
219 int tex = 0;
220 int vb = 0;
221 int ib = 0;
222 int ub = 0;
223 int sb = 0;
224 };
225
226 /*
227 * The graphics device manages the underlying graphics context
228 */
239 {
240 public:
241 virtual ~GraphicsDevice();
242
243 // Function which executes at the start of the frame
244 void frameStart();
245
246 // Function which executes at the end of the frame
247 void frameEnd();
248
249 std::shared_ptr<RenderTarget> backBuffer() const { return _backBuffer; }
250
251 // Submits a graphical primitive to the hardware for immediate rendering
252 virtual void draw(const Primitive& primitive, const std::shared_ptr<IndexBuffer>& indexBuffer = nullptr,
253 int numInstances = 1, int indirectSlot = -1, bool first = true, bool last = true) = 0;
254 virtual void setTransformUniforms(const Matrix4& viewProjection, const Matrix4& model) {}
255 virtual void setLightingUniforms(const Color& ambientColor, const std::vector<GpuLightData>& lights,
256 const Vector3& cameraPosition, bool enableNormalMaps, float exposure,
257 const FogParams& fogParams = FogParams{}, const ShadowParams& shadowParams = ShadowParams{},
258 int toneMapping = 0) {}
259 virtual void setEnvironmentUniforms(Texture* envAtlas, float skyboxIntensity, float skyboxMip,
260 const Vector3& skyDomeCenter = Vector3(0,0,0), bool isDome = false,
261 Texture* skyboxCubeMap = nullptr) {}
262
265 virtual void setAtmosphereUniforms(const void* data, size_t size) { (void)data; (void)size; }
266
268 void setAtmosphereEnabled(bool value) { _atmosphereEnabled = value; }
269 bool atmosphereEnabled() const { return _atmosphereEnabled; }
270
273 virtual std::shared_ptr<Shader> createShader(const ShaderDefinition& definition,
274 const std::string& sourceCode = "");
275
276 void setShader(const std::shared_ptr<Shader>& shader) { _shader = shader; }
277
278 void setVertexBuffer(const std::shared_ptr<VertexBuffer>& vertexBuffer, const size_t slot = 0)
279 {
280 if (_vertexBuffers.size() <= slot) {
281 _vertexBuffers.resize(slot + 1);
282 }
283 _vertexBuffers[slot] = vertexBuffer;
284 }
285
286 void setBlendState(const std::shared_ptr<BlendState>& blendState) { _blendState = blendState; }
287
288 void setDepthState(const std::shared_ptr<DepthState>& depthState) { _depthState = depthState; }
289
290 // hardware polygon-offset depth bias for shadow rendering.
291 // Applied via setDepthState().
292 // depthBias/slopeScale are in hardware depth-buffer units; clamp limits the maximum.
293 virtual void setDepthBias(float depthBias, float slopeScale, float clamp) {}
294
298 virtual void setIndirectDrawBuffer(void* nativeBuffer) { (void)nativeBuffer; }
299
302 virtual void setDynamicBatchPalette(const void* data, size_t size)
303 {
304 (void)data;
305 (void)size;
306 }
307
311 virtual void setClusterBuffers(const void* lightData, size_t lightSize,
312 const void* cellData, size_t cellSize)
313 {
314 (void)lightData;
315 (void)lightSize;
316 (void)cellData;
317 (void)cellSize;
318 }
319
322 virtual void setClusterGridParams(const float* boundsMin, const float* boundsRange,
323 const float* cellsCountByBoundsSize,
324 int cellsX, int cellsY, int cellsZ, int maxLightsPerCell,
325 int numClusteredLights)
326 {
327 (void)boundsMin;
328 (void)boundsRange;
329 (void)cellsCountByBoundsSize;
330 (void)cellsX;
331 (void)cellsY;
332 (void)cellsZ;
333 (void)maxLightsPerCell;
334 (void)numClusteredLights;
335 }
336
338 CullMode cullMode() const { return _cullMode; }
339 void setStencilState(const std::shared_ptr<StencilParameters>& stencilFront = nullptr,
340 const std::shared_ptr<StencilParameters>& stencilBack = nullptr)
341 {
342 _stencilFront = stencilFront;
343 _stencilBack = stencilBack;
344 _stencilEnabled = (_stencilFront != nullptr || _stencilBack != nullptr);
345 }
346
347 virtual void setViewport(float x, float y, float w, float h)
348 {
349 _vx = x;
350 _vy = y;
351 _vw = w;
352 _vh = h;
353 }
354
355 virtual void setScissor(int x, int y, int w, int h)
356 {
357 _sx = x;
358 _sy = y;
359 _sw = w;
360 _sh = h;
361 }
362
363 float vx() const { return _vx; }
364 float vy() const { return _vy; }
365 float vw() const { return _vw; }
366 float vh() const { return _vh; }
367 int sx() const { return _sx; }
368 int sy() const { return _sy; }
369 int sw() const { return _sw; }
370 int sh() const { return _sh; }
371 std::shared_ptr<VertexBuffer> quadVertexBuffer();
372 void setQuadTextureBinding(const size_t slot, Texture* texture)
373 {
374 if (slot < _quadTextureBindings.size()) {
375 _quadTextureBindings[slot] = texture;
376 }
377 }
379 {
380 _quadTextureBindings.fill(nullptr);
381 }
382 void setQuadRenderActive(const bool active) { _quadRenderActive = active; }
383 bool quadRenderActive() const { return _quadRenderActive; }
384 Texture* quadTextureBinding(const size_t slot) const
385 {
386 return slot < _quadTextureBindings.size() ? _quadTextureBindings[slot] : nullptr;
387 }
388 const std::array<Texture*, 8>& quadTextureBindings() const { return _quadTextureBindings; }
389
391 const Material* material() const { return _material; }
392
393 // when true, forward shaders output linear HDR
394 // (tonemapping + gamma are deferred to the compose pass). Set by
395 // RenderPassForward when running inside a CameraFrame pipeline.
396 void setHdrPass(bool hdr) { _hdrPass = hdr; }
397 bool hdrPass() const { return _hdrPass; }
398
399 virtual void startRenderPass(RenderPass* renderPass) = 0;
400
401 virtual void endRenderPass(RenderPass* renderPass) = 0;
402
403 virtual std::unique_ptr<gpu::HardwareTexture> createGPUTexture(Texture* texture) = 0;
404
405 virtual std::shared_ptr<VertexBuffer> createVertexBuffer(const std::shared_ptr<VertexFormat>& format,
406 int numVertices, const VertexBufferOptions& options = VertexBufferOptions{}) = 0;
407
408 virtual std::shared_ptr<IndexBuffer> createIndexBuffer(IndexFormat format, int numIndices,
409 const std::vector<uint8_t>& data = {}) = 0;
410
411 int samples() const { return _samples; }
412
413 void resizeCanvas(int width, int height);
414 virtual void setResolution(int width, int height) = 0;
415
416 virtual std::pair<int, int> size() const = 0;
417
418 int drawCallsPerFrame() const { return _drawCallsPerFrame; }
419 void resetDrawCallsPerFrame() { _drawCallsPerFrame = 0; }
420
421 bool contextLost() const { return _contextLost; }
422
423 virtual void update();
424
425 void updateClientRect();
426
427 // The maximum supported number of hardware antialiasing samples
428 int maxSamples() const { return _maxSamples; }
429
430 void removeTarget(RenderTarget* target);
431
432 std::shared_ptr<RenderTarget> renderTarget() const { return _renderTarget; }
433 void setRenderTarget(const std::shared_ptr<RenderTarget>& target) { _renderTarget = target; }
434 bool insideRenderPass() const { return _insideRenderPass; }
435 Texture* sceneDepthMap() const { return _sceneDepthMap; }
436 void setSceneDepthMap(Texture* depthMap) { _sceneDepthMap = depthMap; }
437
438 // DEVIATION: planar reflection texture, set by application-level code.
439 // Upstream handles this in the planarRenderer script; we promote it to
440 // a device-level binding so the forward pass can sample it at slot 9.
441 Texture* reflectionMap() const { return _reflectionMap; }
442 void setReflectionMap(Texture* tex) { _reflectionMap = tex; }
443
444 // DEVIATION: blurred planar reflection parameters.
445 const ReflectionBlurParams& reflectionBlurParams() const { return _reflectionBlurParams; }
446 void setReflectionBlurParams(const ReflectionBlurParams& params) { _reflectionBlurParams = params; }
447
448 // DEVIATION: planar reflection depth texture (distance-from-plane), bound at slot 10.
449 // depth camera pass for per-pixel blur radius.
450 Texture* reflectionDepthMap() const { return _reflectionDepthMap; }
451 void setReflectionDepthMap(Texture* tex) { _reflectionDepthMap = tex; }
452
453 // SSAO texture for per-material forward-pass compositing (VT_FEATURE_SSAO).
454 // When non-null, fragment shaders modulate ambient occlusion by sampling this
455 // texture at screen-space UV. Bound at fragment texture slot 18.
456 Texture* ssaoForwardTexture() const { return _ssaoForwardTexture; }
457 void setSsaoForwardTexture(Texture* tex) { _ssaoForwardTexture = tex; }
458
462 virtual std::shared_ptr<VertexBuffer> createVertexBufferFromNativeBuffer(
463 const std::shared_ptr<VertexFormat>& format,
464 int numVertices, void* nativeBuffer) { (void)nativeBuffer; return nullptr; }
465
466 virtual std::shared_ptr<RenderTarget> createRenderTarget(const RenderTargetOptions& options) = 0;
467 virtual void executeComposePass(const ComposePassParams& params) {}
468 virtual void executeTAAPass(Texture* sourceTexture, Texture* historyTexture, Texture* depthTexture,
469 const Matrix4& viewProjectionPrevious, const Matrix4& viewProjectionInverse,
470 const std::array<float, 4>& jitters, const std::array<float, 4>& cameraParams,
471 bool highQuality, bool historyValid) {}
472 virtual void executeSsaoPass(const SsaoPassParams& params) {}
473 virtual void executeCoCPass(const CoCPassParams& params) {}
474 virtual void executeDofBlurPass(const DofBlurPassParams& params) {}
475 virtual void executeDepthAwareBlurPass(const DepthAwareBlurPassParams& params, bool horizontal) {}
476 virtual bool supportsCompute() const { return false; }
477 virtual void computeDispatch(const std::vector<Compute*>& computes, const std::string& label = "") {}
478
479 void addTexture(const std::shared_ptr<Texture>& texture)
480 {
481 _textures.push_back(texture);
482 }
483
484 int renderVersion() const { return _renderVersion; }
485
486 // Device-level shader cache for utility shaders (downsample, upsample, etc.)
487 // that are compiled from fixed source and should only be created once.
488 std::shared_ptr<Shader> getCachedShader(const std::string& name) const
489 {
490 const auto it = _shaderCache.find(name);
491 return it != _shaderCache.end() ? it->second : nullptr;
492 }
493 void setCachedShader(const std::string& name, const std::shared_ptr<Shader>& shader)
494 {
495 _shaderCache[name] = shader;
496 }
497
498 protected:
499 virtual void onFrameStart() {}
500 virtual void onFrameEnd() {}
501 void setBackBuffer(const std::shared_ptr<RenderTarget>& target) { _backBuffer = target; }
502 void recordDrawCall(int count = 1) { _drawCallsPerFrame += count; }
503
504 void clearVertexBuffer();
505
506 std::shared_ptr<Shader> _shader;
507
508 std::vector<std::shared_ptr<VertexBuffer>> _vertexBuffers;
509
510 std::shared_ptr<RenderTarget> _renderTarget;
511
512 std::shared_ptr<BlendState> _blendState;
513 std::shared_ptr<DepthState> _depthState;
514
516 bool _insideRenderPass = false;
517
518 bool _stencilEnabled = false;
519
520 std::shared_ptr<StencilParameters> _stencilFront;
521 std::shared_ptr<StencilParameters> _stencilBack;
522 const Material* _material = nullptr;
523
524 private:
525 friend class Engine;
526 friend class RenderPass;
527 friend class VertexBuffer;
528 friend class Texture;
529
530 // Index of the currently active render pass
531 int _renderPassIndex;
532
533 // A version number that is incremented every frame. This is used to detect if some object were invalidated.
534 int _renderVersion;
535
536 // The render target representing the main back-buffer
537 std::shared_ptr<RenderTarget> _backBuffer;
538
539 std::shared_ptr<VertexBuffer> _quadVertexBuffer;
540 std::array<Texture*, 8> _quadTextureBindings{};
541 bool _quadRenderActive = false;
542 bool _hdrPass = false;
543 bool _atmosphereEnabled = false;
544 float _vx = 0.0f;
545 float _vy = 0.0f;
546 float _vw = 0.0f;
547 float _vh = 0.0f;
548 int _sx = 0;
549 int _sy = 0;
550 int _sw = 0;
551 int _sh = 0;
552
553 std::shared_ptr<DynamicBuffers> _dynamicBuffers;
554
555 std::shared_ptr<GpuProfiler> _gpuProfiler;
556
557 int _samples = 0;
558
559 float _maxPixelRatio;
560
561 int _shaderSwitchesPerFrame = 0;
562 int _drawCallsPerFrame = 0;
563
564 int _renderTargetCreationTime = 0;
565
566 bool _contextLost = false;
567
568 std::pair<int, int> _clientRect;
569
570 std::unordered_set<std::map<void*, void*>*> _mapsToClear;
571
572 std::vector<VertexBuffer*> _buffers;
573
574 std::vector<int> _primsPerFrame;
575
576 int _maxSamples = 1;
577
578 std::unordered_set<RenderTarget*> _targets;
579
580 DeviceVRAM _vram;
581
582 std::vector<std::shared_ptr<Texture>> _textures;
583
584 Texture* _sceneDepthMap = nullptr;
585 Texture* _reflectionMap = nullptr;
586 Texture* _reflectionDepthMap = nullptr;
587 Texture* _ssaoForwardTexture = nullptr;
588 ReflectionBlurParams _reflectionBlurParams;
589
590 std::unordered_map<std::string, std::shared_ptr<Shader>> _shaderCache;
591 };
592}
Abstract GPU interface for resource creation, state management, and draw submission.
virtual std::shared_ptr< Shader > createShader(const ShaderDefinition &definition, const std::string &sourceCode="")
void setCachedShader(const std::string &name, const std::shared_ptr< Shader > &shader)
std::shared_ptr< RenderTarget > renderTarget() const
void setSsaoForwardTexture(Texture *tex)
void removeTarget(RenderTarget *target)
virtual void setAtmosphereUniforms(const void *data, size_t size)
virtual void executeDofBlurPass(const DofBlurPassParams &params)
std::shared_ptr< StencilParameters > _stencilBack
Texture * quadTextureBinding(const size_t slot) const
virtual void computeDispatch(const std::vector< Compute * > &computes, const std::string &label="")
void setShader(const std::shared_ptr< Shader > &shader)
virtual bool supportsCompute() const
std::shared_ptr< Shader > getCachedShader(const std::string &name) const
virtual void setTransformUniforms(const Matrix4 &viewProjection, const Matrix4 &model)
virtual void executeComposePass(const ComposePassParams &params)
void setRenderTarget(const std::shared_ptr< RenderTarget > &target)
void setSceneDepthMap(Texture *depthMap)
void setStencilState(const std::shared_ptr< StencilParameters > &stencilFront=nullptr, const std::shared_ptr< StencilParameters > &stencilBack=nullptr)
void setMaterial(const Material *material)
virtual void endRenderPass(RenderPass *renderPass)=0
std::shared_ptr< RenderTarget > backBuffer() const
void setVertexBuffer(const std::shared_ptr< VertexBuffer > &vertexBuffer, const size_t slot=0)
const ReflectionBlurParams & reflectionBlurParams() const
void setBackBuffer(const std::shared_ptr< RenderTarget > &target)
void setBlendState(const std::shared_ptr< BlendState > &blendState)
virtual void setLightingUniforms(const Color &ambientColor, const std::vector< GpuLightData > &lights, const Vector3 &cameraPosition, bool enableNormalMaps, float exposure, const FogParams &fogParams=FogParams{}, const ShadowParams &shadowParams=ShadowParams{}, int toneMapping=0)
virtual void executeCoCPass(const CoCPassParams &params)
void setAtmosphereEnabled(bool value)
Enable/disable atmosphere scattering for the current frame.
virtual void executeDepthAwareBlurPass(const DepthAwareBlurPassParams &params, bool horizontal)
void setCullMode(const CullMode cullMode)
virtual void setDynamicBatchPalette(const void *data, size_t size)
virtual std::unique_ptr< gpu::HardwareTexture > createGPUTexture(Texture *texture)=0
virtual void setClusterGridParams(const float *boundsMin, const float *boundsRange, const float *cellsCountByBoundsSize, int cellsX, int cellsY, int cellsZ, int maxLightsPerCell, int numClusteredLights)
void setReflectionDepthMap(Texture *tex)
virtual std::pair< int, int > size() const =0
virtual std::shared_ptr< IndexBuffer > createIndexBuffer(IndexFormat format, int numIndices, const std::vector< uint8_t > &data={})=0
const std::array< Texture *, 8 > & quadTextureBindings() const
virtual void executeSsaoPass(const SsaoPassParams &params)
virtual void startRenderPass(RenderPass *renderPass)=0
std::shared_ptr< StencilParameters > _stencilFront
std::shared_ptr< RenderTarget > _renderTarget
virtual void setDepthBias(float depthBias, float slopeScale, float clamp)
virtual void executeTAAPass(Texture *sourceTexture, Texture *historyTexture, Texture *depthTexture, const Matrix4 &viewProjectionPrevious, const Matrix4 &viewProjectionInverse, const std::array< float, 4 > &jitters, const std::array< float, 4 > &cameraParams, bool highQuality, bool historyValid)
virtual void setScissor(int x, int y, int w, int h)
virtual void setIndirectDrawBuffer(void *nativeBuffer)
std::shared_ptr< Shader > _shader
virtual void setEnvironmentUniforms(Texture *envAtlas, float skyboxIntensity, float skyboxMip, const Vector3 &skyDomeCenter=Vector3(0, 0, 0), bool isDome=false, Texture *skyboxCubeMap=nullptr)
void setQuadRenderActive(const bool active)
virtual std::shared_ptr< RenderTarget > createRenderTarget(const RenderTargetOptions &options)=0
virtual void setResolution(int width, int height)=0
void setDepthState(const std::shared_ptr< DepthState > &depthState)
void resizeCanvas(int width, int height)
void setQuadTextureBinding(const size_t slot, Texture *texture)
void addTexture(const std::shared_ptr< Texture > &texture)
std::vector< std::shared_ptr< VertexBuffer > > _vertexBuffers
virtual void setViewport(float x, float y, float w, float h)
virtual void draw(const Primitive &primitive, const std::shared_ptr< IndexBuffer > &indexBuffer=nullptr, int numInstances=1, int indirectSlot=-1, bool first=true, bool last=true)=0
void setReflectionBlurParams(const ReflectionBlurParams &params)
std::shared_ptr< BlendState > _blendState
virtual std::shared_ptr< VertexBuffer > createVertexBuffer(const std::shared_ptr< VertexFormat > &format, int numVertices, const VertexBufferOptions &options=VertexBufferOptions{})=0
virtual void setClusterBuffers(const void *lightData, size_t lightSize, const void *cellData, size_t cellSize)
const Material * material() const
std::shared_ptr< VertexBuffer > quadVertexBuffer()
std::shared_ptr< DepthState > _depthState
virtual std::shared_ptr< VertexBuffer > createVertexBufferFromNativeBuffer(const std::shared_ptr< VertexFormat > &format, int numVertices, void *nativeBuffer)
Base class for GPU materials — owns uniform data, texture bindings, blend/depth state,...
Definition material.h:143
GPU texture resource supporting 2D, cubemap, volume, and array formats with mipmap management.
Definition texture.h:57
RGBA color with floating-point components in [0, 1].
Definition color.h:18
Per-light GPU data uploaded to the lighting uniform buffer.
4x4 column-major transformation matrix with SIMD acceleration.
Definition matrix4.h:31
static Matrix4 identity()
Definition matrix4.h:108
Describes how vertex and index data should be interpreted for a draw call.
Definition mesh.h:33
struct visutwin::canvas::ShadowParams::LocalShadow localShadows[kMaxLocalShadows]
static constexpr int kMaxLocalShadows
3D vector for positions, directions, and normals with multi-backend SIMD acceleration.
Definition vector3.h:29