VTK  9.7.1
vtkShadowMapPass.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
32 #ifndef vtkShadowMapPass_h
33 #define vtkShadowMapPass_h
34 
35 #include "vtkOpenGLRenderPass.h"
36 #include "vtkRenderingOpenGL2Module.h" // For export macro
37 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
38 #include <string> // For member variables.
39 #include <vector> // STL Header
40 
41 VTK_ABI_NAMESPACE_BEGIN
44 class vtkCamera;
45 class vtkLight;
46 class vtkFrameBufferObject;
47 class vtkShadowMapPassTextures; // internal
48 class vtkShadowMapPassLightCameras; // internal
51 class vtkShaderProgram;
52 
53 class VTKRENDERINGOPENGL2_EXPORT VTK_MARSHALAUTO vtkShadowMapPass : public vtkOpenGLRenderPass
54 {
55 public:
56  static vtkShadowMapPass* New();
58  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
64  void Render(const vtkRenderState* s) override;
65 
71  void ReleaseGraphicsResources(vtkWindow* w) override;
72 
74 
80  vtkGetObjectMacro(ShadowMapBakerPass, vtkShadowMapBakerPass);
81  virtual void SetShadowMapBakerPass(vtkShadowMapBakerPass* shadowMapBakerPass);
83 
85 
89  vtkGetObjectMacro(OpaqueSequence, vtkRenderPass);
90  virtual void SetOpaqueSequence(vtkRenderPass* opaqueSequence);
92 
97  std::vector<double> ShadowMapTransforms() { return this->ShadowTransforms; }
98 
104  std::vector<int> GetShadowMapTextureUnits() { return this->ShadowTextureUnits; }
105 
110  static vtkInformationObjectBaseKey* ShadowMapPass();
111 
116  std::string GetFragmentDeclaration() { return this->FragmentDeclaration; }
117  std::string GetFragmentImplementation() { return this->FragmentImplementation; }
118 
119  // vtkOpenGLRenderPass virtuals:
120  bool PreReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
121  std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
122  bool PostReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
123  std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
124  bool SetShaderParameters(vtkShaderProgram* program, vtkAbstractMapper* mapper, vtkProp* prop,
125  vtkOpenGLVertexArrayObject* VAO = nullptr) override;
126 
127 protected:
132 
136  ~vtkShadowMapPass() override;
137 
142  void CheckSupport(vtkOpenGLRenderWindow* w);
143 
146 
148 
152  vtkFrameBufferObject* FrameBufferObject;
153 
154  vtkShadowMapPassTextures* ShadowMaps;
155  vtkShadowMapPassLightCameras* LightCameras;
156 
158 
159  // to store the shader code and settings
160  void BuildShaderCode();
163  std::vector<int> ShadowTextureUnits;
164  std::vector<double> ShadowTransforms;
165  std::vector<float> ShadowAttenuation;
166  std::vector<int> ShadowParallel;
167 
168 private:
169  vtkShadowMapPass(const vtkShadowMapPass&) = delete;
170  void operator=(const vtkShadowMapPass&) = delete;
171 };
172 
173 VTK_ABI_NAMESPACE_END
174 #endif
OpenGL rendering window.
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:49
vtkTimeStamp LastRenderTime
vtkShadowMapBakerPass * ShadowMapBakerPass
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkRenderPass * CompositeRGBAPass
record modification and/or execution time
Definition: vtkTimeStamp.h:24
std::string GetFragmentDeclaration()
Get the shader code to compute light factors based on a mappers vertexVC variable.
vtkFrameBufferObject * FrameBufferObject
Graphics resources.
vtkShadowMapPassLightCameras * LightCameras
std::vector< float > ShadowAttenuation
std::vector< int > ShadowParallel
std::vector< double > ShadowTransforms
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
Context in which a vtkRenderPass will render.
std::vector< int > GetShadowMapTextureUnits()
get the texture units for the shadow maps for each light.
vtkRenderPass * OpaqueSequence
a simple class to control print indentation
Definition: vtkIndent.h:28
The VertexArrayObject class uses, or emulates, vertex array objects.
a virtual camera for 3D rendering
Definition: vtkCamera.h:41
Key for integer values in vtkInformation.
a virtual light for 3D rendering
Definition: vtkLight.h:49
Key for vtkObjectBase values.
vtkShadowMapPassTextures * ShadowMaps
std::vector< int > ShadowTextureUnits
abstract class specifies interface to map data
virtual bool PreReplaceShaderValues(std::string &vertexShader, std::string &geometryShader, std::string &fragmentShader, vtkAbstractMapper *mapper, vtkProp *prop)
Use vtkShaderProgram::Substitute to replace.
virtual void Render(const vtkRenderState *s)=0
Perform rendering according to a render state s.
std::vector< double > ShadowMapTransforms()
get the matrices for all the shadow maps.
std::string GetFragmentImplementation()
std::string FragmentImplementation
virtual void ReleaseGraphicsResources(vtkWindow *w)
Release graphics resources and ask components to release their own resources.
Implement a shadow mapping render pass.
#define VTK_MARSHALAUTO
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
Perform part of the rendering of a vtkRenderer.
Definition: vtkRenderPass.h:49
virtual bool SetShaderParameters(vtkShaderProgram *program, vtkAbstractMapper *mapper, vtkProp *prop, vtkOpenGLVertexArrayObject *VAO=nullptr)
Update the uniforms of the shader program.
Abstract render pass with shader modifications.
virtual bool PostReplaceShaderValues(std::string &vertexShader, std::string &geometryShader, std::string &fragmentShader, vtkAbstractMapper *mapper, vtkProp *prop)
Use vtkShaderProgram::Substitute to replace.
std::string FragmentDeclaration
The ShaderProgram uses one or more Shader objects.
Implement a builder of shadow map pass.