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-2012 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 
00049 #define SGX_LIB_INTEGRATEDPSSM                      "SGXLib_IntegratedPSSM"
00050 #define SGX_FUNC_COMPUTE_SHADOW_COLOUR3             "SGX_ComputeShadowFactor_PSSM3"
00051 #define SGX_FUNC_APPLYSHADOWFACTOR_DIFFUSE          "SGX_ApplyShadowFactor_Diffuse"
00052 #define SGX_FUNC_MODULATE_SCALAR                    "SGX_ModulateScalar"
00053 
00057 class _OgreRTSSExport IntegratedPSSM3 : public SubRenderState
00058 {
00059 
00060     // Interface.
00061 public:
00062     typedef std::vector<Real> SplitPointList;
00063 
00065     IntegratedPSSM3();
00066 
00070     virtual const String& getType() const;
00071 
00075     virtual int getExecutionOrder() const;
00076 
00080     virtual void updateGpuProgramsParams(Renderable* rend, Pass* pass, const AutoParamDataSource* source, const LightList* pLightList);
00081 
00085     virtual void copyFrom(const SubRenderState& rhs);
00086 
00087 
00091     virtual bool preAddToRenderState(const RenderState* renderState, Pass* srcPass, Pass* dstPass);
00092 
00093 
00094     
00101     void setSplitPoints(const SplitPointList& newSplitPoints);
00102 
00103     static String Type;
00104 
00105     // Protected types:
00106 protected:
00107 
00108     // Shadow texture parameters.
00109     struct _OgreRTSSExport ShadowTextureParams
00110     {                   
00111         // The max range of this shadow texture in terms of PSSM (far plane of viewing camera).
00112         Real mMaxRange;
00113         // The shadow map sampler index.
00114         unsigned int mTextureSamplerIndex;
00115         // The shadow map sampler.          
00116         UniformParameterPtr mTextureSampler;
00117         // The inverse texture 
00118         UniformParameterPtr mInvTextureSize;
00119         // The source light view projection matrix combined with world matrix.      
00120         UniformParameterPtr mWorldViewProjMatrix;
00121         // The vertex shader output position in light space.
00122         ParameterPtr mVSOutLightPosition;
00123         // The pixel shader input position in light space.
00124         ParameterPtr mPSInLightPosition;
00125 
00126     };
00127 
00128     typedef std::vector<ShadowTextureParams>            ShadowTextureParamsList;
00129     typedef ShadowTextureParamsList::iterator           ShadowTextureParamsIterator;
00130     typedef ShadowTextureParamsList::const_iterator     ShadowTextureParamsConstIterator;
00131 
00132     // Protected methods
00133 protected:
00134 
00135 
00136 
00140     virtual bool resolveParameters(ProgramSet* programSet);
00141 
00145     virtual bool resolveDependencies(ProgramSet* programSet);
00146 
00150     virtual bool addFunctionInvocations(ProgramSet* programSet);
00151 
00155     bool addVSInvocation(Function* vsMain, const int groupOrder, int& internalCounter);
00156 
00160     bool addPSInvocation(Program* psProgram, const int groupOrder, int& internalCounter);
00161 
00162 
00163 
00164 
00165 
00166     // Attributes.
00167 protected:      
00168     // Shadow texture parameter list.   
00169     ShadowTextureParamsList mShadowTextureParamsList;
00170     // Split points parameter.
00171     UniformParameterPtr mPSSplitPoints;
00172     // Vertex shader input position parameter.  
00173     ParameterPtr mVSInPos;
00174     // Vertex shader output position (clip space) parameter.
00175     ParameterPtr mVSOutPos;
00176     // Vertex shader output depth (clip space) parameter.
00177     ParameterPtr mVSOutDepth;
00178     // Pixel shader input depth (clip space) parameter.
00179     ParameterPtr mPSInDepth;
00180     // Pixel shader local computed shadow colour parameter.
00181     ParameterPtr mPSLocalShadowFactor;
00182     // Pixel shader in/local diffuse colour parameter.
00183     ParameterPtr mPSDiffuse;
00184     // Pixel shader output diffuse colour parameter.
00185     ParameterPtr mPSOutDiffuse;
00186     // Pixel shader in/local specular colour parameter.
00187     ParameterPtr mPSSpecualr;
00188     // Derived scene colour (ambient term).
00189     UniformParameterPtr mPSDerivedSceneColour;
00190 
00191 };
00192 
00193 
00198 class _OgreRTSSExport IntegratedPSSM3Factory : public SubRenderStateFactory
00199 {
00200 public:
00201 
00205     virtual const String& getType() const;
00206 
00210     virtual SubRenderState* createInstance(ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass, SGScriptTranslator* translator);
00211 
00212 
00213 protected:
00214 
00218     virtual SubRenderState* createInstanceImpl();
00219 
00220 
00221 };
00222 
00226 }
00227 }
00228 
00229 #endif
00230 #endif
00231 

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