OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OgreShaderFFPTexturing.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-2011 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 _ShaderFFPTextureStage_
28 #define _ShaderFFPTextureStage_
29 
31 #ifdef RTSHADER_SYSTEM_BUILD_CORE_SHADERS
33 #include "OgreShaderParameter.h"
34 #include "OgreRenderSystem.h"
35 
36 namespace Ogre {
37 namespace RTShader {
38 
39 
54 class _OgreRTSSExport FFPTexturing : public SubRenderState
55 {
56 
57 // Interface.
58 public:
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 (RenderState* renderState, Pass* srcPass, Pass* dstPass);
87 
88  static String Type;
89 
90 // Protected types:
91 protected:
92 
93  // Per texture unit parameters.
94  struct _OgreRTSSExport TextureUnitParams
95  {
96  TextureUnitState* mTextureUnitState; // Texture unit state.
97  const Frustum* mTextureProjector; // Texture projector.
98  unsigned short mTextureSamplerIndex; // Texture sampler index.
99  GpuConstantType mTextureSamplerType; // Texture sampler index.
100  GpuConstantType mVSInTextureCoordinateType; // Vertex shader input texture coordinate type.
101  GpuConstantType mVSOutTextureCoordinateType; // Vertex shader output texture coordinates type.
102  TexCoordCalcMethod mTexCoordCalcMethod; // Texture coordinates calculation method.
103  UniformParameterPtr mTextureMatrix; // Texture matrix parameter.
104  UniformParameterPtr mTextureViewProjImageMatrix; // Texture View Projection Image space matrix parameter.
105  UniformParameterPtr mTextureSampler; // Texture sampler parameter.
106  ParameterPtr mVSInputTexCoord; // Vertex shader input texture coordinates parameter.
107  ParameterPtr mVSOutputTexCoord; // Vertex shader output texture coordinates parameter.
108  ParameterPtr mPSInputTexCoord; // Pixel shader input texture coordinates parameter.
109  };
110 
111  typedef vector<TextureUnitParams>::type TextureUnitParamsList;
112  typedef TextureUnitParamsList::iterator TextureUnitParamsIterator;
113  typedef TextureUnitParamsList::const_iterator TextureUnitParamsConstIterator;
114 
115 // Protected methods
116 protected:
117 
122  void setTextureUnitCount (size_t count);
123 
127  size_t getTextureUnitCount () const { return mTextureUnitParamsList.size(); }
128 
134  void setTextureUnit (unsigned short index, TextureUnitState* textureUnitState);
135 
139  virtual bool resolveParameters (ProgramSet* programSet);
140 
144  bool resolveUniformParams (TextureUnitParams* textureUnitParams, ProgramSet* programSet);
145 
149  bool resolveFunctionsParams (TextureUnitParams* textureUnitParams, ProgramSet* programSet);
150 
154  virtual bool resolveDependencies (ProgramSet* programSet);
155 
159  virtual bool addFunctionInvocations (ProgramSet* programSet);
160 
161 
165  bool addVSFunctionInvocations(TextureUnitParams* textureUnitParams, Function* vsMain);
166 
170  bool addPSFunctionInvocations(TextureUnitParams* textureUnitParams, Function* psMain, int& internalCounter);
171 
172  void addPSArgumentInvocations(Function* psMain,
173  ParameterPtr arg,
174  ParameterPtr texel,
175  int samplerIndex,
176  LayerBlendSource blendSrc,
177  const ColourValue& colourValue,
178  Real alphaValue,
179  bool isAlphaArgument,
180  const int groupOrder,
181  int& internalCounter);
182 
183  void addPSBlendInvocations(Function* psMain,
184  ParameterPtr arg1,
185  ParameterPtr arg2,
186  ParameterPtr texel,
187  int samplerIndex,
188  const LayerBlendModeEx& blendMode,
189  const int groupOrder,
190  int& internalCounter,
191  int targetChannels);
192 
196  TexCoordCalcMethod getTexCalcMethod (TextureUnitState* textureUnitState);
197 
201  bool needsTextureMatrix (TextureUnitState* textureUnitState);
202 
203 // Attributes.
204 protected:
205  TextureUnitParamsList mTextureUnitParamsList; // Texture units list.
206  UniformParameterPtr mWorldMatrix; // World matrix parameter.
207  UniformParameterPtr mWorldITMatrix; // World inverse transpose matrix parameter.
208  UniformParameterPtr mViewMatrix; // View matrix parameter.
209  ParameterPtr mVSInputNormal; // Vertex shader input normal parameter.
210  ParameterPtr mVSInputPos; // Vertex shader input position parameter.
211  ParameterPtr mPSOutDiffuse; // Pixel shader output colour.
212  ParameterPtr mPSDiffuse; // Pixel shader diffuse colour.
213  ParameterPtr mPSSpecular; // Pixel shader specular colour.
214 };
215 
216 
221 class _OgreRTSSExport FFPTexturingFactory : public SubRenderStateFactory
222 {
223 public:
224 
228  virtual const String& getType () const;
229 
233  virtual SubRenderState* createInstance (ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass);
234 
238  virtual void writeInstance (MaterialSerializer* ser, SubRenderState* subRenderState, Pass* srcPass, Pass* dstPass);
239 
240 
241 protected:
242 
246  virtual SubRenderState* createInstanceImpl ();
247 
248 
249 };
250 
255 }
256 }
257 
258 #endif
259 #endif
260 
float Real
Software floating point type.
HashedVector< Light * > LightList
Definition: OgreCommon.h:515
TexCoordCalcMethod
Enum describing the ways to generate texture coordinates.
SharedPtr< Parameter > ParameterPtr
#define _OgreRTSSExport
GpuConstantType
Enumeration of the types of constant we may encounter in programs.
LayerBlendSource
List of valid sources of values for blending operations used in TextureUnitState::setColourOperation ...
_StringBase String
SharedPtr< UniformParameter > UniformParameterPtr