Easy3D 2.5.3
soft_shadow.h
1/********************************************************************
2 * Copyright (C) 2015 Liangliang Nan <liangliang.nan@gmail.com>
3 * https://3d.bk.tudelft.nl/liangliang/
4 *
5 * This file is part of Easy3D. If it is useful in your research/work,
6 * I would be grateful if you show your appreciation by citing it:
7 * ------------------------------------------------------------------
8 * Liangliang Nan.
9 * Easy3D: a lightweight, easy-to-use, and efficient C++ library
10 * for processing and rendering 3D data.
11 * Journal of Open Source Software, 6(64), 3255, 2021.
12 * ------------------------------------------------------------------
13 *
14 * Easy3D is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License Version 3
16 * as published by the Free Software Foundation.
17 *
18 * Easy3D is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ********************************************************************/
26
27#ifndef EASY3D_RENDERER_SOFT_SHADOW_H
28#define EASY3D_RENDERER_SOFT_SHADOW_H
29
30#include <easy3d/renderer/shadow.h>
31
32
33namespace easy3d {
34
69 class SoftShadow : public Shadow
70 {
71 public:
72 enum SamplePattern {
73 SP_Poisson_25_25 = 0, // 25 samples for the blocker search, 25 samples in the PCF filtering, all samples using a Poisson disk
74 SP_Poisson_32_64 = 1, // 32 samples for the blocker search, 64 samples for the PCF filtering, all samples using a Poisson disk
75 SP_Poisson_64_128 = 2, // 64 samples for the blocker search, 128 samples for the PCF filtering, all samples using a Poisson disk
76 SP_Poisson_100_100 = 3, // 100 samples for the blocker search, 100 samples for the PCF filtering, all samples using a Poisson disk
77 SP_Regular_49_225 = 4 // 49 samples for the blocker search, 225 samples for the PCF filtering, all samples using regular sampling (faster than Poisson disk)
78 };
79
80 public:
83 explicit SoftShadow(Camera* cam);
84 ~SoftShadow() override = default;
85
86 // The softness of the shadow. Values must be in [0, 1]. Default: 0.5.
87 float softness() const { return softness_; }
88 void set_softness(float s) { softness_ = s; }
89
90 // The sampler pattern used for blocker search and PCF filtering.
91 SamplePattern sample_pattern() const { return sample_pattern_; }
92 void set_sample_pattern(SamplePattern pattern) { sample_pattern_ = pattern; }
93
94 protected:
95 void ensure_fbo() override;
96 void shadow_map_pass(const std::vector<TrianglesDrawable*>& surfaces) override;
97 void render_pass(const std::vector<TrianglesDrawable*>& surfaces) override;
98
99 protected:
100 // The softness of the shadow, in [0, 1] (w.r.t. 10% of the light's size)
101 float softness_;
102
103 SamplePattern sample_pattern_;
104
105 private:
106 //copying disabled
107 SoftShadow(const SoftShadow&);
108 SoftShadow& operator=(const SoftShadow&);
109 };
110
111}
112
113#endif // EASY3D_RENDERER_SOFT_SHADOW_H
A perspective or orthographic camera.
Definition: camera.h:116
Shadow implements the standard shadow map (hard shadow) algorithm.
Definition: shadow.h:50
An implementation of the Percentage-Closer Soft Shadows.
Definition: soft_shadow.h:70
SoftShadow(Camera *cam)
Constructor.
Definition: soft_shadow.cpp:43
Definition: collider.cpp:182