VTK  9.7.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 "vtkPBRIrradianceTexture.h" // for ivar
21 #include "vtkPBRLUTTexture.h" // for ivar
22 #include "vtkPBRPrefilterTexture.h" // for ivar
23 #include "vtkRenderingOpenGL2Module.h" // For export macro
24 #include "vtkSmartPointer.h" // For vtkSmartPointer
25 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
26 #include <string> // Ivars
27 
28 VTK_ABI_NAMESPACE_BEGIN
29 class vtkFloatArray;
31 class vtkRenderPass;
32 class vtkOpenGLState;
33 class vtkOpenGLTexture;
35 class vtkTextureObject;
37 class vtkShaderProgram;
38 class vtkShadowMapPass;
39 class vtkSSAOPass;
40 class vtkPolyData;
41 class vtkTexturedActor2D;
44 class vtkCameraPass;
46 
47 class VTKRENDERINGOPENGL2_EXPORT VTK_MARSHALAUTO vtkOpenGLRenderer : public vtkRenderer
48 {
49 public:
50  static vtkOpenGLRenderer* New();
52  static vtkOverrideAttribute* CreateOverrideAttributes();
54  void PrintSelf(ostream& os, vtkIndent indent) override;
55 
59  void DeviceRender() override;
60 
64  void DeviceRenderOpaqueGeometry(vtkFrameBufferObjectBase* fbo = nullptr) override;
65 
73 
74  void Clear() override;
75 
79  int UpdateLights() override;
80 
87  int GetDepthPeelingHigherLayer();
88 
93  static bool HaveAppleQueryAllocationBug();
94 
100  bool IsDualDepthPeelingSupported();
101 
102  // Get the state object used to keep track of
103  // OpenGL state
104  vtkOpenGLState* GetState();
105 
106  // get the standard lighting uniform declarations
107  // for the current set of lights
108  const char* GetLightingUniforms();
109 
110  // update the lighting uniforms for this shader if they
111  // are out of date
112  void UpdateLightingUniforms(vtkShaderProgram* prog);
113 
114  // get the complexity of the current lights as a int
115  // 0 = no lighting
116  // 1 = headlight
117  // 2 = directional lights
118  // 3 = positional lights
120  {
121  NoLighting = 0,
122  Headlight = 1,
123  Directional = 2,
124  Positional = 3
125  };
126  vtkGetMacro(LightingComplexity, int);
127 
128  // get the number of lights turned on
129  vtkGetMacro(LightingCount, int);
130 
132 
136  void SetUserLightTransform(vtkTransform* transform);
137  vtkTransform* GetUserLightTransform();
139 
141 
144  vtkSetSmartPointerMacro(EnvMapLookupTable, vtkPBRLUTTexture);
145  vtkPBRLUTTexture* GetEnvMapLookupTable();
146  vtkSetSmartPointerMacro(EnvMapIrradiance, vtkPBRIrradianceTexture);
147  vtkPBRIrradianceTexture* GetEnvMapIrradiance();
148  vtkSetSmartPointerMacro(EnvMapPrefiltered, vtkPBRPrefilterTexture);
149  vtkPBRPrefilterTexture* GetEnvMapPrefiltered();
151 
155  vtkFloatArray* GetSphericalHarmonics();
156 
158 
161  vtkSetMacro(UseSphericalHarmonics, bool);
162  vtkGetMacro(UseSphericalHarmonics, bool);
163  vtkBooleanMacro(UseSphericalHarmonics, bool);
165 
180  void SetEnvironmentTexture(vtkTexture* texture, bool isSRGB = false) override;
181 
182  // Method to release graphics resources
183  void ReleaseGraphicsResources(vtkWindow* w) override;
184 
185 protected:
187  ~vtkOpenGLRenderer() override;
188 
192  void CheckCompilation(unsigned int fragmentShader);
193 
199  int UpdateGeometry(vtkFrameBufferObjectBase* fbo = nullptr) override;
200 
206  vtkTexture* GetCurrentTexturedBackground();
207 
208  friend class vtkOpenGLProperty;
209  friend class vtkOpenGLTexture;
211  friend class vtkOpenGLImageResliceMapper;
212 
217 
222 
227 
232 
237 
238  // Is rendering at translucent geometry stage using depth peeling and
239  // rendering a layer other than the first one? (Boolean value)
240  // If so, the uniform variables UseTexture and Texture can be set.
241  // (Used by vtkOpenGLProperty or vtkOpenGLTexture)
243 
244  friend class vtkRenderPass;
245 
250 
255 
261 
266 
267 private:
268  vtkOpenGLRenderer(const vtkOpenGLRenderer&) = delete;
269  void operator=(const vtkOpenGLRenderer&) = delete;
270 
276 };
277 
278 #define vtkOpenGLRenderer_OVERRIDE_ATTRIBUTES vtkOpenGLRenderer::CreateOverrideAttributes()
279 VTK_ABI_NAMESPACE_END
280 #endif
vtkSmartPointer< vtkTexturedActor2D > BackgroundTextureActor
Implement Depth Peeling for use within a framebuffer pass.
Attribute for vtkObjectFactory overrides.
vtkSmartPointer< vtkPBRIrradianceTexture > EnvMapIrradiance
Implement a screen-space ambient occlusion pass.
Definition: vtkSSAOPass.h:36
virtual void ReleaseGraphicsResources(vtkWindow *)
actor that draws 2D data with texture support
vtkShadowMapPass * ShadowMapPass
Shadows are delegated to an instance of vtkShadowMapPass.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
std::string LightingDeclaration
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:31
abstract specification for renderers
Definition: vtkRenderer.h:63
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
vtkSmartPointer< vtkPBRPrefilterTexture > EnvMapPrefiltered
virtual void SetEnvironmentTexture(vtkTexture *texture, bool isSRGB=false)
Set/Get the environment texture used for image based lighting.
vtkSmartPointer< vtkPolyDataMapper2D > BackgroundMapper
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Implement the camera render pass.
Definition: vtkCameraPass.h:31
vtkSmartPointer< vtkPBRLUTTexture > EnvMapLookupTable
OpenGL property.
OpenGL mapper for image slice display.
OpenGL texture map.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
vtkOpenGLFXAAFilter * FXAAFilter
FXAA is delegated to an instance of vtkOpenGLFXAAFilter.
vtkSmartPointer< vtkFloatArray > SphericalHarmonics
vtkSmartPointer< vtkPolyData > BackgroundQuad
abstract interface to OpenGL FBOs
OpenGL state storage.
a simple class to control print indentation
Definition: vtkIndent.h:28
Screen space render pass that blur a given image using the hexagonal bokeh method.
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:1145
handles properties associated with a texture map
Definition: vtkTexture.h:58
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.
#define VTK_NEWINSTANCE
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:307
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.
#define VTK_MARSHALAUTO
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:49
OpenGL renderer.
virtual void DeviceRenderOpaqueGeometry(vtkFrameBufferObjectBase *fbo=nullptr)
Render opaque polygonal geometry.
vtkSmartPointer< vtkTexturedActor2D > BackgroundGradientActor
draw vtkPolyData onto the image plane
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:337
The ShaderProgram uses one or more Shader objects.