VTK  9.0.20201128
vtkShadowMapPass.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkShadowMapPass.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
41 #ifndef vtkShadowMapPass_h
42 #define vtkShadowMapPass_h
43 
44 #include "vtkOpenGLRenderPass.h"
45 #include "vtkRenderingOpenGL2Module.h" // For export macro
46 #include <string> // For member variables.
47 #include <vector> // STL Header
48 
51 class vtkCamera;
52 class vtkLight;
53 class vtkFrameBufferObject;
54 class vtkShadowMapPassTextures; // internal
55 class vtkShadowMapPassLightCameras; // internal
58 class vtkShaderProgram;
59 
60 class VTKRENDERINGOPENGL2_EXPORT vtkShadowMapPass : public vtkOpenGLRenderPass
61 {
62 public:
63  static vtkShadowMapPass* New();
65  void PrintSelf(ostream& os, vtkIndent indent) override;
66 
71  void Render(const vtkRenderState* s) override;
72 
78  void ReleaseGraphicsResources(vtkWindow* w) override;
79 
81 
87  vtkGetObjectMacro(ShadowMapBakerPass, vtkShadowMapBakerPass);
88  virtual void SetShadowMapBakerPass(vtkShadowMapBakerPass* shadowMapBakerPass);
90 
92 
96  vtkGetObjectMacro(OpaqueSequence, vtkRenderPass);
97  virtual void SetOpaqueSequence(vtkRenderPass* opaqueSequence);
99 
104  std::vector<double> ShadowMapTransforms() { return this->ShadowTransforms; }
105 
111  std::vector<int> GetShadowMapTextureUnits() { return this->ShadowTextureUnits; }
112 
116  static vtkInformationObjectBaseKey* ShadowMapPass();
117 
122  std::string GetFragmentDeclaration() { return this->FragmentDeclaration; }
123  std::string GetFragmentImplementation() { return this->FragmentImplementation; }
124 
125  // vtkOpenGLRenderPass virtuals:
126  bool PreReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
127  std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
128  bool PostReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
129  std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
130  bool SetShaderParameters(vtkShaderProgram* program, vtkAbstractMapper* mapper, vtkProp* prop,
131  vtkOpenGLVertexArrayObject* VAO = nullptr) override;
132 
133 protected:
138 
142  ~vtkShadowMapPass() override;
143 
148  void CheckSupport(vtkOpenGLRenderWindow* w);
149 
152 
154 
158  vtkFrameBufferObject* FrameBufferObject;
159 
160  vtkShadowMapPassTextures* ShadowMaps;
161  vtkShadowMapPassLightCameras* LightCameras;
162 
164 
165  // to store the shader code and settings
166  void BuildShaderCode();
169  std::vector<int> ShadowTextureUnits;
170  std::vector<double> ShadowTransforms;
171  std::vector<float> ShadowAttenuation;
172  std::vector<int> ShadowParallel;
173 
174 private:
175  vtkShadowMapPass(const vtkShadowMapPass&) = delete;
176  void operator=(const vtkShadowMapPass&) = delete;
177 };
178 
179 #endif
vtkShadowMapPass::OpaqueSequence
vtkRenderPass * OpaqueSequence
Definition: vtkShadowMapPass.h:153
vtkLight
a virtual light for 3D rendering
Definition: vtkLight.h:56
vtkRenderPass::ReleaseGraphicsResources
virtual void ReleaseGraphicsResources(vtkWindow *w)
Release graphics resources and ask components to release their own resources.
vtkOpenGLRenderPass::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkShadowMapPass::ShadowMaps
vtkShadowMapPassTextures * ShadowMaps
Definition: vtkShadowMapPass.h:160
vtkOpenGLRenderPass::PreReplaceShaderValues
virtual bool PreReplaceShaderValues(std::string &vertexShader, std::string &geometryShader, std::string &fragmentShader, vtkAbstractMapper *mapper, vtkProp *prop)
Use vtkShaderProgram::Substitute to replace //VTK::XXX:YYY declarations in the shader sources.
vtkShadowMapPass::ShadowTextureUnits
std::vector< int > ShadowTextureUnits
Definition: vtkShadowMapPass.h:169
vtkRenderPass::Render
virtual void Render(const vtkRenderState *s)=0
Perform rendering according to a render state s.
vtkShadowMapPass::FragmentImplementation
std::string FragmentImplementation
Definition: vtkShadowMapPass.h:168
vtkShadowMapPass::ShadowMapTransforms
std::vector< double > ShadowMapTransforms()
get the matricies for all the shadow maps.
Definition: vtkShadowMapPass.h:104
vtkShadowMapPass::GetFragmentImplementation
std::string GetFragmentImplementation()
Definition: vtkShadowMapPass.h:123
vtkShadowMapPass
Implement a shadow mapping render pass.
Definition: vtkShadowMapPass.h:60
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
vtkOpenGLRenderPass::SetShaderParameters
virtual bool SetShaderParameters(vtkShaderProgram *program, vtkAbstractMapper *mapper, vtkProp *prop, vtkOpenGLVertexArrayObject *VAO=nullptr)
Update the uniforms of the shader program.
vtkShadowMapPass::FragmentDeclaration
std::string FragmentDeclaration
Definition: vtkShadowMapPass.h:167
vtkShadowMapPass::LastRenderTime
vtkTimeStamp LastRenderTime
Definition: vtkShadowMapPass.h:163
vtkShaderProgram
The ShaderProgram uses one or more Shader objects.
Definition: vtkShaderProgram.h:44
vtkInformationObjectBaseKey
Key for vtkObjectBase values.
Definition: vtkInformationObjectBaseKey.h:33
vtkInformationIntegerKey
Key for integer values in vtkInformation.
Definition: vtkInformationIntegerKey.h:31
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkCamera
a virtual camera for 3D rendering
Definition: vtkCamera.h:45
vtkShadowMapPass::ShadowMapBakerPass
vtkShadowMapBakerPass * ShadowMapBakerPass
Definition: vtkShadowMapPass.h:150
vtkOpenGLRenderPass::PostReplaceShaderValues
virtual bool PostReplaceShaderValues(std::string &vertexShader, std::string &geometryShader, std::string &fragmentShader, vtkAbstractMapper *mapper, vtkProp *prop)
Use vtkShaderProgram::Substitute to replace //VTK::XXX:YYY declarations in the shader sources.
vtkShadowMapPass::CompositeRGBAPass
vtkRenderPass * CompositeRGBAPass
Definition: vtkShadowMapPass.h:151
vtkShadowMapPass::GetFragmentDeclaration
std::string GetFragmentDeclaration()
Get the shader code to compute light factors based on a mappers vertexVC variable.
Definition: vtkShadowMapPass.h:122
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
vtkX3D::string
Definition: vtkX3D.h:496
vtkShadowMapPass::ShadowParallel
std::vector< int > ShadowParallel
Definition: vtkShadowMapPass.h:172
vtkOpenGLRenderPass
Abstract render pass with shader modifications.
Definition: vtkOpenGLRenderPass.h:38
vtkOpenGLRenderPass.h
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:53
vtkShadowMapPass::LightCameras
vtkShadowMapPassLightCameras * LightCameras
Definition: vtkShadowMapPass.h:161
vtkShadowMapPass::FrameBufferObject
vtkFrameBufferObject * FrameBufferObject
Graphics resources.
Definition: vtkShadowMapPass.h:158
vtkRenderState
Context in which a vtkRenderPass will render.
Definition: vtkRenderState.h:40
vtkShadowMapPass::ShadowAttenuation
std::vector< float > ShadowAttenuation
Definition: vtkShadowMapPass.h:171
vtkShadowMapPass::GetShadowMapTextureUnits
std::vector< int > GetShadowMapTextureUnits()
get the texture units for the shadow maps for each light.
Definition: vtkShadowMapPass.h:111
vtkShadowMapPass::ShadowTransforms
std::vector< double > ShadowTransforms
Definition: vtkShadowMapPass.h:170
vtkOpenGLVertexArrayObject
The VertexArrayObject class uses, or emulates, vertex array objects.
Definition: vtkOpenGLVertexArrayObject.h:36
vtkShadowMapBakerPass
Implement a builder of shadow map pass.
Definition: vtkShadowMapBakerPass.h:56
vtkAbstractMapper
abstract class specifies interface to map data
Definition: vtkAbstractMapper.h:52
vtkRenderPass
Perform part of the rendering of a vtkRenderer.
Definition: vtkRenderPass.h:56