OGRE  1.9.0
OgreShaderFFPTexturing.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 _ShaderFFPTextureStage_
28#define _ShaderFFPTextureStage_
29
31#ifdef RTSHADER_SYSTEM_BUILD_CORE_SHADERS
33#include "OgreShaderParameter.h"
34#include "OgreRenderSystem.h"
35
36namespace Ogre {
37namespace RTShader {
38
39
54class _OgreRTSSExport FFPTexturing : public SubRenderState
55{
56
57// Interface.
58public:
59
61 FFPTexturing();
62
66 virtual const String& getType() const;
67
71 virtual int getExecutionOrder() const;
72
76 virtual void updateGpuProgramsParams(Renderable* rend, Pass* pass, const AutoParamDataSource* source, const LightList* pLightList);
77
81 virtual void copyFrom(const SubRenderState& rhs);
82
86 virtual bool preAddToRenderState(const RenderState* renderState, Pass* srcPass, Pass* dstPass);
87
88 static String Type;
89
90// Protected types:
91protected:
92
93 // Per texture unit parameters.
94 struct _OgreRTSSExport TextureUnitParams
95 {
96 // Texture unit state.
97 TextureUnitState* mTextureUnitState;
98 // Texture projector.
99 const Frustum* mTextureProjector;
100 // Texture sampler index.
101 unsigned short mTextureSamplerIndex;
102 // Texture sampler index.
103 GpuConstantType mTextureSamplerType;
104 // Vertex shader input texture coordinate type.
105 GpuConstantType mVSInTextureCoordinateType;
106 // Vertex shader output texture coordinates type.
107 GpuConstantType mVSOutTextureCoordinateType;
108 // Texture coordinates calculation method.
109 TexCoordCalcMethod mTexCoordCalcMethod;
110 // Texture matrix parameter.
111 UniformParameterPtr mTextureMatrix;
112 // Texture View Projection Image space matrix parameter.
113 UniformParameterPtr mTextureViewProjImageMatrix;
114 // Texture sampler parameter.
115 UniformParameterPtr mTextureSampler;
116 // Vertex shader input texture coordinates parameter.
117 ParameterPtr mVSInputTexCoord;
118 // Vertex shader output texture coordinates parameter.
119 ParameterPtr mVSOutputTexCoord;
120 // Pixel shader input texture coordinates parameter.
121 ParameterPtr mPSInputTexCoord;
122 };
123
124 typedef vector<TextureUnitParams>::type TextureUnitParamsList;
125 typedef TextureUnitParamsList::iterator TextureUnitParamsIterator;
126 typedef TextureUnitParamsList::const_iterator TextureUnitParamsConstIterator;
127
128// Protected methods
129protected:
130
135 void setTextureUnitCount(size_t count);
136
140 size_t getTextureUnitCount() const { return mTextureUnitParamsList.size(); }
141
147 void setTextureUnit(unsigned short index, TextureUnitState* textureUnitState);
148
152 virtual bool resolveParameters(ProgramSet* programSet);
153
157 bool resolveUniformParams(TextureUnitParams* textureUnitParams, ProgramSet* programSet);
158
162 bool resolveFunctionsParams(TextureUnitParams* textureUnitParams, ProgramSet* programSet);
163
167 virtual bool resolveDependencies(ProgramSet* programSet);
168
172 virtual bool addFunctionInvocations(ProgramSet* programSet);
173
174
178 bool addVSFunctionInvocations(TextureUnitParams* textureUnitParams, Function* vsMain);
179
183 bool addPSFunctionInvocations(TextureUnitParams* textureUnitParams, Function* psMain, int& internalCounter);
184
188 virtual void addPSSampleTexelInvocation(TextureUnitParams* textureUnitParams, Function* psMain,
189 const ParameterPtr& texel, int groupOrder, int& internalCounter);
190
191 virtual void addPSArgumentInvocations(Function* psMain, ParameterPtr arg, ParameterPtr texel,
192 int samplerIndex, LayerBlendSource blendSrc, const ColourValue& colourValue, Real alphaValue,
193 bool isAlphaArgument, const int groupOrder, int& internalCounter);
194
195 virtual void addPSBlendInvocations(Function* psMain, ParameterPtr arg1, ParameterPtr arg2,
196 ParameterPtr texel,int samplerIndex, const LayerBlendModeEx& blendMode,
197 const int groupOrder, int& internalCounter, int targetChannels);
198
202 TexCoordCalcMethod getTexCalcMethod(TextureUnitState* textureUnitState);
203
207 bool needsTextureMatrix(TextureUnitState* textureUnitState);
208
212 virtual bool isProcessingNeeded(TextureUnitState* texUnitState);
213
214
215// Attributes.
216protected:
217 // Texture units list.
218 TextureUnitParamsList mTextureUnitParamsList;
219 // World matrix parameter.
220 UniformParameterPtr mWorldMatrix;
221 // World inverse transpose matrix parameter.
222 UniformParameterPtr mWorldITMatrix;
223 // View matrix parameter.
224 UniformParameterPtr mViewMatrix;
225 // Vertex shader input normal parameter.
226 ParameterPtr mVSInputNormal;
227 // Vertex shader input position parameter.
228 ParameterPtr mVSInputPos;
229 // Pixel shader output colour.
230 ParameterPtr mPSOutDiffuse;
231 // Pixel shader diffuse colour.
232 ParameterPtr mPSDiffuse;
233 // Pixel shader specular colour.
234 ParameterPtr mPSSpecular;
235};
236
237
242class _OgreRTSSExport FFPTexturingFactory : public SubRenderStateFactory
243{
244public:
245
249 virtual const String& getType() const;
250
254 virtual SubRenderState* createInstance(ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass, SGScriptTranslator* translator);
255
259 virtual void writeInstance(MaterialSerializer* ser, SubRenderState* subRenderState, Pass* srcPass, Pass* dstPass);
260
261
262protected:
263
267 virtual SubRenderState* createInstanceImpl();
268
269
270};
271
276}
277}
278
279#endif
280#endif
281
#define _OgreRTSSExport
GpuConstantType
Enumeration of the types of constant we may encounter in programs.
SharedPtr< Parameter > ParameterPtr
SharedPtr< UniformParameter > UniformParameterPtr
TexCoordCalcMethod
Enum describing the ways to generate texture coordinates.
_StringBase String