OgreShaderFFPTexturing.h
Go to the documentation of this file.

    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         // Texture unit state.
    00097         TextureUnitState* mTextureUnitState;
    00098         // Texture projector.
    00099         const Frustum* mTextureProjector;
    00100         // Texture sampler index.
    00101         unsigned short mTextureSamplerIndex;
    00102         // Texture sampler index.
    00103         GpuConstantType mTextureSamplerType;
    00104         // Vertex shader input texture coordinate type.
    00105         GpuConstantType mVSInTextureCoordinateType;
    00106         // Vertex shader output texture coordinates type.
    00107         GpuConstantType mVSOutTextureCoordinateType;
    00108         // Texture coordinates calculation method.
    00109         TexCoordCalcMethod mTexCoordCalcMethod;
    00110         // Texture matrix parameter.
    00111         UniformParameterPtr mTextureMatrix;
    00112         // Texture View Projection Image space matrix parameter.
    00113         UniformParameterPtr mTextureViewProjImageMatrix;
    00114         // Texture sampler parameter.
    00115         UniformParameterPtr mTextureSampler;
    00116         // Vertex shader input texture coordinates parameter.
    00117         ParameterPtr mVSInputTexCoord;
    00118         // Vertex shader output texture coordinates parameter.
    00119         ParameterPtr mVSOutputTexCoord;
    00120         // Pixel shader input texture coordinates parameter.
    00121         ParameterPtr mPSInputTexCoord;
    00122     };
    00123
    00124     typedef vector<TextureUnitParams>::type         TextureUnitParamsList;
    00125     typedef TextureUnitParamsList::iterator         TextureUnitParamsIterator;
    00126     typedef TextureUnitParamsList::const_iterator   TextureUnitParamsConstIterator;
    00127
    00128 // Protected methods
    00129 protected:
    00130
    00135     void setTextureUnitCount(size_t count);
    00136
    00140     size_t getTextureUnitCount() const { return mTextureUnitParamsList.size(); }
    00141
    00147     void setTextureUnit(unsigned short index, TextureUnitState* textureUnitState);
    00148
    00152     virtual bool resolveParameters(ProgramSet* programSet);
    00153
    00157     bool resolveUniformParams(TextureUnitParams* textureUnitParams, ProgramSet* programSet);
    00158
    00162     bool resolveFunctionsParams(TextureUnitParams* textureUnitParams, ProgramSet* programSet);
    00163
    00167     virtual bool resolveDependencies(ProgramSet* programSet);
    00168
    00172     virtual bool addFunctionInvocations(ProgramSet* programSet);
    00173
    00174
    00178     bool addVSFunctionInvocations(TextureUnitParams* textureUnitParams, Function* vsMain);
    00179
    00183     bool addPSFunctionInvocations(TextureUnitParams* textureUnitParams, Function* psMain, int& internalCounter);
    00184
    00188     virtual void addPSSampleTexelInvocation(TextureUnitParams* textureUnitParams, Function* psMain,
    00189         const ParameterPtr& texel, int groupOrder, int& internalCounter);
    00190
    00191     virtual void addPSArgumentInvocations(Function* psMain, ParameterPtr arg, ParameterPtr texel,
    00192                 int samplerIndex, LayerBlendSource blendSrc, const ColourValue& colourValue, Real alphaValue,
    00193                  bool isAlphaArgument, const int groupOrder, int& internalCounter);
    00194
    00195     virtual void addPSBlendInvocations(Function* psMain, ParameterPtr arg1, ParameterPtr arg2,
    00196                 ParameterPtr texel,int samplerIndex, const LayerBlendModeEx& blendMode,
    00197                 const int groupOrder, int& internalCounter, 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     // Texture units list.
    00218     TextureUnitParamsList mTextureUnitParamsList;
    00219     // World matrix parameter.
    00220     UniformParameterPtr mWorldMatrix;
    00221     // World inverse transpose matrix parameter.
    00222     UniformParameterPtr mWorldITMatrix;
    00223     // View matrix parameter.
    00224     UniformParameterPtr mViewMatrix;
    00225     // Vertex shader input normal parameter.
    00226     ParameterPtr mVSInputNormal;
    00227     // Vertex shader input position parameter.
    00228     ParameterPtr mVSInputPos;
    00229     // Pixel shader output colour.
    00230     ParameterPtr mPSOutDiffuse;
    00231     // Pixel shader diffuse colour.
    00232     ParameterPtr mPSDiffuse;
    00233     // Pixel shader specular colour.
    00234     ParameterPtr mPSSpecular;
    00235 };
    00236
    00237
    00242 class _OgreRTSSExport FFPTexturingFactory : public SubRenderStateFactory
    00243 {
    00244 public:
    00245
    00249     virtual const String& getType() const;
    00250
    00254     virtual SubRenderState* createInstance(ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass, SGScriptTranslator* translator);
    00255
    00259     virtual void writeInstance(MaterialSerializer* ser, SubRenderState* subRenderState, Pass* srcPass, Pass* dstPass);
    00260
    00261
    00262 protected:
    00263
    00267     virtual SubRenderState* createInstanceImpl();
    00268
    00269
    00270 };
    00271
    00276 }
    00277 }
    00278
    00279 #endif
    00280 #endif
    00281

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun Sep 2 2012 07:27:23