VTK  9.1.0
vtkShadowMapPass.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkShadowMapPass.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=========================================================================*/
70#ifndef vtkShadowMapPass_h
71#define vtkShadowMapPass_h
72
73#include "vtkOpenGLRenderPass.h"
74#include "vtkRenderingOpenGL2Module.h" // For export macro
75#include <string> // For member variables.
76#include <vector> // STL Header
77
80class vtkCamera;
81class vtkLight;
82class vtkFrameBufferObject;
83class vtkShadowMapPassTextures; // internal
84class vtkShadowMapPassLightCameras; // internal
88
89class VTKRENDERINGOPENGL2_EXPORT vtkShadowMapPass : public vtkOpenGLRenderPass
90{
91public:
94 void PrintSelf(ostream& os, vtkIndent indent) override;
95
100 void Render(const vtkRenderState* s) override;
101
108
110
116 vtkGetObjectMacro(ShadowMapBakerPass, vtkShadowMapBakerPass);
117 virtual void SetShadowMapBakerPass(vtkShadowMapBakerPass* shadowMapBakerPass);
119
121
125 vtkGetObjectMacro(OpaqueSequence, vtkRenderPass);
126 virtual void SetOpaqueSequence(vtkRenderPass* opaqueSequence);
128
133 std::vector<double> ShadowMapTransforms() { return this->ShadowTransforms; }
134
140 std::vector<int> GetShadowMapTextureUnits() { return this->ShadowTextureUnits; }
141
146
151 std::string GetFragmentDeclaration() { return this->FragmentDeclaration; }
152 std::string GetFragmentImplementation() { return this->FragmentImplementation; }
153
154 // vtkOpenGLRenderPass virtuals:
155 bool PreReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
156 std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
157 bool PostReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
158 std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
160 vtkOpenGLVertexArrayObject* VAO = nullptr) override;
161
162protected:
167
172
178
181
183
187 vtkFrameBufferObject* FrameBufferObject;
188
189 vtkShadowMapPassTextures* ShadowMaps;
190 vtkShadowMapPassLightCameras* LightCameras;
191
193
194 // to store the shader code and settings
198 std::vector<int> ShadowTextureUnits;
199 std::vector<double> ShadowTransforms;
200 std::vector<float> ShadowAttenuation;
201 std::vector<int> ShadowParallel;
202
203private:
204 vtkShadowMapPass(const vtkShadowMapPass&) = delete;
205 void operator=(const vtkShadowMapPass&) = delete;
206};
207
208#endif
abstract class specifies interface to map data
a virtual camera for 3D rendering
Definition: vtkCamera.h:155
a simple class to control print indentation
Definition: vtkIndent.h:113
Key for integer values in vtkInformation.
Key for vtkObjectBase values.
a virtual light for 3D rendering
Definition: vtkLight.h:166
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:67
Perform part of the rendering of a vtkRenderer.
Definition: vtkRenderPass.h:57
Context in which a vtkRenderPass will render.
The ShaderProgram uses one or more Shader objects.
Implement a builder of shadow map pass.
Implement a shadow mapping render pass.
std::vector< int > ShadowTextureUnits
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
std::vector< int > ShadowParallel
std::vector< float > ShadowAttenuation
std::string FragmentDeclaration
static vtkShadowMapPass * New()
std::vector< int > GetShadowMapTextureUnits()
get the texture units for the shadow maps for each light.
void ReleaseGraphicsResources(vtkWindow *w) override
Release graphics resources and ask components to release their own resources.
vtkShadowMapPassLightCameras * LightCameras
std::string FragmentImplementation
vtkShadowMapBakerPass * ShadowMapBakerPass
bool PreReplaceShaderValues(std::string &vertexShader, std::string &geometryShader, std::string &fragmentShader, vtkAbstractMapper *mapper, vtkProp *prop) override
Use vtkShaderProgram::Substitute to replace.
vtkRenderPass * OpaqueSequence
virtual void SetOpaqueSequence(vtkRenderPass *opaqueSequence)
Pass that render the lights and opaque geometry Typically a sequence pass with a light pass and opaqu...
void CheckSupport(vtkOpenGLRenderWindow *w)
Check if shadow mapping is supported by the current OpenGL context.
virtual void SetShadowMapBakerPass(vtkShadowMapBakerPass *shadowMapBakerPass)
Pass that generates the shadow maps.
static vtkInformationObjectBaseKey * ShadowMapPass()
this key will contain the shadow map pass
bool SetShaderParameters(vtkShaderProgram *program, vtkAbstractMapper *mapper, vtkProp *prop, vtkOpenGLVertexArrayObject *VAO=nullptr) override
Update the uniforms of the shader program.
vtkFrameBufferObject * FrameBufferObject
Graphics resources.
void BuildShaderCode()
std::string GetFragmentDeclaration()
Get the shader code to compute light factors based on a mappers vertexVC variable.
vtkShadowMapPassTextures * ShadowMaps
~vtkShadowMapPass() override
Destructor.
std::vector< double > ShadowTransforms
void Render(const vtkRenderState *s) override
Perform rendering according to a render state s.
std::vector< double > ShadowMapTransforms()
get the matricies for all the shadow maps.
std::string GetFragmentImplementation()
vtkRenderPass * CompositeRGBAPass
bool PostReplaceShaderValues(std::string &vertexShader, std::string &geometryShader, std::string &fragmentShader, vtkAbstractMapper *mapper, vtkProp *prop) override
Use vtkShaderProgram::Substitute to replace.
vtkShadowMapPass()
Default constructor.
vtkTimeStamp LastRenderTime
record modification and/or execution time
Definition: vtkTimeStamp.h:52
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
@ string
Definition: vtkX3D.h:496