VTK  9.3.1
vtkShadowMapBakerPass.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 vtkShadowMapBakerPass_h
33 #define vtkShadowMapBakerPass_h
34 
35 #include "vtkOpenGLRenderPass.h"
36 #include "vtkRenderingOpenGL2Module.h" // For export macro
37 #include "vtkSmartPointer.h" // for ivars
38 #include <vector> // STL Header
39 
40 VTK_ABI_NAMESPACE_BEGIN
43 class vtkCamera;
44 class vtkLight;
46 class vtkTextureObject;
47 
48 class VTKRENDERINGOPENGL2_EXPORT vtkShadowMapBakerPass : public vtkOpenGLRenderPass
49 {
50 public:
51  static vtkShadowMapBakerPass* New();
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
59  void Render(const vtkRenderState* s) override;
60 
66  void ReleaseGraphicsResources(vtkWindow* w) override;
67 
69 
75  vtkGetObjectMacro(OpaqueSequence, vtkRenderPass);
76  virtual void SetOpaqueSequence(vtkRenderPass* opaqueSequence);
78 
80 
86  vtkGetObjectMacro(CompositeZPass, vtkRenderPass);
87  virtual void SetCompositeZPass(vtkRenderPass* compositeZPass);
89 
91 
96  vtkSetMacro(Resolution, unsigned int);
97  vtkGetMacro(Resolution, unsigned int);
99 
107  bool GetHasShadows();
108 
118  bool LightCreatesShadow(vtkLight* l);
119 
126  std::vector<vtkSmartPointer<vtkTextureObject>>* GetShadowMaps();
127 
134  std::vector<vtkSmartPointer<vtkCamera>>* GetLightCameras();
135 
144  bool GetNeedUpdate();
145 
146  // // Description:
147  // INTERNAL USE ONLY.
148  // Internally used by vtkShadowMapBakerPass and vtkShadowMapPass.
149  //
150  // Set NeedUpate to false. Called by vtkShadowMapPass.
151  void SetUpToDate();
152 
153 protected:
158 
162  ~vtkShadowMapBakerPass() override;
163 
164  // vtkOpenGLRenderPass virtuals:
165  bool PreReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
166  std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
167  bool SetShaderParameters(vtkShaderProgram* program, vtkAbstractMapper* mapper, vtkProp* prop,
168  vtkOpenGLVertexArrayObject* VAO = nullptr) override;
169 
177  void PointNearFar(
178  double* v, double* pt, double* dir, double& mNear, double& mFar, bool initialized);
179 
186  void BoxNearFar(double* bb, double* pt, double* dir, double& mNear, double& mFar);
187 
193  void BuildCameraLight(vtkLight* light, double* boundingBox, vtkCamera* lcamera);
194 
199  void CheckSupport(vtkOpenGLRenderWindow* w);
200 
202 
204 
205  unsigned int Resolution;
206 
208 
213 
214  std::vector<vtkSmartPointer<vtkTextureObject>>* ShadowMaps;
215  std::vector<vtkSmartPointer<vtkCamera>>* LightCameras;
216 
220 
221 private:
223  void operator=(const vtkShadowMapBakerPass&) = delete;
224 };
225 
226 VTK_ABI_NAMESPACE_END
227 #endif
OpenGL rendering window.
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:45
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:24
std::vector< vtkSmartPointer< vtkTextureObject > > * ShadowMaps
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
Context in which a vtkRenderPass will render.
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:40
Key for integer values in vtkInformation.
a virtual light for 3D rendering
Definition: vtkLight.h:48
std::vector< vtkSmartPointer< vtkCamera > > * LightCameras
Internal class which encapsulates OpenGL FramebufferObject.
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.
abstracts an OpenGL texture object.
virtual void Render(const vtkRenderState *s)=0
Perform rendering according to a render state s.
virtual void ReleaseGraphicsResources(vtkWindow *w)
Release graphics resources and ask components to release their own resources.
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:48
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.
vtkOpenGLFramebufferObject * FrameBufferObject
Graphics resources.
The ShaderProgram uses one or more Shader objects.
Implement a builder of shadow map pass.