VTK
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 =========================================================================*/
44 #ifndef vtkShadowMapPass_h
45 #define vtkShadowMapPass_h
46 
47 #include "vtkRenderingOpenGL2Module.h" // For export macro
48 #include "vtkOpenGLRenderPass.h"
49 #include <vector> // STL Header
50 #include <string> // For member variables.
51 
54 class vtkCamera;
55 class vtkLight;
56 class vtkFrameBufferObject;
57 class vtkShadowMapPassTextures; // internal
58 class vtkShadowMapPassLightCameras; // internal
61 class vtkShaderProgram;
62 
63 class VTKRENDERINGOPENGL2_EXPORT vtkShadowMapPass : public vtkOpenGLRenderPass
64 {
65 public:
66  static vtkShadowMapPass *New();
68  void PrintSelf(ostream& os, vtkIndent indent) override;
69 
74  void Render(const vtkRenderState *s) override;
75 
81  void ReleaseGraphicsResources(vtkWindow *w) override;
82 
84 
90  vtkGetObjectMacro(ShadowMapBakerPass,vtkShadowMapBakerPass);
91  virtual void SetShadowMapBakerPass(
92  vtkShadowMapBakerPass *shadowMapBakerPass);
94 
96 
100  vtkGetObjectMacro(OpaqueSequence,vtkRenderPass);
101  virtual void SetOpaqueSequence(vtkRenderPass *opaqueSequence);
103 
108  std::vector<double> ShadowMapTransforms() {
109  return this->ShadowTransforms; }
110 
116  std::vector<int> GetShadowMapTextureUnits() {
117  return this->ShadowTextureUnits; }
118 
122  static vtkInformationObjectBaseKey *ShadowMapPass();
123 
129  return this->FragmentDeclaration; }
131  return this->FragmentImplementation; }
132 
133  // vtkOpenGLRenderPass virtuals:
134  bool PreReplaceShaderValues(std::string &vertexShader,
135  std::string &geometryShader,
136  std::string &fragmentShader,
137  vtkAbstractMapper *mapper,
138  vtkProp *prop) override;
139  bool PostReplaceShaderValues(std::string &vertexShader,
140  std::string &geometryShader,
141  std::string &fragmentShader,
142  vtkAbstractMapper *mapper,
143  vtkProp *prop) override;
145  vtkAbstractMapper *mapper, vtkProp *prop,
146  vtkOpenGLVertexArrayObject* VAO = nullptr) override;
147 
148  protected:
153 
157  ~vtkShadowMapPass() override;
158 
163  void CheckSupport(vtkOpenGLRenderWindow *w);
164 
167 
169 
173  vtkFrameBufferObject *FrameBufferObject;
174 
175  vtkShadowMapPassTextures *ShadowMaps;
176  vtkShadowMapPassLightCameras *LightCameras;
177 
179 
180  // to store the shader code and settings
181  void BuildShaderCode();
184  std::vector<int> ShadowTextureUnits;
185  std::vector<double> ShadowTransforms;
186  std::vector<float> ShadowAttenuation;
187  std::vector<int> ShadowParallel;
188 
189 private:
190  vtkShadowMapPass(const vtkShadowMapPass&) = delete;
191  void operator=(const vtkShadowMapPass&) = delete;
192 };
193 
194 #endif
OpenGL rendering window.
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
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:35
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:37
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:39
The VertexArrayObject class uses, or emulates, vertex array objects.
a virtual camera for 3D rendering
Definition: vtkCamera.h:50
Key for integer values in vtkInformation.
a virtual light for 3D rendering
Definition: vtkLight.h:62
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 //VTK::XXX:YYY declarations in the shader sources...
virtual void Render(const vtkRenderState *s)=0
Perform rendering according to a render state s.
std::vector< double > ShadowMapTransforms()
get the matricies 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.
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:58
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 //VTK::XXX:YYY declarations in the shader sources...
std::string FragmentDeclaration
The ShaderProgram uses one or more Shader objects.
Implement a builder of shadow map pass.