Ocean
GIFramebuffer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_RENDERING_GI_FRAMEBUFFER_H
9 #define META_OCEAN_RENDERING_GI_FRAMEBUFFER_H
10 
15 
16 #include "ocean/base/Frame.h"
17 
19 
20 #include "ocean/rendering/Engine.h"
22 
23 namespace Ocean
24 {
25 
26 namespace Rendering
27 {
28 
29 namespace GlobalIllumination
30 {
31 
32 /**
33  * This class implements a base for all Global Illumination framebuffers.
34  * @ingroup renderinggi
35  */
36 class OCEAN_RENDERING_GI_EXPORT GIFramebuffer :
37  virtual public GIObject,
38  virtual public Framebuffer
39 {
40  public:
41 
42  /**
43  * Returns the global face mode of the entire framebuffer.
44  * @see Framebuffer::faceMode().
45  */
46  FaceMode faceMode() const override;
47 
48  /**
49  * Returns the global face culling mode of the entire framebuffer.
50  * @see Framebuffer::cullingMode().
51  */
52  CullingMode cullingMode() const override;
53 
54  /**
55  * Returns the render technique of the entire framebuffer.
56  * @see Framebuffer::renderTechnique().
57  */
58  RenderTechnique renderTechnique() const override;
59 
60  /**
61  * Returns whether the framebuffer supports hardware antialiasing.
62  * @see Framebuffer::isAntialiasingSupported().
63  */
64  bool isAntialiasingSupported(const unsigned int buffers) const override;
65 
66  /**
67  * Returns whether the framebuffer uses hardware antialiasing.
68  * @see Framebuffer::isAntialiasing().
69  */
70  bool isAntialiasing() const override;
71 
72  /**
73  * Returns whether the framebuffer supports stereo views.
74  * @see Framebuffer::isQuadbufferedStereoSupported().
75  */
76  bool isQuadbufferedStereoSupported() const override;
77 
78  /**
79  * Connects a view with this framebuffer.
80  * @see Framebuffer::setView().
81  */
82  void setView(const ViewRef& view) override;
83 
84  /**
85  * Sets the global face mode of the entire framebuffer.
86  * @see Framebuffer::setFaceMode().
87  */
88  void setFaceMode(const FaceMode faceMode) override;
89 
90  /**
91  * Sets the global culling mode of the entire framebuffer.
92  * @see Framebuffer::setCullingMode().
93  */
94  void setCullingMode(const CullingMode cullingMode) override;
95 
96  /**
97  * Sets the rendering technique of the entire framebuffer.
98  * @see Framebuffer::setRenderTechnique().
99  */
100  void setRenderTechnique(const RenderTechnique technique) override;
101 
102  /**
103  * Sets whether this framebuffer will support hardware antialiasing.
104  * @see setSupportAntialiasing().
105  */
106  bool setSupportAntialiasing(const unsigned int buffers) override;
107 
108  /**
109  * Sets whether the framebuffer uses hardware antialiasing.
110  * @see Framebuffer::setAntialiasing().
111  */
112  bool setAntialiasing(const bool antialiasing) override;
113 
114  /**
115  * Sets whether this framebuffer will support stereo views.
116  * @see Framebuffer::setSupportQuadbufferedStereo().
117  */
118  bool setSupportQuadbufferedStereo(const bool enable) override;
119 
120  /**
121  * Makes this frambuffer to the current one.
122  * @see Framebuffer::makeCurrent().
123  */
124  void makeCurrent() override;
125 
126  /**
127  * Makes this framebuffer to non current.
128  * @see Framebuffer::makeNoncurrent().
129  */
130  void makeNoncurrent() override;
131 
132  /**
133  * Adds a new scene to the framebuffer.
134  * @see Framebuffer::addScene().
135  */
136  void addScene(const SceneRef& scene) override;
137 
138  /**
139  * Removes a scene from the framebuffer.
140  * @see Framebuffer::removeScene().
141  */
142  void removeScene(const SceneRef& scene) override;
143 
144  /**
145  * Cleares all scenes registered at the framebuffer.
146  * @see Framebuffer::clearScenes().
147  */
148  void clearScenes() override;
149 
150  /**
151  * Returns the viewport of this framebuffer.
152  * @see Framebuffer::viewport().
153  */
154  void viewport(unsigned int& left, unsigned int& top, unsigned int& width, unsigned int& height) const override;
155 
156  /**
157  * Sets the viewport of this framebuffer.
158  * @see Framebuffer::setViewport().
159  */
160  void setViewport(const unsigned int left, const unsigned int top, const unsigned int width, const unsigned int height) override;
161 
162  /**
163  * Renders the next frame into the framebuffer.
164  * @see Framebuffer::render().
165  */
166  void render() override;
167 
168  /**
169  * Returns the renderable object intersected by a given ray.
170  * @see Framebuffer::intersection().
171  */
172  bool intersection(const Line3& ray, RenderableRef& renderable, Vector3& position) override;
173 
174  protected:
175 
176  /**
177  * Creates a new NvidaSceneGraph framebuffer object.
178  * @param preferredGraphicAPI Preferred graphic API to be used for this framebuffer
179  */
181 
182  /**
183  * Destructs a Global Illumination framebuffer object.
184  */
185  ~GIFramebuffer() override;
186 
187  /**
188  * Renders a subset of the frame into the framebuffer.
189  * @param lightSources The light sources that will be used for rendering
190  * @param group The group of tracing objects actually representing the geometry(s) of the scene
191  * @param threads The number of threads the are currently used concurrently to render the frame, with range [1, infinity)
192  * @param threadIndex The index of the thread currently executed, with range [0, threads)
193  * @param mustBeOne Unused parameter which must be 1
194  */
195  void renderSubset(LightSources* lightSources, const TracingGroup* group, const unsigned int threads, const unsigned int threadIndex, const unsigned int mustBeOne);
196 
197  /**
198  * Renders a subset of the frame into the framebuffer.
199  * @param sobelResponse The sobel response of the pixel-accurate render result providing a measure for the number of necessary sub-pixel render iterations, must be valid
200  * @param sobelResponsePaddingElements The number of padding elements at the end of each sobel response row, in elements, with range [0, infinity)
201  * @param lightSources The light sources that will be used for rendering, must be valid
202  * @param group The group of tracing objects actually representing the geometry(s) of the scene
203  * @param threads The number of threads the are currently used concurrently to render the frame, with range [1, infinity)
204  * @param threadIndex The index of the thread currently executed, with range [0, threads)
205  * @param mustBeOne Unused parameter which must be 1
206  */
207  void renderAntialiasedSubset(const uint8_t* sobelResponse, const unsigned int sobelResponsePaddingElements, LightSources* lightSources, const TracingGroup* group, const unsigned int threads, const unsigned int threadIndex, const unsigned int mustBeOne);
208 
209  /**
210  * Renders one specific ray for a given group of tracing objects and light sources.
211  * @param viewPosition The position of the view, defined within the same coordinate system as all other objects
212  * @param ray The specific ray for which the color value (the light) will be determined
213  * @param group The group of tracing objects actually representing the geometry(s) of the scene
214  * @param lightSources The light sources that will be used for rendering
215  * @param result The resulting color value (the light) of the specified ray
216  * @return True, if succeeded
217  */
218  bool renderRay(const Vector3& viewPosition, const Line3& ray, const TracingGroup& group, const LightSources& lightSources, RGBAColor& result) const;
219 
220  /**
221  * Releases the framebuffer.
222  * @see Framebuffer::release().
223  */
224  void release() override;
225 
226  protected:
227 
228  /// Preferred graphic API of this framebuffer.
230 
231  /// Framebuffer frame.
233 
234  /// Antialiasing enabled statement.
236 
237  /// Optional framebuffer frame holding the sobel response for antialiasing.
239 
240  /// Lighting modes for this framebuffer.
242 };
243 
244 }
245 
246 }
247 
248 }
249 
250 #endif // META_OCEAN_RENDERING_GI_FRAMEBUFFER_H
This class implements Ocean's image class.
Definition: Frame.h:1792
This class implements an infinite line in 3D space.
Definition: Line3.h:70
This class implements a color defined by red, green, blue and alpha parameters.
Definition: RGBAColor.h:41
GraphicAPI
Definition of different graphic APIs.
Definition: Engine.h:57
@ API_DEFAULT
Invalid graphic api id.
Definition: Engine.h:59
This class is the base class for all rendering framebuffers.
Definition: rendering/Framebuffer.h:48
RenderTechnique
Definition of different render techniques.
Definition: rendering/Framebuffer.h:68
This class implements a base for all Global Illumination framebuffers.
Definition: GIFramebuffer.h:39
void setRenderTechnique(const RenderTechnique technique) override
Sets the rendering technique of the entire framebuffer.
bool intersection(const Line3 &ray, RenderableRef &renderable, Vector3 &position) override
Returns the renderable object intersected by a given ray.
void viewport(unsigned int &left, unsigned int &top, unsigned int &width, unsigned int &height) const override
Returns the viewport of this framebuffer.
void setView(const ViewRef &view) override
Connects a view with this framebuffer.
void setFaceMode(const FaceMode faceMode) override
Sets the global face mode of the entire framebuffer.
Frame sobelFrame_
Optional framebuffer frame holding the sobel response for antialiasing.
Definition: GIFramebuffer.h:238
void release() override
Releases the framebuffer.
bool setSupportQuadbufferedStereo(const bool enable) override
Sets whether this framebuffer will support stereo views.
CullingMode cullingMode() const override
Returns the global face culling mode of the entire framebuffer.
void render() override
Renders the next frame into the framebuffer.
Engine::GraphicAPI preferredGraphicAPI_
Preferred graphic API of this framebuffer.
Definition: GIFramebuffer.h:229
bool isAntialiasingSupported(const unsigned int buffers) const override
Returns whether the framebuffer supports hardware antialiasing.
bool setAntialiasing(const bool antialiasing) override
Sets whether the framebuffer uses hardware antialiasing.
void removeScene(const SceneRef &scene) override
Removes a scene from the framebuffer.
RenderTechnique renderTechnique() const override
Returns the render technique of the entire framebuffer.
void setCullingMode(const CullingMode cullingMode) override
Sets the global culling mode of the entire framebuffer.
FaceMode faceMode() const override
Returns the global face mode of the entire framebuffer.
void renderAntialiasedSubset(const uint8_t *sobelResponse, const unsigned int sobelResponsePaddingElements, LightSources *lightSources, const TracingGroup *group, const unsigned int threads, const unsigned int threadIndex, const unsigned int mustBeOne)
Renders a subset of the frame into the framebuffer.
void renderSubset(LightSources *lightSources, const TracingGroup *group, const unsigned int threads, const unsigned int threadIndex, const unsigned int mustBeOne)
Renders a subset of the frame into the framebuffer.
bool setSupportAntialiasing(const unsigned int buffers) override
Sets whether this framebuffer will support hardware antialiasing.
bool antialiasingEnabled_
Antialiasing enabled statement.
Definition: GIFramebuffer.h:235
GIFramebuffer(const Engine::GraphicAPI preferredGraphicAPI=Engine::API_DEFAULT)
Creates a new NvidaSceneGraph framebuffer object.
Frame frame_
Framebuffer frame.
Definition: GIFramebuffer.h:232
void addScene(const SceneRef &scene) override
Adds a new scene to the framebuffer.
Lighting::LightingModes lightingModes_
Lighting modes for this framebuffer.
Definition: GIFramebuffer.h:241
void makeCurrent() override
Makes this frambuffer to the current one.
void clearScenes() override
Cleares all scenes registered at the framebuffer.
void setViewport(const unsigned int left, const unsigned int top, const unsigned int width, const unsigned int height) override
Sets the viewport of this framebuffer.
void makeNoncurrent() override
Makes this framebuffer to non current.
bool renderRay(const Vector3 &viewPosition, const Line3 &ray, const TracingGroup &group, const LightSources &lightSources, RGBAColor &result) const
Renders one specific ray for a given group of tracing objects and light sources.
bool isAntialiasing() const override
Returns whether the framebuffer uses hardware antialiasing.
~GIFramebuffer() override
Destructs a Global Illumination framebuffer object.
bool isQuadbufferedStereoSupported() const override
Returns whether the framebuffer supports stereo views.
This class is the base class for all Global Illumination objects.
Definition: GIObject.h:29
LightingModes
Definition of individual lighting modes.
Definition: Lighting.h:47
This class implements a group of tracing objects.
Definition: TracingGroup.h:28
FaceMode
Defines different face rendering modes.
Definition: PrimitiveAttribute.h:42
CullingMode
Defines different face culling modes.
Definition: PrimitiveAttribute.h:57
std::vector< LightPair > LightSources
Definition of a vector holding light pairs.
Definition: GILightSource.h:40
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15