VTK  9.0.1
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 =========================================================================*/
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 
51 class vtkCamera;
52 class vtkLight;
54 class vtkTextureObject;
55 
56 class VTKRENDERINGOPENGL2_EXPORT vtkShadowMapBakerPass : public vtkOpenGLRenderPass
57 {
58 public:
59  static vtkShadowMapBakerPass* New();
61  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
67  void Render(const vtkRenderState* s) override;
68 
74  void ReleaseGraphicsResources(vtkWindow* w) override;
75 
77 
83  vtkGetObjectMacro(OpaqueSequence, vtkRenderPass);
84  virtual void SetOpaqueSequence(vtkRenderPass* opaqueSequence);
86 
88 
94  vtkGetObjectMacro(CompositeZPass, vtkRenderPass);
95  virtual void SetCompositeZPass(vtkRenderPass* compositeZPass);
97 
99 
104  vtkSetMacro(Resolution, unsigned int);
105  vtkGetMacro(Resolution, unsigned int);
107 
115  bool GetHasShadows();
116 
126  bool LightCreatesShadow(vtkLight* l);
127 
134  std::vector<vtkSmartPointer<vtkTextureObject> >* GetShadowMaps();
135 
142  std::vector<vtkSmartPointer<vtkCamera> >* GetLightCameras();
143 
152  bool GetNeedUpdate();
153 
154  // // Description:
155  // INTERNAL USE ONLY.
156  // Internally used by vtkShadowMapBakerPass and vtkShadowMapPass.
157  //
158  // Set NeedUpate to false. Called by vtkShadowMapPass.
159  void SetUpToDate();
160 
161 protected:
166 
170  ~vtkShadowMapBakerPass() override;
171 
172  // vtkOpenGLRenderPass virtuals:
173  bool PreReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
174  std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
175  bool SetShaderParameters(vtkShaderProgram* program, vtkAbstractMapper* mapper, vtkProp* prop,
176  vtkOpenGLVertexArrayObject* VAO = nullptr) override;
177 
185  void PointNearFar(
186  double* v, double* pt, double* dir, double& mNear, double& mFar, bool initialized);
187 
194  void BoxNearFar(double* bb, double* pt, double* dir, double& mNear, double& mFar);
195 
201  void BuildCameraLight(vtkLight* light, double* boundingBox, vtkCamera* lcamera);
202 
207  void CheckSupport(vtkOpenGLRenderWindow* w);
208 
210 
212 
213  unsigned int Resolution;
214 
216 
221 
222  std::vector<vtkSmartPointer<vtkTextureObject> >* ShadowMaps;
223  std::vector<vtkSmartPointer<vtkCamera> >* LightCameras;
224 
228 
229 private:
231  void operator=(const vtkShadowMapBakerPass&) = delete;
232 };
233 
234 #endif
vtkShadowMapBakerPass::ShadowMaps
std::vector< vtkSmartPointer< vtkTextureObject > > * ShadowMaps
Definition: vtkShadowMapBakerPass.h:222
vtkLight
a virtual light for 3D rendering
Definition: vtkLight.h:56
vtkRenderPass::ReleaseGraphicsResources
virtual void ReleaseGraphicsResources(vtkWindow *w)
Release graphics resources and ask components to release their own resources.
vtkOpenGLRenderPass::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkOpenGLRenderPass::PreReplaceShaderValues
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.
vtkRenderPass::Render
virtual void Render(const vtkRenderState *s)=0
Perform rendering according to a render state s.
vtkOpenGLFramebufferObject
Internal class which encapsulates OpenGL FramebufferObject.
Definition: vtkOpenGLFramebufferObject.h:181
vtkX3D::dir
@ dir
Definition: vtkX3D.h:330
vtkShadowMapBakerPass::FrameBufferObject
vtkOpenGLFramebufferObject * FrameBufferObject
Graphics resources.
Definition: vtkShadowMapBakerPass.h:220
vtkShadowMapBakerPass::Resolution
unsigned int Resolution
Definition: vtkShadowMapBakerPass.h:213
vtkShadowMapBakerPass::LightCameras
std::vector< vtkSmartPointer< vtkCamera > > * LightCameras
Definition: vtkShadowMapBakerPass.h:223
vtkShadowMapBakerPass::NeedUpdate
bool NeedUpdate
Definition: vtkShadowMapBakerPass.h:226
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
vtkShadowMapBakerPass::CompositeZPass
vtkRenderPass * CompositeZPass
Definition: vtkShadowMapBakerPass.h:211
vtkOpenGLRenderPass::SetShaderParameters
virtual bool SetShaderParameters(vtkShaderProgram *program, vtkAbstractMapper *mapper, vtkProp *prop, vtkOpenGLVertexArrayObject *VAO=nullptr)
Update the uniforms of the shader program.
vtkShadowMapBakerPass::LastRenderTime
vtkTimeStamp LastRenderTime
Definition: vtkShadowMapBakerPass.h:225
vtkShaderProgram
The ShaderProgram uses one or more Shader objects.
Definition: vtkShaderProgram.h:44
vtkInformationIntegerKey
Key for integer values in vtkInformation.
Definition: vtkInformationIntegerKey.h:31
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkTextureObject
abstracts an OpenGL texture object.
Definition: vtkTextureObject.h:40
vtkCamera
a virtual camera for 3D rendering
Definition: vtkCamera.h:45
vtkShadowMapBakerPass::CurrentLightIndex
size_t CurrentLightIndex
Definition: vtkShadowMapBakerPass.h:227
vtkSmartPointer.h
vtkShadowMapBakerPass::HasShadows
bool HasShadows
Definition: vtkShadowMapBakerPass.h:215
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:53
vtkX3D::string
@ string
Definition: vtkX3D.h:496
vtkShadowMapBakerPass::OpaqueSequence
vtkRenderPass * OpaqueSequence
Definition: vtkShadowMapBakerPass.h:209
vtkOpenGLRenderPass
Abstract render pass with shader modifications.
Definition: vtkOpenGLRenderPass.h:38
vtkOpenGLRenderPass.h
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:51
vtkRenderState
Context in which a vtkRenderPass will render.
Definition: vtkRenderState.h:40
vtkOpenGLVertexArrayObject
The VertexArrayObject class uses, or emulates, vertex array objects.
Definition: vtkOpenGLVertexArrayObject.h:36
vtkShadowMapBakerPass
Implement a builder of shadow map pass.
Definition: vtkShadowMapBakerPass.h:56
vtkAbstractMapper
abstract class specifies interface to map data
Definition: vtkAbstractMapper.h:52
vtkRenderPass
Perform part of the rendering of a vtkRenderer.
Definition: vtkRenderPass.h:56