VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
shadowRendererDirectional.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 18.10.2025.
5//
6#pragma once
7
8#include <memory>
9#include <unordered_map>
10#include <vector>
11
13#include "scene/camera.h"
14#include "scene/frameGraph.h"
15#include "scene/light.h"
16
17namespace visutwin::canvas
18{
20 class Renderer;
21 class ShadowRenderer;
22
24 {
25 public:
26 ShadowRendererDirectional(const std::shared_ptr<GraphicsDevice>& device, Renderer* renderer, ShadowRenderer* shadowRenderer);
27
28 // Sets up the shadow camera for a directional light: positions it to cover the scene
29 // camera's frustum, sets orthographic projection, and snaps to texel grid for stability.
30 // lines 72-201.
31 void cull(Light* light, Camera* camera);
32
33 std::shared_ptr<RenderPass> getLightRenderPass(Light* light, Camera* camera, int face, bool clearRenderTarget,
34 bool allCascadesRendering);
35
37 const std::unordered_map<Camera*, std::vector<Light*>>& cameraDirShadowLights);
38
39 // Compute per-cascade split distances using linear-logarithmic blend.
40 // lines 204-216.
41 static void generateSplitDistances(Light* light, float nearDist, float farDist);
42
43 private:
44 Renderer* _renderer = nullptr;
45 ShadowRenderer* _shadowRenderer = nullptr;
46 std::shared_ptr<GraphicsDevice> _device;
47 };
48}
Perspective or orthographic camera with projection matrix, jitter (TAA), and render target binding.
Definition camera.h:40
Directional, point, spot, or area light with shadow mapping and cookie projection.
Definition light.h:54
void buildNonClusteredRenderPasses(FrameGraph *frameGraph, const std::unordered_map< Camera *, std::vector< Light * > > &cameraDirShadowLights)
ShadowRendererDirectional(const std::shared_ptr< GraphicsDevice > &device, Renderer *renderer, ShadowRenderer *shadowRenderer)
static void generateSplitDistances(Light *light, float nearDist, float farDist)
std::shared_ptr< RenderPass > getLightRenderPass(Light *light, Camera *camera, int face, bool clearRenderTarget, bool allCascadesRendering)