Ignition Rendering

API Reference

5.0.0
OgreMaterial.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 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 #ifndef IGNITION_RENDERING_OGRE_OGREMATERIAL_HH_
18 #define IGNITION_RENDERING_OGRE_OGREMATERIAL_HH_
19 
20 #include <string>
21 
23 
27 
28 namespace ignition
29 {
30  namespace rendering
31  {
32  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
33  // TODO(anyone): use a better way to find shader configurations
35  "depth_vertex_shader.glsl";
37  "depth_fragment_shader.glsl";
38 
39  class IGNITION_RENDERING_OGRE_VISIBLE OgreMaterial :
40  public BaseMaterial<OgreObject>
41  {
42  protected: OgreMaterial();
43 
44  public: virtual ~OgreMaterial();
45 
46  // Documentation inherited
47  public: virtual void Destroy() override;
48 
49  public: virtual bool LightingEnabled() const override;
50 
51  public: virtual void SetLightingEnabled(const bool _enabled) override;
52 
53  // Documentation inherited
54  public: virtual bool DepthCheckEnabled() const override;
55 
56  // Documentation inherited
57  public: virtual void SetDepthCheckEnabled(bool _enabled) override;
58 
59  // Documentation inherited
60  public: virtual bool DepthWriteEnabled() const override;
61 
62  // Documentation inherited
63  public: virtual void SetDepthWriteEnabled(bool _enabled) override;
64 
65  public: virtual math::Color Ambient() const override;
66 
67  public: virtual void SetAmbient(const math::Color &_color) override;
68 
69  public: virtual math::Color Diffuse() const override;
70 
71  public: virtual void SetDiffuse(const math::Color &_color) override;
72 
73  public: virtual math::Color Specular() const override;
74 
75  public: virtual void SetSpecular(const math::Color &_color) override;
76 
77  public: virtual math::Color Emissive() const override;
78 
79  public: virtual void SetEmissive(const math::Color &_color) override;
80 
81  public: virtual double Shininess() const override;
82 
83  public: virtual void SetShininess(const double _shininess) override;
84 
85  public: virtual double Transparency() const override;
86 
87  public: virtual void SetTransparency(const double _transparency)
88  override;
89 
90  // Documentation inherited
91  public: virtual void SetAlphaFromTexture(bool _enabled,
92  double _alpha = 0.5, bool _twoSided = true) override;
93 
94  public: virtual double Reflectivity() const override;
95 
96  public: virtual void SetReflectivity(const double _reflectivity)
97  override;
98 
99  public: virtual bool CastShadows() const override;
100 
101  public: virtual void SetCastShadows(const bool _castShadows) override;
102 
103  public: virtual bool ReceiveShadows() const override;
104 
105  public: virtual void SetReceiveShadows(const bool _receiveShadows)
106  override;
107 
108  // Documentation inherited
109  public: virtual float RenderOrder() const override;
110 
111  // Documentation inherited
112  // Review the official documentation to get more details about this
113  // parameter, in particular Ogre::Pass::setDepthBias()
114  // https://www.ogre3d.org/docs/api/1.8/class_ogre_1_1_pass.html
115  public: virtual void SetRenderOrder(const float _renderOrder) override;
116 
117  public: virtual bool ReflectionEnabled() const override;
118 
119  public: virtual void SetReflectionEnabled(const bool _enabled) override;
120 
121  public: virtual bool HasTexture() const override;
122 
123  public: virtual std::string Texture() const override;
124 
125  public: virtual void SetTexture(const std::string &_name) override;
126 
127  public: virtual void ClearTexture() override;
128 
129  public: virtual bool HasNormalMap() const override;
130 
131  public: virtual std::string NormalMap() const override;
132 
133  public: virtual void SetNormalMap(const std::string &_name) override;
134 
135  public: virtual void ClearNormalMap() override;
136 
137  public: virtual enum ShaderType ShaderType() const override;
138 
139  public: virtual void SetShaderType(enum ShaderType _type) override;
140 
141  public: virtual Ogre::MaterialPtr Material() const;
142 
143  // Documentation inherited.
144  // \sa Material::Set3DMaterial()
145  public: virtual void SetDepthMaterial(const double far,
146  const double near) override;
147 
148  // Documentation inherited.
149  // \sa Material::SetVertexShader(const std::string &)
150  public: virtual void SetVertexShader(const std::string &_path) override;
151 
152  // Documentation inherited.
153  // \sa Material::VertexShader() const
154  public: virtual std::string VertexShader() const override;
155 
156  // Documentation inherited.
157  // \sa Material::VertexShaderParams()
158  public: virtual ShaderParamsPtr VertexShaderParams() override;
159 
160  // Documentation inherited.
161  // \sa Material::SetFragmentShader(const std::string &)
162  public: virtual void SetFragmentShader(const std::string &_path)
163  override;
164 
165  // Documentation inherited.
166  // \sa Material::FragmentShader() const
167  public: virtual std::string FragmentShader() const override;
168 
169  // Documentation inherited.
170  // \sa Material::FragmentShaderParams()
171  public: virtual ShaderParamsPtr FragmentShaderParams() override;
172 
173  // Documentation inherited.
174  // \sa BaseMaterial::PreRender()
175  public: virtual void PreRender() override;
176 
177  protected: virtual void LoadOneImage(const std::string &_name,
178  Ogre::Image &_image);
179 
182  protected: virtual void SetTextureImpl(const std::string &_texture);
183 
184  protected: virtual Ogre::TexturePtr Texture(const std::string &_name);
185 
186  protected: virtual Ogre::TexturePtr CreateTexture(
187  const std::string &_name);
188 
189  protected: virtual void UpdateTransparency();
190 
191  protected: virtual void UpdateColorOperation();
192 
194  protected: void UpdateShaderParams();
195 
199  protected: void UpdateShaderParams(ConstShaderParamsPtr _params,
200  Ogre::GpuProgramParametersSharedPtr _ogreParams);
201 
202  protected: virtual void Init() override;
203 
205  protected: Ogre::MaterialPtr ogreMaterial;
206 
207  protected: Ogre::Technique *ogreTechnique = nullptr;
208 
209  protected: Ogre::Pass *ogrePass = nullptr;
210 
211  protected: Ogre::TextureUnitState *ogreTexState = nullptr;
212 
213  protected: Ogre::String ogreGroup;
214 
215 #if OGRE_VERSION_MAJOR == 1 && OGRE_VERSION_MINOR <= 7
216  protected: math::Color emissiveColor;
217 #endif
219 
221 
222  protected: enum ShaderType shaderType = ST_PIXEL;
223 
226 
229 
232 
236 
237  private: friend class OgreScene;
238  };
239  }
240  }
241 }
242 #endif
const std::string depth_fragment_shader_file
Definition: OgreMaterial.hh:36
const std::string depth_vertex_shader_file
Definition: OgreMaterial.hh:34
std::string vertexShaderPath
Path to vertex shader program.
Definition: OgreMaterial.hh:225
std::string fragmentShaderPath
Path to fragment shader program.
Definition: OgreMaterial.hh:228
ShaderParamsPtr vertexShaderParams
Parameters to be bound to the vertex shader.
Definition: OgreMaterial.hh:231
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
ShaderParamsPtr fragmentShaderParams
Parameters to be bound to the fragment shader.
Definition: OgreMaterial.hh:234
STL class.
Ogre::String ogreGroup
Definition: OgreMaterial.hh:213
std::string normalMapName
Definition: OgreMaterial.hh:220
Definition: OgreMaterial.hh:39
Definition: OgreScene.hh:39
std::string textureName
Definition: OgreMaterial.hh:218
ShaderType
Available types of shaders. Note that not all rendering-engines will be able to use each type...
Definition: ShaderType.hh:34
Definition: BaseMaterial.hh:38
Per pixel lighting shader.
Definition: ShaderType.hh:40
Ogre::MaterialPtr ogreMaterial
Definition: OgreMaterial.hh:205
Represents a surface material of a Geometry.
Definition: Material.hh:47
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING