RTShaderSystem.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 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_RTSHADERSYSTEM_HH_
19 #define _GAZEBO_RTSHADERSYSTEM_HH_
20 
21 #include <list>
22 #include <string>
23 
25 #include "gazebo/gazebo_config.h"
26 
29 #include "gazebo/util/system.hh"
30 
32 GZ_SINGLETON_DECLARE(GZ_RENDERING_VISIBLE, gazebo, rendering, RTShaderSystem)
33 
34 namespace gazebo
35 {
36  namespace rendering
37  {
38  class RTShaderSystemPrivate;
39 
42 
48  class GZ_RENDERING_VISIBLE RTShaderSystem :
49  public SingletonT<RTShaderSystem>
50  {
53  public: enum LightingModel
54  {
64  SSLM_NormalMapLightingObjectSpace
65  };
66 
68  private: RTShaderSystem();
69 
71  private: virtual ~RTShaderSystem();
72 
74  public: void Init();
75 
77  public: void Fini();
78 
81  public: void AddScene(ScenePtr _scene);
82 
85  public: void RemoveScene(ScenePtr _scene);
86 
89  public: void RemoveScene(const std::string &_scene);
90 
92  public: void UpdateShaders();
93 
95  public: void UpdateShadows();
96 
100  public: static void AttachViewport(Ogre::Viewport *_viewport,
101  ScenePtr _scene);
102 
106  public: static void DetachViewport(Ogre::Viewport *_viewport,
107  ScenePtr _scene);
108 
111  public: void SetPerPixelLighting(bool _set);
112 
115  public: void GenerateShaders(const VisualPtr &_vis);
116 
119  public: void ApplyShadows(ScenePtr _scene);
120 
123  public: void RemoveShadows(ScenePtr _scene);
124 
127  public: Ogre::PSSMShadowCameraSetup *GetPSSMShadowCameraSetup() const;
128 
130  public: void Update();
131 
136  public: bool SetShadowTextureSize(const unsigned int _size);
137 
140  public: unsigned int ShadowTextureSize() const;
141 
145  public: void SetShadowClipDist(const double _near, const double _far);
146 
149  public: double ShadowNearClip() const;
150 
153  public: double ShadowFarClip() const;
154 
158  public: void SetShadowSplitLambda(const double _lambda);
159 
162  public: double ShadowSplitLambda() const;
163 
166  public: void SetShadowSplitPadding(const double _padding);
167 
170  public: double ShadowSplitPadding() const;
171 
176  private: bool GetPaths(std::string &_coreLibsPath,
177  std::string &_cachePath);
178 
181  private: void UpdateShaders(VisualPtr _vis);
182 
185  private: void UpdateShadows(ScenePtr _scene);
186 
188  private: void ReapplyShadows();
189 
191  private: friend class SingletonT<RTShaderSystem>;
192 
195  private: RTShaderSystemPrivate *dataPtr;
196  };
198  }
199 }
200 #endif
rendering
Definition: RTShaderSystem.hh:32
Singleton template class.
Definition: SingletonT.hh:34
Implements Ogre's Run-Time Shader system.
Definition: RTShaderSystem.hh:50
void Fini()
Finalize the shader system.
void AddScene(ScenePtr _scene)
Add a scene manager.
static void AttachViewport(Ogre::Viewport *_viewport, ScenePtr _scene)
Set a viewport to use shaders.
void SetShadowSplitPadding(const double _padding)
Set the overlap between PSSM shadow maps.
void GenerateShaders(const VisualPtr &_vis)
Generate shaders for an entity.
void RemoveScene(ScenePtr _scene)
Remove a scene.
void Init()
Init the run time shader system.
void SetShadowSplitLambda(const double _lambda)
Set the PSSM lambda value for determining how linear or logarithmic choice of split points will be.
unsigned int ShadowTextureSize() const
Get the shadow texture size.
LightingModel
Definition: RTShaderSystem.hh:54
@ SSLM_PerPixelLighting
Per-Pixel lighting: best look.
Definition: RTShaderSystem.hh:58
@ SSLM_NormalMapLightingTangentSpace
Normal Map lighting: lighting calculations have been stored in a light map (texture) using tangent sp...
Definition: RTShaderSystem.hh:61
@ SSLM_PerVertexLighting
Per-Vertex lighting: best performance.
Definition: RTShaderSystem.hh:56
void UpdateShaders()
Queue a call to update the shaders.
bool SetShadowTextureSize(const unsigned int _size)
Set the shadow texture size.
void SetPerPixelLighting(bool _set)
Set the lighting model to per pixel or per vertex.
double ShadowNearClip() const
Get the shadow near clip distance.
void RemoveShadows(ScenePtr _scene)
Remove shadows from a scene.
void RemoveScene(const std::string &_scene)
Remove a scene.
double ShadowSplitPadding() const
Get the PSSM split point overlap.
void ApplyShadows(ScenePtr _scene)
Apply shadows to a scene.
double ShadowFarClip() const
Get the shadow far clip distance.
void SetShadowClipDist(const double _near, const double _far)
Set the shadow clip distances.
Ogre::PSSMShadowCameraSetup * GetPSSMShadowCameraSetup() const
Get the Ogre PSSM Shadows camera setup.
double ShadowSplitLambda() const
Get the PSSM split point lambda value.
void Update()
Update the RT shaders. This should not be called frequently.
static void DetachViewport(Ogre::Viewport *_viewport, ScenePtr _scene)
Set a viewport to not use shaders.
void UpdateShadows()
Queue a call to update the shadows.
#define GZ_SINGLETON_DECLARE(visibility, n1, n2, singletonType)
Helper to declare typed SingletonT.
Definition: SingletonT.hh:61
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:114
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:82
Forward declarations for the common classes.
Definition: Animation.hh:27