CustomPSSMShadowCameraSetup.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef GAZEBO_RENDERING_CUSTOMPSSMSHADOWCAMERASETUP_HH_
19 #define GAZEBO_RENDERING_CUSTOMPSSMSHADOWCAMERASETUP_HH_
20 
22 
23 #include "gazebo/util/system.hh"
24 
25 namespace gazebo
26 {
27  namespace rendering
28  {
31  class GAZEBO_VISIBLE CustomPSSM3 : public Ogre::RTShader::IntegratedPSSM3
32  {
34  public: CustomPSSM3() {}
35 
36  // Documentation inherited
37  public: virtual const Ogre::String &getType() const override;
38 
44  protected: virtual bool resolveParameters(
45  Ogre::RTShader::ProgramSet *_programSet) override;
46 
48  public: static Ogre::String Type;
49  };
50 
54  public Ogre::RTShader::SubRenderStateFactory
55  {
56  // Documentation inherited.
57  public: virtual const Ogre::String &getType() const override;
58 
59  // Documentation inherited.
60  public: virtual Ogre::RTShader::SubRenderState *createInstance(
61  Ogre::ScriptCompiler *_compiler,
62  Ogre::PropertyAbstractNode *_prop,
63  Ogre::Pass *_pass,
64  Ogre::RTShader::SGScriptTranslator *_translator) override;
65 
66  // Documentation inherited
67  protected: virtual Ogre::RTShader::SubRenderState *createInstanceImpl()
68  override;
69  };
70 
90  : public Ogre::PSSMShadowCameraSetup
91  {
94 
96  public: ~CustomPSSMShadowCameraSetup();
97 
100  void calculateShadowMappingMatrix(const Ogre::SceneManager &_sm,
101  const Ogre::Camera &_cam, const Ogre::Light &_light,
102  Ogre::Matrix4 *_out_view, Ogre::Matrix4 *_outProj,
103  Ogre::Camera *_outCam) const;
104 
108  public: Ogre::Matrix4 buildViewMatrix(const Ogre::Vector3 &_pos,
109  const Ogre::Vector3 &_dir, const Ogre::Vector3 & _up) const;
110 
114  public: virtual void getZUpFocusedShadowCamera(
115  const Ogre::SceneManager *_sm, const Ogre::Camera *_cam,
116  const Ogre::Viewport *_vp, const Ogre::Light *_light,
117  Ogre::Camera *_texCam, size_t _iteration) const;
118 
121  public: virtual void getShadowCamera(const Ogre::SceneManager *_sm,
122  const Ogre::Camera *_cam, const Ogre::Viewport *_vp,
123  const Ogre::Light *_light, Ogre::Camera *_texCam, size_t _iteration)
124  const override;
125  };
126 
131  public Ogre::RTShader::GLSLProgramWriter
132  {
134  public: CustomGLSLProgramWriter();
135 
137  public: ~CustomGLSLProgramWriter() = default;
138  };
139 
142  public Ogre::RTShader::ProgramWriterFactory
143  {
146 
148  public: ~CustomGLSLProgramWriterFactory() = default;
149 
152  public: const Ogre::String &getTargetLanguage() const override;
153 
156  public: virtual Ogre::RTShader::ProgramWriter* create() override;
157  };
158  }
159 }
160 
161 #endif
Custom PSSM shadow receiver that overrides one deficient method in IntegratedPSSM3.
Definition: CustomPSSMShadowCameraSetup.hh:31
CustomPSSM3()
Constructor.
Definition: CustomPSSMShadowCameraSetup.hh:34
Forward declarations for the common classes.
Definition: Animation.hh:26
This overrides ogre&#39;s default GLSLProgramWriter to fix a bug in ogre versions <= 1.8 where &#39;sampler2DShadow&#39; sampler type is missing.
Definition: CustomPSSMShadowCameraSetup.hh:130
A factory that enables creation of CustomPSSM3 instances.
Definition: CustomPSSMShadowCameraSetup.hh:53
static Ogre::String Type
Type of sub render state.
Definition: CustomPSSMShadowCameraSetup.hh:48
Parallel Split Shadow Map (PSSM) shadow camera setup.
Definition: CustomPSSMShadowCameraSetup.hh:89
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:59
A factory to create our own CustomGLSLProgramWriter.
Definition: CustomPSSMShadowCameraSetup.hh:141