OGRE: OgreShaderFFPTexturing.h Source File - OGRE Documentation

# 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-2009 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     (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
    00172     void                    addPSArgumentInvocations(Function* psMain,
    00173                                                      ParameterPtr arg,
    00174                                                      ParameterPtr texel,
    00175                                                      int samplerIndex,
    00176                                                      LayerBlendSource blendSrc,
    00177                                                      const ColourValue& colourValue,
    00178                                                      Real alphaValue,
    00179                                                      bool isAlphaArgument,
    00180                                                      const int groupOrder,
    00181                                                      int& internalCounter);
    00182
    00183     void                    addPSBlendInvocations(Function* psMain,
    00184                                                 ParameterPtr arg1,
    00185                                                 ParameterPtr arg2,
    00186                                                 ParameterPtr texel,
    00187                                                 int samplerIndex,
    00188                                                 const LayerBlendModeEx& blendMode,
    00189                                                 const int groupOrder,
    00190                                                 int& internalCounter,
    00191                                                 int targetChannels);
    00192
    00196     TexCoordCalcMethod      getTexCalcMethod        (TextureUnitState* textureUnitState);
    00197
    00201     bool                    needsTextureMatrix      (TextureUnitState* textureUnitState);
    00202
    00203 // Attributes.
    00204 protected:
    00205     TextureUnitParamsList   mTextureUnitParamsList;     // Texture units list.
    00206     UniformParameterPtr     mWorldMatrix;               // World matrix parameter.
    00207     UniformParameterPtr     mWorldITMatrix;             // World inverse transpose matrix parameter.
    00208     UniformParameterPtr     mViewMatrix;                // View matrix parameter.
    00209     ParameterPtr            mVSInputNormal;             // Vertex shader input normal parameter.
    00210     ParameterPtr            mVSInputPos;                // Vertex shader input position parameter.
    00211     ParameterPtr            mPSOutDiffuse;              // Pixel shader output colour.
    00212     ParameterPtr            mPSDiffuse;                 // Pixel shader diffuse colour.
    00213     ParameterPtr            mPSSpecular;                // Pixel shader specular colour.
    00214 };
    00215
    00216
    00221 class _OgreRTSSExport FFPTexturingFactory : public SubRenderStateFactory
    00222 {
    00223 public:
    00224
    00228     virtual const String&   getType             () const;
    00229
    00233     virtual SubRenderState* createInstance      (ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass);
    00234
    00238     virtual void            writeInstance       (MaterialSerializer* ser, SubRenderState* subRenderState, Pass* srcPass, Pass* dstPass);
    00239
    00240
    00241 protected:
    00242
    00246     virtual SubRenderState* createInstanceImpl  ();
    00247
    00248
    00249 };
    00250
    00255 }
    00256 }
    00257
    00258 #endif
    00259 #endif
    00260

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Nov 3 2010 19:24:52