VTK  9.7.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 "vtkWrappingHints.h" // For VTK_MARSHALAUTO
39 #include <vector> // STL Header
40 
41 VTK_ABI_NAMESPACE_BEGIN
44 class vtkCamera;
45 class vtkLight;
47 class vtkTextureObject;
48 
49 class VTKRENDERINGOPENGL2_EXPORT VTK_MARSHALAUTO vtkShadowMapBakerPass : public vtkOpenGLRenderPass
50 {
51 public:
52  static vtkShadowMapBakerPass* New();
54  void PrintSelf(ostream& os, vtkIndent indent) override;
55 
60  void Render(const vtkRenderState* s) override;
61 
67  void ReleaseGraphicsResources(vtkWindow* w) override;
68 
70 
76  vtkGetObjectMacro(OpaqueSequence, vtkRenderPass);
77  virtual void SetOpaqueSequence(vtkRenderPass* opaqueSequence);
79 
81 
87  vtkGetObjectMacro(CompositeZPass, vtkRenderPass);
88  virtual void SetCompositeZPass(vtkRenderPass* compositeZPass);
90 
92 
97  vtkSetMacro(Resolution, unsigned int);
98  vtkGetMacro(Resolution, unsigned int);
100 
102 
114  vtkSetMacro(ExponentialConstant, float);
115  vtkGetMacro(ExponentialConstant, float);
117 
125  bool GetHasShadows();
126 
136  bool LightCreatesShadow(vtkLight* l);
137 
144  std::vector<vtkSmartPointer<vtkTextureObject>>* GetShadowMaps();
145 
152  std::vector<vtkSmartPointer<vtkCamera>>* GetLightCameras();
153 
162  bool GetNeedUpdate();
163 
164  // // Description:
165  // INTERNAL USE ONLY.
166  // Internally used by vtkShadowMapBakerPass and vtkShadowMapPass.
167  //
168  // Set NeedUpate to false. Called by vtkShadowMapPass.
169  void SetUpToDate();
170 
171 protected:
176 
180  ~vtkShadowMapBakerPass() override;
181 
182  // vtkOpenGLRenderPass virtuals:
183  bool PreReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
184  std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
185  bool SetShaderParameters(vtkShaderProgram* program, vtkAbstractMapper* mapper, vtkProp* prop,
186  vtkOpenGLVertexArrayObject* VAO = nullptr) override;
187 
195  void PointNearFar(
196  double* v, double* pt, double* dir, double& mNear, double& mFar, bool initialized);
197 
204  void BoxNearFar(double* bb, double* pt, double* dir, double& mNear, double& mFar);
205 
211  void BuildCameraLight(vtkLight* light, double* boundingBox, vtkCamera* lcamera);
212 
217  void CheckSupport(vtkOpenGLRenderWindow* w);
218 
220 
222 
223  unsigned int Resolution;
224  float ExponentialConstant{ 11.0f };
225 
227 
232 
233  std::vector<vtkSmartPointer<vtkTextureObject>>* ShadowMaps;
234  std::vector<vtkSmartPointer<vtkCamera>>* LightCameras;
235 
239 
240 private:
242  void operator=(const vtkShadowMapBakerPass&) = delete;
243 };
244 
245 VTK_ABI_NAMESPACE_END
246 #endif
OpenGL rendering window.
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:49
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:41
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:41
Key for integer values in vtkInformation.
a virtual light for 3D rendering
Definition: vtkLight.h:49
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.
#define VTK_MARSHALAUTO
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:49
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.