OGRE  1.9.0
OgreShaderFFPFog.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in
16all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24THE 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
36namespace Ogre {
37namespace RTShader {
38
45
50class _OgreRTSSExport FFPFog : public SubRenderState
51{
52public:
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.
62public:
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
121protected:
122
126 virtual bool resolveParameters(ProgramSet* programSet);
127
131 virtual bool resolveDependencies(ProgramSet* programSet);
132
136 virtual bool addFunctionInvocations(ProgramSet* programSet);
137
138// Attributes.
139protected:
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
176class _OgreRTSSExport FFPFogFactory : public SubRenderStateFactory
177{
178public:
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
196protected:
197
201 virtual SubRenderState* createInstanceImpl();
202
203
204};
205
208
209}
210}
211
212#endif
213#endif
214
#define _OgreRTSSExport
Abstract factory interface for creating SubRenderState implementation instances.
This class is the base interface of sub part from a shader based rendering pipeline.
FogMode
Fog modes.
Definition OgreCommon.h:122
SharedPtr< Parameter > ParameterPtr
SharedPtr< UniformParameter > UniformParameterPtr
_StringBase String