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 =========================================================================*/
41 #ifndef vtkShadowMapPass_h
42 #define vtkShadowMapPass_h
43 
44 #include "vtkRenderingOpenGL2Module.h" // For export macro
45 #include "vtkOpenGLRenderPass.h"
46 #include <vector> // STL Header
47 #include <string> // For member variables.
48 
51 class vtkCamera;
52 class vtkLight;
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) VTK_OVERRIDE;
66 
71  void Render(const vtkRenderState *s) VTK_OVERRIDE;
72 
78  void ReleaseGraphicsResources(vtkWindow *w) VTK_OVERRIDE;
79 
81 
87  vtkGetObjectMacro(ShadowMapBakerPass,vtkShadowMapBakerPass);
88  virtual void SetShadowMapBakerPass(
89  vtkShadowMapBakerPass *shadowMapBakerPass);
91 
93 
97  vtkGetObjectMacro(OpaqueSequence,vtkRenderPass);
98  virtual void SetOpaqueSequence(vtkRenderPass *opaqueSequence);
100 
105  std::vector<double> ShadowMapTransforms() {
106  return this->ShadowTransforms; }
107 
113  std::vector<int> GetShadowMapTextureUnits() {
114  return this->ShadowTextureUnits; }
115 
119  static vtkInformationObjectBaseKey *ShadowMapPass();
120 
126  return this->FragmentDeclaration; }
128  return this->FragmentImplementation; }
129 
130  // vtkOpenGLRenderPass virtuals:
131  bool PreReplaceShaderValues(std::string &vertexShader,
132  std::string &geometryShader,
133  std::string &fragmentShader,
134  vtkAbstractMapper *mapper,
135  vtkProp *prop) VTK_OVERRIDE;
136  bool PostReplaceShaderValues(std::string &vertexShader,
137  std::string &geometryShader,
138  std::string &fragmentShader,
139  vtkAbstractMapper *mapper,
140  vtkProp *prop) VTK_OVERRIDE;
142  vtkAbstractMapper *mapper, vtkProp *prop,
143  vtkOpenGLVertexArrayObject* VAO = NULL) VTK_OVERRIDE;
144 
145  protected:
150 
154  ~vtkShadowMapPass() VTK_OVERRIDE;
155 
160  void CheckSupport(vtkOpenGLRenderWindow *w);
161 
162  vtkShadowMapBakerPass *ShadowMapBakerPass;
163  vtkRenderPass *CompositeRGBAPass;
164 
166 
170  vtkFrameBufferObject *FrameBufferObject;
171 
172  vtkShadowMapPassTextures *ShadowMaps;
173  vtkShadowMapPassLightCameras *LightCameras;
174 
175  vtkTimeStamp LastRenderTime;
176 
177  // to store the shader code and settings
178  void BuildShaderCode();
181  std::vector<int> ShadowTextureUnits;
182  std::vector<double> ShadowTransforms;
183  std::vector<float> ShadowAttenuation;
184 
185 private:
186  vtkShadowMapPass(const vtkShadowMapPass&) VTK_DELETE_FUNCTION;
187  void operator=(const vtkShadowMapPass&) VTK_DELETE_FUNCTION;
188 };
189 
190 #endif
OpenGL rendering window.
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:44
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
record modification and/or execution time
Definition: vtkTimeStamp.h:32
std::string GetFragmentDeclaration()
Get the shader code to compute light factors based on a mappers vertexVC variable.
virtual bool SetShaderParameters(vtkShaderProgram *program, vtkAbstractMapper *mapper, vtkProp *prop, vtkOpenGLVertexArrayObject *VAO=NULL)
Update the uniforms of the shader program.
std::vector< float > ShadowAttenuation
std::vector< double > ShadowTransforms
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
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:33
The VertexArrayObject class uses, or emulates, vertex array objects.
a virtual camera for 3D rendering
Definition: vtkCamera.h:44
Key for integer values in vtkInformation.
a virtual light for 3D rendering
Definition: vtkLight.h:55
Key for vtkObjectBase values.
std::vector< int > ShadowTextureUnits
internal class which encapsulates OpenGL frame buffer object.
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:55
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.