OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreShaderFFPFog.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14 
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE.
25 -----------------------------------------------------------------------------
26 */
27 #ifndef _ShaderFFPFog_
28 #define _ShaderFFPFog_
29 
31 #ifdef RTSHADER_SYSTEM_BUILD_CORE_SHADERS
32 #include "OgreShaderParameter.h"
34 #include "OgreVector4.h"
35 
36 namespace Ogre {
37 namespace RTShader {
38 
50 class _OgreRTSSExport FFPFog : public SubRenderState
51 {
52 public:
53 
54  // Fog calculation mode enum.
55  enum CalcMode
56  {
57  CM_PER_VERTEX = 1, // Per vertex fog calculations. (Default).
58  CM_PER_PIXEL = 2 // Per pixel fog calculations.
59  };
60 
61 // Interface.
62 public:
63 
65  FFPFog();
66 
70  virtual const String& getType() const;
71 
75  virtual int getExecutionOrder() const;
76 
80  virtual void updateGpuProgramsParams(Renderable* rend, Pass* pass, const AutoParamDataSource* source, const LightList* pLightList);
81 
85  virtual void copyFrom(const SubRenderState& rhs);
86 
90  virtual bool preAddToRenderState(const RenderState* renderState, Pass* srcPass, Pass* dstPass);
91 
101  void setFogProperties(FogMode fogMode,
102  const ColourValue& fogColour,
103  float fogStart,
104  float fogEnd,
105  float fogDensity);
106 
111  void setCalcMode(CalcMode calcMode) { mCalcMode = calcMode; }
112 
116  CalcMode getCalcMode() const { return mCalcMode; }
117 
118  static String Type;
119 
120 // Protected methods
121 protected:
122 
126  virtual bool resolveParameters(ProgramSet* programSet);
127 
131  virtual bool resolveDependencies(ProgramSet* programSet);
132 
136  virtual bool addFunctionInvocations(ProgramSet* programSet);
137 
138 // Attributes.
139 protected:
140  // Fog calculation mode.
141  CalcMode mCalcMode;
142  // Fog formula.
143  FogMode mFogMode;
144  // Fog colour value.
145  ColourValue mFogColourValue;
146  // Fog parameters (density, start, end, 1/end-start).
147  Vector4 mFogParamsValue;
148  // True if the fog parameters should be taken from the pass.
149  bool mPassOverrideParams;
150 
151  // World view projection parameter.
152  UniformParameterPtr mWorldViewProjMatrix;
153  // Fog colour parameter.
154  UniformParameterPtr mFogColour;
155  // Fog parameters program parameter.
156  UniformParameterPtr mFogParams;
157  // Vertex shader input position parameter.
158  ParameterPtr mVSInPos;
159  // Vertex shader output fog colour parameter.
160  ParameterPtr mVSOutFogFactor;
161  // Pixel shader input fog factor.
162  ParameterPtr mPSInFogFactor;
163  // Vertex shader output depth.
164  ParameterPtr mVSOutDepth;
165  // Pixel shader input depth.
166  ParameterPtr mPSInDepth;
167  // Pixel shader output diffuse colour.
168  ParameterPtr mPSOutDiffuse;
169 };
170 
171 
176 class _OgreRTSSExport FFPFogFactory : public SubRenderStateFactory
177 {
178 public:
179 
183  virtual const String& getType() const;
184 
188  virtual SubRenderState* createInstance(ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass, SGScriptTranslator* translator);
189 
193  virtual void writeInstance(MaterialSerializer* ser, SubRenderState* subRenderState, Pass* srcPass, Pass* dstPass);
194 
195 
196 protected:
197 
201  virtual SubRenderState* createInstanceImpl();
202 
203 
204 };
205 
209 }
210 }
211 
212 #endif
213 #endif
214 
HashedVector< Light * > LightList
Definition: OgreCommon.h:541
FogMode
Fog modes.
Definition: OgreCommon.h:121
SharedPtr< Parameter > ParameterPtr
#define _OgreRTSSExport
_StringBase String
SharedPtr< UniformParameter > UniformParameterPtr