OgreShaderExIntegratedPSSM3.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 
00009 Permission is hereby granted, free of charge, to any person obtaining a copy
00010 of this software and associated documentation files (the "Software"), to deal
00011 in the Software without restriction, including without limitation the rights
00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00013 copies of the Software, and to permit persons to whom the Software is
00014 furnished to do so, subject to the following conditions:
00015 
00016 The above copyright notice and this permission notice shall be included in
00017 all copies or substantial portions of the Software.
00018 
00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00025 THE SOFTWARE.
00026 -----------------------------------------------------------------------------
00027 */
00028 #ifndef _ShaderExIntegratedPSSM3_
00029 #define _ShaderExIntegratedPSSM3_
00030 
00031 #include "OgreShaderPrerequisites.h"
00032 #ifdef RTSHADER_SYSTEM_BUILD_EXT_SHADERS
00033 #include "OgreVector4.h"
00034 #include "OgreLight.h"
00035 #include "OgreCommon.h"
00036 #include "OgreShaderSubRenderState.h"
00037 #include "OgreShaderParameter.h"
00038 
00039 namespace Ogre {
00040 namespace RTShader {
00041 
00052 class _OgreRTSSExport IntegratedPSSM3 : public SubRenderState
00053 {
00054 
00055     // Interface.
00056 public:
00057     typedef std::vector<Real> SplitPointList;
00058 
00060     IntegratedPSSM3();
00061 
00065     virtual const String&   getType                 () const;
00066 
00070     virtual int             getExecutionOrder       () const;
00071 
00075     virtual void            updateGpuProgramsParams (Renderable* rend, Pass* pass, const AutoParamDataSource* source, const LightList* pLightList);
00076 
00080     virtual void            copyFrom                (const SubRenderState& rhs);
00081 
00082 
00086     virtual bool            preAddToRenderState     (RenderState* renderState, Pass* srcPass, Pass* dstPass);
00087 
00088 
00089     
00096     void            setSplitPoints                  (const SplitPointList& newSplitPoints);
00097 
00098     static String Type;
00099 
00100     // Protected types:
00101 protected:
00102 
00103     // Shadow texture parameters.
00104     struct _OgreRTSSExport ShadowTextureParams
00105     {                   
00106         Real                mMaxRange;              // The max range of this shadow texture in terms of PSSM (far plane of viewing camera).
00107         unsigned int        mTextureSamplerIndex;   // The shadow map sampler index.
00108         UniformParameterPtr mTextureSampler;        // The shadow map sampler.          
00109         UniformParameterPtr mInvTextureSize;        // The inverse texture 
00110         UniformParameterPtr mWorldViewProjMatrix;   // The source light view projection matrix combined with world matrix.      
00111         ParameterPtr        mVSOutLightPosition;    // The vertex shader output position in light space.
00112         ParameterPtr        mPSInLightPosition;     // The pixel shader input position in light space.
00113 
00114     };
00115 
00116     typedef std::vector<ShadowTextureParams>            ShadowTextureParamsList;
00117     typedef ShadowTextureParamsList::iterator           ShadowTextureParamsIterator;
00118     typedef ShadowTextureParamsList::const_iterator     ShadowTextureParamsConstIterator;
00119 
00120     // Protected methods
00121 protected:
00122 
00123 
00124 
00128     virtual bool            resolveParameters       (ProgramSet* programSet);
00129 
00133     virtual bool            resolveDependencies     (ProgramSet* programSet);
00134 
00138     virtual bool            addFunctionInvocations  (ProgramSet* programSet);
00139 
00143     bool            addVSInvocation                     (Function* vsMain, const int groupOrder, int& internalCounter);
00144 
00148     bool            addPSInvocation                     (Program* psProgram, const int groupOrder, int& internalCounter);
00149 
00150 
00151 
00152 
00153 
00154     // Attributes.
00155 protected:      
00156     ShadowTextureParamsList     mShadowTextureParamsList;       // Shadow texture parameter list.   
00157     UniformParameterPtr         mPSSplitPoints;                 // Split points parameter.
00158     ParameterPtr                mVSInPos;                       // Vertex shader input position parameter.  
00159     ParameterPtr                mVSOutPos;                      // Vertex shader output position (clip space) parameter.
00160     ParameterPtr                mVSOutDepth;                    // Vertex shader output depth (clip space) parameter.
00161     ParameterPtr                mPSInDepth;                     // Pixel shader input depth (clip space) parameter.
00162     ParameterPtr                mPSLocalShadowFactor;           // Pixel shader local computed shadow colour parameter.
00163     ParameterPtr                mPSDiffuse;                     // Pixel shader in/local diffuse colour parameter.
00164     ParameterPtr                mPSOutDiffuse;                  // Pixel shader output diffuse colour parameter.
00165     ParameterPtr                mPSSpecualr;                    // Pixel shader in/local specular colour parameter.
00166     UniformParameterPtr         mPSDerivedSceneColour;          // Derived scene colour (ambient term).
00167 
00168 };
00169 
00170 
00175 class _OgreRTSSExport IntegratedPSSM3Factory : public SubRenderStateFactory
00176 {
00177 public:
00178 
00182     virtual const String&   getType             () const;
00183 
00187     virtual SubRenderState* createInstance      (ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass);
00188 
00189 
00190 protected:
00191 
00195     virtual SubRenderState* createInstanceImpl  ();
00196 
00197 
00198 };
00199 
00203 }
00204 }
00205 
00206 #endif
00207 #endif
00208 

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