VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
shadowCatcher.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3//
4//
5// A script that creates a shadow-catching ground plane beneath the target entity.
6// The plane uses a multiplicative-blend material with the LIT_SHADOW_CATCHER shader
7// path, which outputs the accumulated shadow factor as a grayscale value. When blended
8// multiplicatively with the framebuffer, lit areas remain unchanged while shadowed
9// areas are darkened — giving the appearance of a shadow on the existing background.
10//
11#pragma once
12
13#include <memory>
14
15#include "script.h"
16#include "scriptRegistry.h"
17
18namespace visutwin::canvas
19{
20 class Entity;
21 class StandardMaterial;
22
35 class ShadowCatcher : public Script
36 {
37 public:
38 SCRIPT_NAME("shadowCatcher")
39
40 // --- Configuration (can be set before or after initialize) ---
41
42 // Scale of the shadow-catching plane (default 20x20)
43 float planeScale() const { return _planeScale; }
44 void setPlaneScale(float value);
45
46 // Vertical offset below the entity position (default 0)
47 float yOffset() const { return _yOffset; }
48 void setYOffset(float value);
49
50 // Shadow intensity: 0 = no shadow, 1 = full shadow darkening (default 1.0)
51 float intensity() const { return _intensity; }
52 void setIntensity(float value) { _intensity = value; }
53
54 void initialize() override;
55
56 private:
57 float _planeScale = 20.0f;
58 float _yOffset = 0.0f;
59 float _intensity = 1.0f;
60
61 Entity* _planeEntity = nullptr;
62 StandardMaterial* _material = nullptr;
63 };
64}
65
ECS entity — a GraphNode that hosts components defining its behavior.
Definition entity.h:32
Full PBR material with metalness/roughness workflow and advanced surface features.
#define SCRIPT_NAME(Name)
Definition script.h:10
#define REGISTER_SCRIPT(Type, Name)