VTK  9.3.1
vtkOpenGLRenderer.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
14 #ifndef vtkOpenGLRenderer_h
15 #define vtkOpenGLRenderer_h
16 
17 #include "vtkRenderer.h"
18 
19 #include "vtkOpenGLQuadHelper.h" // for ivar
20 #include "vtkRenderingOpenGL2Module.h" // For export macro
21 #include "vtkSmartPointer.h" // For vtkSmartPointer
22 #include <memory> // for unique_ptr
23 #include <string> // Ivars
24 #include <vector> // STL Header
25 
26 VTK_ABI_NAMESPACE_BEGIN
27 class vtkFloatArray;
29 class vtkRenderPass;
30 class vtkOpenGLState;
31 class vtkOpenGLTexture;
33 class vtkTextureObject;
36 class vtkPBRLUTTexture;
38 class vtkShaderProgram;
39 class vtkShadowMapPass;
40 class vtkSSAOPass;
41 
42 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLRenderer : public vtkRenderer
43 {
44 public:
45  static vtkOpenGLRenderer* New();
47  void PrintSelf(ostream& os, vtkIndent indent) override;
48 
52  void DeviceRender() override;
53 
57  void DeviceRenderOpaqueGeometry(vtkFrameBufferObjectBase* fbo = nullptr) override;
58 
66 
67  void Clear() override;
68 
72  int UpdateLights() override;
73 
80  int GetDepthPeelingHigherLayer();
81 
86  static bool HaveAppleQueryAllocationBug();
87 
93  bool IsDualDepthPeelingSupported();
94 
95  // Get the state object used to keep track of
96  // OpenGL state
97  vtkOpenGLState* GetState();
98 
99  // get the standard lighting uniform declarations
100  // for the current set of lights
101  const char* GetLightingUniforms();
102 
103  // update the lighting uniforms for this shader if they
104  // are out of date
105  void UpdateLightingUniforms(vtkShaderProgram* prog);
106 
107  // get the complexity of the current lights as a int
108  // 0 = no lighting
109  // 1 = headlight
110  // 2 = directional lights
111  // 3 = positional lights
113  {
114  NoLighting = 0,
115  Headlight = 1,
116  Directional = 2,
117  Positional = 3
118  };
119  vtkGetMacro(LightingComplexity, int);
120 
121  // get the number of lights turned on
122  vtkGetMacro(LightingCount, int);
123 
125 
129  void SetUserLightTransform(vtkTransform* transform);
130  vtkTransform* GetUserLightTransform();
132 
134 
137  vtkPBRLUTTexture* GetEnvMapLookupTable();
138  vtkPBRIrradianceTexture* GetEnvMapIrradiance();
139  vtkPBRPrefilterTexture* GetEnvMapPrefiltered();
141 
145  vtkFloatArray* GetSphericalHarmonics();
146 
148 
151  vtkSetMacro(UseSphericalHarmonics, bool);
152  vtkGetMacro(UseSphericalHarmonics, bool);
153  vtkBooleanMacro(UseSphericalHarmonics, bool);
155 
159  void SetEnvironmentTexture(vtkTexture* texture, bool isSRGB = false) override;
160 
161  // Method to release graphics resources
162  void ReleaseGraphicsResources(vtkWindow* w) override;
163 
164 protected:
166  ~vtkOpenGLRenderer() override;
167 
171  void CheckCompilation(unsigned int fragmentShader);
172 
178  int UpdateGeometry(vtkFrameBufferObjectBase* fbo = nullptr) override;
179 
185  vtkTexture* GetCurrentTexturedBackground();
186 
187  friend class vtkOpenGLProperty;
188  friend class vtkOpenGLTexture;
190  friend class vtkOpenGLImageResliceMapper;
191 
196 
201 
206 
211 
216 
217  // Is rendering at translucent geometry stage using depth peeling and
218  // rendering a layer other than the first one? (Boolean value)
219  // If so, the uniform variables UseTexture and Texture can be set.
220  // (Used by vtkOpenGLProperty or vtkOpenGLTexture)
222 
223  friend class vtkRenderPass;
224 
229 
234 
239  std::unique_ptr<vtkOpenGLQuadHelper> BackgroundRenderer;
241 
242 private:
243  vtkOpenGLRenderer(const vtkOpenGLRenderer&) = delete;
244  void operator=(const vtkOpenGLRenderer&) = delete;
245 };
246 
247 VTK_ABI_NAMESPACE_END
248 #endif
Implement Depth Peeling for use within a framebuffer pass.
std::unique_ptr< vtkOpenGLQuadHelper > BackgroundRenderer
Implement a screen-space ambient occlusion pass.
Definition: vtkSSAOPass.h:34
virtual void ReleaseGraphicsResources(vtkWindow *)
vtkPBRIrradianceTexture * EnvMapIrradiance
vtkShadowMapPass * ShadowMapPass
Shadows are delegated to an instance of vtkShadowMapPass.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
std::string LightingDeclaration
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:30
abstract specification for renderers
Definition: vtkRenderer.h:61
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:49
virtual void SetEnvironmentTexture(vtkTexture *texture, bool isSRGB=false)
Set/Get the environment texture used for image based lighting.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
OpenGL property.
OpenGL mapper for image slice display.
vtkPBRLUTTexture * EnvMapLookupTable
OpenGL texture map.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
vtkOpenGLFXAAFilter * FXAAFilter
FXAA is delegated to an instance of vtkOpenGLFXAAFilter.
vtkSmartPointer< vtkFloatArray > SphericalHarmonics
abstract interface to OpenGL FBOs
OpenGL state storage.
a simple class to control print indentation
Definition: vtkIndent.h:28
precompute prefilter texture used in physically based rendering
vtkSmartPointer< vtkTransform > UserLightTransform
Optional user transform for lights.
virtual int UpdateLights()
Ask all lights to load themselves into rendering pipeline.
Definition: vtkRenderer.h:1051
handles properties associated with a texture map
Definition: vtkTexture.h:57
vtkDepthPeelingPass * DepthPeelingPass
Depth peeling is delegated to an instance of vtkDepthPeelingPass.
virtual int UpdateGeometry(vtkFrameBufferObjectBase *fbo=nullptr)
Ask all props to update and draw any opaque and translucent geometry.
precompute BRDF look-up table texture used in physically based rendering
vtkMTimeType LightingUpdateTime
abstracts an OpenGL texture object.
vtkOrderIndependentTranslucentPass * TranslucentPass
Fallback for transparency.
virtual void DeviceRender()
Create an image.
Definition: vtkRenderer.h:294
virtual void DeviceRenderTranslucentPolygonalGeometry(vtkFrameBufferObjectBase *fbo=nullptr)
Render translucent polygonal geometry.
static vtkRenderer * New()
Create a vtkRenderer with a black background, a white ambient light, two-sided lighting turned on...
Implement a shadow mapping render pass.
Perform FXAA antialiasing on the current framebuffer.
vtkSSAOPass * SSAOPass
SSAO is delegated to an instance of vtkSSAOPass.
Perform part of the rendering of a vtkRenderer.
Definition: vtkRenderPass.h:48
OpenGL renderer.
vtkPBRPrefilterTexture * EnvMapPrefiltered
virtual void DeviceRenderOpaqueGeometry(vtkFrameBufferObjectBase *fbo=nullptr)
Render opaque polygonal geometry.
precompute irradiance texture used in physically based rendering
Implement OIT rendering using average color.
virtual void Clear()
Clear the image to the background color.
Definition: vtkRenderer.h:324
The ShaderProgram uses one or more Shader objects.