Easy3D 2.6.1
Loading...
Searching...
No Matches
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#include <vector>
31#include <memory>
32
33#include <easy3d/core/types.h>
34
35
36namespace easy3d {
37
38 class Model;
39 class Camera;
41
49 {
50 public:
55 explicit AmbientOcclusion(Camera* cam);
59 virtual ~AmbientOcclusion();
60
65 void set_radius(float r) { radius_ = r; }
70 float radius() const { return radius_; }
71
76 void set_bias(float b) { bias_ = b; }
81 float bias() const { return bias_; }
82
88 virtual unsigned int generate(const std::vector< std::shared_ptr<Model> >& models);
93 unsigned int ssao_texture() const;
94
95 protected:
101 void init(int w, int h);
106 void geometry_pass(const std::vector< std::shared_ptr<Model> >& models);
110 void ssao_pass();
114 void blur_pass();
120 void generate_noise(int width, int height);
121
122 protected:
123 Camera* camera_;
124
125 float radius_;
126 float bias_;
127
128 FramebufferObject* geom_fbo_;
129 FramebufferObject* ssao_fbo_;
130
131 std::vector<vec3> ssao_kernel_;
132 unsigned int noise_texture_;
133
134 private:
135 //copying disabled
137 AmbientOcclusion& operator=(const AmbientOcclusion&);
138 };
139
140
141} // namespace easy3d
142
143
144#endif // EASY_RENDERER_AMBIENT_OCCLUSION_H
Traditional Screen Space Ambient Occlusion (SSAO) technique.
Definition ambient_occlusion.h:49
virtual unsigned int generate(const std::vector< std::shared_ptr< Model > > &models)
Generates the SSAO texture.
Definition ambient_occlusion.cpp:144
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:70
void set_radius(float r)
Sets the sample radius (in pixels). Typical value is in range [0, 4].
Definition ambient_occlusion.h:65
void set_bias(float b)
Sets the bias. Default value is 0.005.
Definition ambient_occlusion.h:76
virtual ~AmbientOcclusion()
Destructor.
Definition ambient_occlusion.cpp:67
float bias() const
Returns the bias.
Definition ambient_occlusion.h:81
A perspective or orthographic camera.
Definition camera.h:113
An implementation of framebuffer object (FBO).
Definition framebuffer_object.h:122
The base class of renderable 3D models.
Definition model.h:50
Definition collider.cpp:182