Blue Brain BioExplorer
Renderer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2024, EPFL/Blue Brain Project
3  *
4  * The Blue Brain BioExplorer is a tool for scientists to extract and analyse
5  * scientific data from visualization
6  *
7  * This file is part of Blue Brain BioExplorer <https://github.com/BlueBrain/BioExplorer>
8  *
9  * This library is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU Lesser General Public License version 3.0 as published
11  * by the Free Software Foundation.
12  *
13  * This library is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #pragma once
24 
29 
30 SERIALIZATION_ACCESS(Renderer)
31 
32 namespace core
33 {
41 class Renderer : public PropertyObject
42 {
43 public:
50  struct PickResult
51  {
52  bool hit{false}; // boolean value that defines if the ray hits anything
53  Vector3d pos; // vector position of the ray intersection
54  };
55 
61  virtual void render(FrameBufferPtr frameBuffer) = 0;
62 
68  virtual float getVariance() const { return 0.f; }
69 
73  virtual void commit() = 0;
74 
80  virtual void setCamera(CameraPtr camera) = 0;
81 
89  virtual PickResult pick(const Vector2f& /*pickPos*/) { return PickResult(); }
90 
96  PLATFORM_API Renderer(const AnimationParameters& animationParameters,
97  const RenderingParameters& renderingParameters);
102  void setEngine(Engine* engine) { _engine = engine; };
103 
107  PLATFORM_API bool getHeadLight() const { return _headLight; }
108  PLATFORM_API void setHeadLight(const bool value) { _updateValue(_headLight, value); }
109 
116  PLATFORM_API void setMaxAccumFrames(const size_t value) { _updateValue(_maxAccumFrames, value); }
117  PLATFORM_API size_t getMaxAccumFrames() const { return _maxAccumFrames; }
118 
120  PLATFORM_API uint32_t getSamplesPerPixel() const { return _spp; }
121  PLATFORM_API void setSamplesPerPixel(const uint32_t value) { _updateValue(_spp, std::max(1u, value)); }
122 
124  PLATFORM_API uint32_t getSubsampling() const { return _subsampling; }
125  PLATFORM_API void setSubsampling(const uint32_t subsampling)
126  {
127  _updateValue(_subsampling, std::max(1u, subsampling));
128  }
129 
133 
135  PLATFORM_API bool getAccumulation() const { return _accumulation; }
136 
137 protected:
140  Engine* _engine{nullptr};
141 
142  bool _accumulation{true};
143  bool _headLight{true};
145  uint32_t _spp{1};
146  uint32_t _subsampling{1};
147  size_t _maxAccumFrames{100};
148 
149 private:
150  SERIALIZATION_FRIEND(Renderer);
151 };
152 } // namespace core
#define PLATFORM_API
Definition: Api.h:37
#define SERIALIZATION_ACCESS(type)
Definition: Macros.h:25
void _updateValue(T &member, const T &newValue, const bool triggerCallback=true)
Definition: BaseObject.h:87
Provides an abstract implementation of a ray-tracing engine.
Definition: Engine.h:59
Renderer class inherits from PropertyObject class The Renderer class has methods to render a FrameBuf...
Definition: Renderer.h:42
PLATFORM_API void setBackgroundColor(const Vector3d &value)
Definition: Renderer.h:132
Vector3d _backgroundColor
Definition: Renderer.h:144
size_t _maxAccumFrames
Definition: Renderer.h:147
PLATFORM_API uint32_t getSubsampling() const
Definition: Renderer.h:124
PLATFORM_API void setMaxAccumFrames(const size_t value)
Definition: Renderer.h:116
bool _accumulation
Definition: Renderer.h:142
virtual void setCamera(CameraPtr camera)=0
Set camera for renderer This virtual method is implemented in specific engine renderers to set the ca...
const RenderingParameters & _renderingParameters
Definition: Renderer.h:139
PLATFORM_API const Vector3d & getBackgroundColor() const
Definition: Renderer.h:131
PLATFORM_API size_t getMaxAccumFrames() const
Definition: Renderer.h:117
PLATFORM_API Renderer(const AnimationParameters &animationParameters, const RenderingParameters &renderingParameters)
Constructs the Renderer object with animationParameters and renderingParameters.
Definition: Renderer.cpp:30
void setEngine(Engine *engine)
Sets the _scene pointer to a specified ScenePtr.
Definition: Renderer.h:102
virtual PickResult pick(const Vector2f &)
Pick method This method is used to pick a point on the scene and returns PickResult struct with hit b...
Definition: Renderer.h:89
PLATFORM_API void setSamplesPerPixel(const uint32_t value)
Definition: Renderer.h:121
uint32_t _subsampling
Definition: Renderer.h:146
PLATFORM_API void setHeadLight(const bool value)
Definition: Renderer.h:108
PLATFORM_API bool getHeadLight() const
Definition: Renderer.h:107
PLATFORM_API uint32_t getSamplesPerPixel() const
Definition: Renderer.h:120
const AnimationParameters & _animationParameters
Definition: Renderer.h:138
virtual void commit()=0
This virtual method is implemented in specific engine renderers to signal that rendering is complete.
PLATFORM_API bool getAccumulation() const
Definition: Renderer.h:135
virtual float getVariance() const
Get variance from previous render() This method returns the variance from the previous render() call.
Definition: Renderer.h:68
uint32_t _spp
Definition: Renderer.h:145
bool _headLight
Definition: Renderer.h:143
virtual void render(FrameBufferPtr frameBuffer)=0
Virtual method to render a FrameBuffer This method is implemented in specific engine renderers to dra...
Engine * _engine
Definition: Renderer.h:140
PLATFORM_API void setSubsampling(const uint32_t subsampling)
Definition: Renderer.h:125
std::shared_ptr< Camera > CameraPtr
Definition: Types.h:93
glm::vec2 Vector2f
Definition: MathTypes.h:136
glm::vec< 3, double > Vector3d
Definition: MathTypes.h:143
std::shared_ptr< FrameBuffer > FrameBufferPtr
Definition: Types.h:100
PickResult Struct containing hit boolean value and Vector3d pos PickResult struct is used to retrieve...
Definition: Renderer.h:51