VTK  9.2.5
vtkShadowMapBakerPass.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkShadowMapBakerPass.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 =========================================================================*/
73 #ifndef vtkShadowMapBakerPass_h
74 #define vtkShadowMapBakerPass_h
75 
76 #include "vtkOpenGLRenderPass.h"
77 #include "vtkRenderingOpenGL2Module.h" // For export macro
78 #include "vtkSmartPointer.h" // for ivars
79 #include <vector> // STL Header
80 
83 class vtkCamera;
84 class vtkLight;
86 class vtkTextureObject;
87 
88 class VTKRENDERINGOPENGL2_EXPORT vtkShadowMapBakerPass : public vtkOpenGLRenderPass
89 {
90 public:
93  void PrintSelf(ostream& os, vtkIndent indent) override;
94 
99  void Render(const vtkRenderState* s) override;
100 
107 
109 
115  vtkGetObjectMacro(OpaqueSequence, vtkRenderPass);
116  virtual void SetOpaqueSequence(vtkRenderPass* opaqueSequence);
118 
120 
126  vtkGetObjectMacro(CompositeZPass, vtkRenderPass);
127  virtual void SetCompositeZPass(vtkRenderPass* compositeZPass);
129 
131 
136  vtkSetMacro(Resolution, unsigned int);
137  vtkGetMacro(Resolution, unsigned int);
139 
148 
159 
166  std::vector<vtkSmartPointer<vtkTextureObject>>* GetShadowMaps();
167 
174  std::vector<vtkSmartPointer<vtkCamera>>* GetLightCameras();
175 
185 
186  // // Description:
187  // INTERNAL USE ONLY.
188  // Internally used by vtkShadowMapBakerPass and vtkShadowMapPass.
189  //
190  // Set NeedUpate to false. Called by vtkShadowMapPass.
191  void SetUpToDate();
192 
193 protected:
198 
203 
204  // vtkOpenGLRenderPass virtuals:
205  bool PreReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
206  std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
208  vtkOpenGLVertexArrayObject* VAO = nullptr) override;
209 
218  double* v, double* pt, double* dir, double& mNear, double& mFar, bool initialized);
219 
226  void BoxNearFar(double* bb, double* pt, double* dir, double& mNear, double& mFar);
227 
233  void BuildCameraLight(vtkLight* light, double* boundingBox, vtkCamera* lcamera);
234 
240 
242 
244 
245  unsigned int Resolution;
246 
248 
253 
254  std::vector<vtkSmartPointer<vtkTextureObject>>* ShadowMaps;
255  std::vector<vtkSmartPointer<vtkCamera>>* LightCameras;
256 
260 
261 private:
263  void operator=(const vtkShadowMapBakerPass&) = delete;
264 };
265 
266 #endif
abstract class specifies interface to map data
a virtual camera for 3D rendering
Definition: vtkCamera.h:161
a simple class to control print indentation
Definition: vtkIndent.h:119
Key for integer values in vtkInformation.
a virtual light for 3D rendering
Definition: vtkLight.h:169
Internal class which encapsulates OpenGL FramebufferObject.
Abstract render pass with shader modifications.
OpenGL rendering window.
The VertexArrayObject class uses, or emulates, vertex array objects.
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:76
Perform part of the rendering of a vtkRenderer.
Definition: vtkRenderPass.h:60
Context in which a vtkRenderPass will render.
The ShaderProgram uses one or more Shader objects.
Implement a builder of shadow map pass.
bool SetShaderParameters(vtkShaderProgram *program, vtkAbstractMapper *mapper, vtkProp *prop, vtkOpenGLVertexArrayObject *VAO=nullptr) override
Update the uniforms of the shader program.
std::vector< vtkSmartPointer< vtkTextureObject > > * GetShadowMaps()
INTERNAL USE ONLY Internally used by vtkShadowMapBakerPass and vtkShadowMapPass.
vtkShadowMapBakerPass()
Default constructor.
bool PreReplaceShaderValues(std::string &vertexShader, std::string &geometryShader, std::string &fragmentShader, vtkAbstractMapper *mapper, vtkProp *prop) override
Use vtkShaderProgram::Substitute to replace.
virtual void SetOpaqueSequence(vtkRenderPass *opaqueSequence)
Delegate for rendering the camera, lights, and opaque geometry.
std::vector< vtkSmartPointer< vtkCamera > > * GetLightCameras()
INTERNAL USE ONLY.
void CheckSupport(vtkOpenGLRenderWindow *w)
Check if shadow mapping is supported by the current OpenGL context.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
std::vector< vtkSmartPointer< vtkCamera > > * LightCameras
void BoxNearFar(double *bb, double *pt, double *dir, double &mNear, double &mFar)
Compute the min/max of the projection of a box in a given direction.
bool LightCreatesShadow(vtkLight *l)
INTERNAL USE ONLY.
~vtkShadowMapBakerPass() override
Destructor.
void PointNearFar(double *v, double *pt, double *dir, double &mNear, double &mFar, bool initialized)
Helper method to compute the mNearest point in a given direction.
void ReleaseGraphicsResources(vtkWindow *w) override
Release graphics resources and ask components to release their own resources.
bool GetHasShadows()
INTERNAL USE ONLY.
void BuildCameraLight(vtkLight *light, double *boundingBox, vtkCamera *lcamera)
Build a camera from spot light parameters.
static vtkShadowMapBakerPass * New()
void Render(const vtkRenderState *s) override
Perform rendering according to a render state s.
vtkOpenGLFramebufferObject * FrameBufferObject
Graphics resources.
bool GetNeedUpdate()
INTERNAL USE ONLY.
std::vector< vtkSmartPointer< vtkTextureObject > > * ShadowMaps
virtual void SetCompositeZPass(vtkRenderPass *compositeZPass)
Delegate for compositing of the shadow maps across processors.
abstracts an OpenGL texture object.
record modification and/or execution time
Definition: vtkTimeStamp.h:55
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
@ dir
Definition: vtkX3D.h:330
@ string
Definition: vtkX3D.h:496