VTK  9.3.0
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:
47  void PrintSelf(ostream& os, vtkIndent indent) override;
48 
52  void DeviceRender() override;
53 
58 
66 
67  void Clear() override;
68 
72  int UpdateLights() override;
73 
81 
87 
94 
95  // Get the state object used to keep track of
96  // OpenGL state
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
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 
132 
134 
141 
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
163 
164 protected:
166  ~vtkOpenGLRenderer() override;
167 
171  void CheckCompilation(unsigned int fragmentShader);
172 
178  int UpdateGeometry(vtkFrameBufferObjectBase* fbo = nullptr) override;
179 
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.
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:31
abstract interface to OpenGL FBOs
a simple class to control print indentation
Definition: vtkIndent.h:29
Perform FXAA antialiasing on the current framebuffer.
OpenGL mapper for image slice display.
OpenGL property.
OpenGL renderer.
vtkOpenGLState * GetState()
vtkPBRLUTTexture * GetEnvMapLookupTable()
Get environment textures used for image based lighting.
std::unique_ptr< vtkOpenGLQuadHelper > BackgroundRenderer
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPBRPrefilterTexture * EnvMapPrefiltered
void SetEnvironmentTexture(vtkTexture *texture, bool isSRGB=false) override
Overridden in order to connect the texture to the environment map textures.
vtkPBRIrradianceTexture * GetEnvMapIrradiance()
Get environment textures used for image based lighting.
vtkSmartPointer< vtkFloatArray > SphericalHarmonics
vtkShadowMapPass * ShadowMapPass
Shadows are delegated to an instance of vtkShadowMapPass.
vtkPBRIrradianceTexture * EnvMapIrradiance
std::string LightingDeclaration
vtkDepthPeelingPass * DepthPeelingPass
Depth peeling is delegated to an instance of vtkDepthPeelingPass.
vtkPBRLUTTexture * EnvMapLookupTable
static bool HaveAppleQueryAllocationBug()
Indicate if this system is subject to the apple/NVIDIA bug that causes crashes in the driver when too...
const char * GetLightingUniforms()
vtkSSAOPass * SSAOPass
SSAO is delegated to an instance of vtkSSAOPass.
bool IsDualDepthPeelingSupported()
Dual depth peeling may be disabled for certain runtime configurations.
vtkTransform * GetUserLightTransform()
Set the user light transform applied after the camera transform.
vtkTexture * GetCurrentTexturedBackground()
Check and return the textured background for the current state If monocular or stereo left eye,...
vtkSmartPointer< vtkTransform > UserLightTransform
Optional user transform for lights.
void DeviceRenderTranslucentPolygonalGeometry(vtkFrameBufferObjectBase *fbo=nullptr) override
Render translucent polygonal geometry.
int UpdateLights() override
Ask lights to load themselves into graphics pipeline.
vtkOrderIndependentTranslucentPass * TranslucentPass
Fallback for transparency.
vtkMTimeType LightingUpdateTime
static vtkOpenGLRenderer * New()
void DeviceRenderOpaqueGeometry(vtkFrameBufferObjectBase *fbo=nullptr) override
Overridden to support hidden line removal.
vtkOpenGLFXAAFilter * FXAAFilter
FXAA is delegated to an instance of vtkOpenGLFXAAFilter.
void ReleaseGraphicsResources(vtkWindow *w) override
void DeviceRender() override
Concrete open gl render method.
int UpdateGeometry(vtkFrameBufferObjectBase *fbo=nullptr) override
Ask all props to update and draw any opaque and translucent geometry.
void UpdateLightingUniforms(vtkShaderProgram *prog)
vtkFloatArray * GetSphericalHarmonics()
Get spherical harmonics coefficients used for irradiance.
void SetUserLightTransform(vtkTransform *transform)
Set the user light transform applied after the camera transform.
vtkPBRPrefilterTexture * GetEnvMapPrefiltered()
Get environment textures used for image based lighting.
void Clear() override
Clear the image to the background color.
~vtkOpenGLRenderer() override
void CheckCompilation(unsigned int fragmentShader)
Check the compilation status of some fragment shader source.
int GetDepthPeelingHigherLayer()
Is rendering at translucent geometry stage using depth peeling and rendering a layer other than the f...
OpenGL state storage.
OpenGL texture map.
Implement OIT rendering using average color.
precompute irradiance texture used in physically based rendering
precompute BRDF look-up table texture used in physically based rendering
precompute prefilter texture used in physically based rendering
Perform part of the rendering of a vtkRenderer.
Definition: vtkRenderPass.h:49
abstract specification for renderers
Definition: vtkRenderer.h:62
Implement a screen-space ambient occlusion pass.
Definition: vtkSSAOPass.h:35
The ShaderProgram uses one or more Shader objects.
Implement a shadow mapping render pass.
abstracts an OpenGL texture object.
handles properties associated with a texture map
Definition: vtkTexture.h:58
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
window superclass for vtkRenderWindow
Definition: vtkWindow.h:28
@ string
Definition: vtkX3D.h:490
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270