00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org 00006 00007 Copyright (c) 2000-2012 Torus Knot Software Ltd 00008 Permission is hereby granted, free of charge, to any person obtaining a copy 00009 of this software and associated documentation files (the "Software"), to deal 00010 in the Software without restriction, including without limitation the rights 00011 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00012 copies of the Software, and to permit persons to whom the Software is 00013 furnished to do so, subject to the following conditions: 00014 00015 The above copyright notice and this permission notice shall be included in 00016 all copies or substantial portions of the Software. 00017 00018 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00019 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00020 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00021 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00022 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00023 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00024 THE SOFTWARE. 00025 ----------------------------------------------------------------------------- 00026 */ 00027 #ifndef _ShaderFFPTextureStage_ 00028 #define _ShaderFFPTextureStage_ 00029 00030 #include "OgreShaderPrerequisites.h" 00031 #ifdef RTSHADER_SYSTEM_BUILD_CORE_SHADERS 00032 #include "OgreShaderSubRenderState.h" 00033 #include "OgreShaderParameter.h" 00034 #include "OgreRenderSystem.h" 00035 00036 namespace Ogre { 00037 namespace RTShader { 00038 00039 00054 class _OgreRTSSExport FFPTexturing : public SubRenderState 00055 { 00056 00057 // Interface. 00058 public: 00059 00061 FFPTexturing(); 00062 00066 virtual const String& getType () const; 00067 00071 virtual int getExecutionOrder () const; 00072 00076 virtual void updateGpuProgramsParams (Renderable* rend, Pass* pass, const AutoParamDataSource* source, const LightList* pLightList); 00077 00081 virtual void copyFrom (const SubRenderState& rhs); 00082 00086 virtual bool preAddToRenderState (const RenderState* renderState, Pass* srcPass, Pass* dstPass); 00087 00088 static String Type; 00089 00090 // Protected types: 00091 protected: 00092 00093 // Per texture unit parameters. 00094 struct _OgreRTSSExport TextureUnitParams 00095 { 00096 TextureUnitState* mTextureUnitState; // Texture unit state. 00097 const Frustum* mTextureProjector; // Texture projector. 00098 unsigned short mTextureSamplerIndex; // Texture sampler index. 00099 GpuConstantType mTextureSamplerType; // Texture sampler index. 00100 GpuConstantType mVSInTextureCoordinateType; // Vertex shader input texture coordinate type. 00101 GpuConstantType mVSOutTextureCoordinateType; // Vertex shader output texture coordinates type. 00102 TexCoordCalcMethod mTexCoordCalcMethod; // Texture coordinates calculation method. 00103 UniformParameterPtr mTextureMatrix; // Texture matrix parameter. 00104 UniformParameterPtr mTextureViewProjImageMatrix; // Texture View Projection Image space matrix parameter. 00105 UniformParameterPtr mTextureSampler; // Texture sampler parameter. 00106 ParameterPtr mVSInputTexCoord; // Vertex shader input texture coordinates parameter. 00107 ParameterPtr mVSOutputTexCoord; // Vertex shader output texture coordinates parameter. 00108 ParameterPtr mPSInputTexCoord; // Pixel shader input texture coordinates parameter. 00109 }; 00110 00111 typedef vector<TextureUnitParams>::type TextureUnitParamsList; 00112 typedef TextureUnitParamsList::iterator TextureUnitParamsIterator; 00113 typedef TextureUnitParamsList::const_iterator TextureUnitParamsConstIterator; 00114 00115 // Protected methods 00116 protected: 00117 00122 void setTextureUnitCount (size_t count); 00123 00127 size_t getTextureUnitCount () const { return mTextureUnitParamsList.size(); } 00128 00134 void setTextureUnit (unsigned short index, TextureUnitState* textureUnitState); 00135 00139 virtual bool resolveParameters (ProgramSet* programSet); 00140 00144 bool resolveUniformParams (TextureUnitParams* textureUnitParams, ProgramSet* programSet); 00145 00149 bool resolveFunctionsParams (TextureUnitParams* textureUnitParams, ProgramSet* programSet); 00150 00154 virtual bool resolveDependencies (ProgramSet* programSet); 00155 00159 virtual bool addFunctionInvocations (ProgramSet* programSet); 00160 00161 00165 bool addVSFunctionInvocations(TextureUnitParams* textureUnitParams, Function* vsMain); 00166 00170 bool addPSFunctionInvocations(TextureUnitParams* textureUnitParams, Function* psMain, int& internalCounter); 00171 00175 virtual void addPSSampleTexelInvocation(TextureUnitParams* textureUnitParams, Function* psMain, 00176 const ParameterPtr& texel, int groupOrder, int& internalCounter); 00177 00178 virtual void addPSArgumentInvocations(Function* psMain, 00179 ParameterPtr arg, 00180 ParameterPtr texel, 00181 int samplerIndex, 00182 LayerBlendSource blendSrc, 00183 const ColourValue& colourValue, 00184 Real alphaValue, 00185 bool isAlphaArgument, 00186 const int groupOrder, 00187 int& internalCounter); 00188 00189 virtual void addPSBlendInvocations(Function* psMain, 00190 ParameterPtr arg1, 00191 ParameterPtr arg2, 00192 ParameterPtr texel, 00193 int samplerIndex, 00194 const LayerBlendModeEx& blendMode, 00195 const int groupOrder, 00196 int& internalCounter, 00197 int targetChannels); 00198 00202 TexCoordCalcMethod getTexCalcMethod (TextureUnitState* textureUnitState); 00203 00207 bool needsTextureMatrix (TextureUnitState* textureUnitState); 00208 00212 virtual bool isProcessingNeeded(TextureUnitState* texUnitState); 00213 00214 00215 // Attributes. 00216 protected: 00217 TextureUnitParamsList mTextureUnitParamsList; // Texture units list. 00218 UniformParameterPtr mWorldMatrix; // World matrix parameter. 00219 UniformParameterPtr mWorldITMatrix; // World inverse transpose matrix parameter. 00220 UniformParameterPtr mViewMatrix; // View matrix parameter. 00221 ParameterPtr mVSInputNormal; // Vertex shader input normal parameter. 00222 ParameterPtr mVSInputPos; // Vertex shader input position parameter. 00223 ParameterPtr mPSOutDiffuse; // Pixel shader output colour. 00224 ParameterPtr mPSDiffuse; // Pixel shader diffuse colour. 00225 ParameterPtr mPSSpecular; // Pixel shader specular colour. 00226 }; 00227 00228 00233 class _OgreRTSSExport FFPTexturingFactory : public SubRenderStateFactory 00234 { 00235 public: 00236 00240 virtual const String& getType () const; 00241 00245 virtual SubRenderState* createInstance (ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass, SGScriptTranslator* translator); 00246 00250 virtual void writeInstance (MaterialSerializer* ser, SubRenderState* subRenderState, Pass* srcPass, Pass* dstPass); 00251 00252 00253 protected: 00254 00258 virtual SubRenderState* createInstanceImpl (); 00259 00260 00261 }; 00262 00267 } 00268 } 00269 00270 #endif 00271 #endif 00272
Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Fri May 25 23:36:26 2012