VTK  9.3.0
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
41 #ifndef vtkShadowMapBakerPass_h
42 #define vtkShadowMapBakerPass_h
43 
44 #include "vtkOpenGLRenderPass.h"
45 #include "vtkRenderingOpenGL2Module.h" // For export macro
46 #include "vtkSmartPointer.h" // for ivars
47 #include <vector> // STL Header
48 
49 VTK_ABI_NAMESPACE_BEGIN
52 class vtkCamera;
53 class vtkLight;
55 class vtkTextureObject;
56 
57 class VTKRENDERINGOPENGL2_EXPORT vtkShadowMapBakerPass : public vtkOpenGLRenderPass
58 {
59 public:
62  void PrintSelf(ostream& os, vtkIndent indent) override;
63 
68  void Render(const vtkRenderState* s) override;
69 
76 
78 
84  vtkGetObjectMacro(OpaqueSequence, vtkRenderPass);
85  virtual void SetOpaqueSequence(vtkRenderPass* opaqueSequence);
87 
89 
95  vtkGetObjectMacro(CompositeZPass, vtkRenderPass);
96  virtual void SetCompositeZPass(vtkRenderPass* compositeZPass);
98 
100 
105  vtkSetMacro(Resolution, unsigned int);
106  vtkGetMacro(Resolution, unsigned int);
108 
117 
128 
135  std::vector<vtkSmartPointer<vtkTextureObject>>* GetShadowMaps();
136 
143  std::vector<vtkSmartPointer<vtkCamera>>* GetLightCameras();
144 
154 
155  // // Description:
156  // INTERNAL USE ONLY.
157  // Internally used by vtkShadowMapBakerPass and vtkShadowMapPass.
158  //
159  // Set NeedUpate to false. Called by vtkShadowMapPass.
160  void SetUpToDate();
161 
162 protected:
167 
172 
173  // vtkOpenGLRenderPass virtuals:
174  bool PreReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
175  std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
177  vtkOpenGLVertexArrayObject* VAO = nullptr) override;
178 
187  double* v, double* pt, double* dir, double& mNear, double& mFar, bool initialized);
188 
195  void BoxNearFar(double* bb, double* pt, double* dir, double& mNear, double& mFar);
196 
202  void BuildCameraLight(vtkLight* light, double* boundingBox, vtkCamera* lcamera);
203 
209 
211 
213 
214  unsigned int Resolution;
215 
217 
222 
223  std::vector<vtkSmartPointer<vtkTextureObject>>* ShadowMaps;
224  std::vector<vtkSmartPointer<vtkCamera>>* LightCameras;
225 
229 
230 private:
232  void operator=(const vtkShadowMapBakerPass&) = delete;
233 };
234 
235 VTK_ABI_NAMESPACE_END
236 #endif
abstract class specifies interface to map data
a virtual camera for 3D rendering
Definition: vtkCamera.h:50
a simple class to control print indentation
Definition: vtkIndent.h:38
Key for integer values in vtkInformation.
a virtual light for 3D rendering
Definition: vtkLight.h:58
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:55
Perform part of the rendering of a vtkRenderer.
Definition: vtkRenderPass.h:49
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:34
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
@ dir
Definition: vtkX3D.h:324
@ string
Definition: vtkX3D.h:490