Easy3D 2.5.3
ambient_occlusion.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 EASY_RENDERER_AMBIENT_OCCLUSION_H
28#define EASY_RENDERER_AMBIENT_OCCLUSION_H
29
30
31#include <string>
32#include <vector>
33
34#include <easy3d/core/types.h>
35
36
37namespace easy3d {
38
39 class Model;
40 class Camera;
41 class FramebufferObject;
42
50 {
51 public:
54 explicit AmbientOcclusion(Camera* cam);
55 virtual ~AmbientOcclusion();
56
58 void set_radius(float r) { radius_ = r; }
60 float radius() const { return radius_; }
61
63 void set_bias(float b) { bias_ = b; }
65 float bias() const { return bias_; }
66
69 virtual unsigned int generate(const std::vector<Model*>& models);
71 unsigned int ssao_texture() const;
72
73 protected:
74 void init(int w, int h);
75
76 void geometry_pass(const std::vector<Model*>& models);
77 void ssao_pass();
78 void blur_pass();
79
80 void generate_noise(int width, int height);
81
82 protected:
83 Camera* camera_;
84
85 float radius_;
86 float bias_;
87
88 FramebufferObject* geom_fbo_;
89 FramebufferObject* ssao_fbo_;
90
91 std::vector<vec3> ssao_kernel_;
92 unsigned int noise_texture_;
93
94 private:
95 //copying disabled
97 AmbientOcclusion& operator=(const AmbientOcclusion&);
98 };
99
100
101} // namespace easy3d
102
103
104#endif // EASY_RENDERER_AMBIENT_OCCLUSION_H
Traditional Screen Space Ambient Occlusion (SSAO) technique.
Definition: ambient_occlusion.h:50
AmbientOcclusion(Camera *cam)
Constructor.
Definition: ambient_occlusion.cpp:56
unsigned int ssao_texture() const
Returns the generated SSAO texture ID.
Definition: ambient_occlusion.cpp:159
float radius() const
Returns the sample radius.
Definition: ambient_occlusion.h:60
void set_radius(float r)
Sets the sample radius (in pixels). Typical value is in range [0, 4].
Definition: ambient_occlusion.h:58
void set_bias(float b)
Sets the bias. Default value is 0.005.
Definition: ambient_occlusion.h:63
float bias() const
Returns the bias.
Definition: ambient_occlusion.h:65
virtual unsigned int generate(const std::vector< Model * > &models)
Generates the SSAO texture.
Definition: ambient_occlusion.cpp:144
A perspective or orthographic camera.
Definition: camera.h:116
An implementation of framebuffer object (FBO).
Definition: framebuffer_object.h:122
Definition: collider.cpp:182