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 Real mMaxRange; // The max range of this shadow texture in terms of PSSM (far plane of viewing camera). 00112 unsigned int mTextureSamplerIndex; // The shadow map sampler index. 00113 UniformParameterPtr mTextureSampler; // The shadow map sampler. 00114 UniformParameterPtr mInvTextureSize; // The inverse texture 00115 UniformParameterPtr mWorldViewProjMatrix; // The source light view projection matrix combined with world matrix. 00116 ParameterPtr mVSOutLightPosition; // The vertex shader output position in light space. 00117 ParameterPtr mPSInLightPosition; // The pixel shader input position in light space. 00118 00119 }; 00120 00121 typedef std::vector<ShadowTextureParams> ShadowTextureParamsList; 00122 typedef ShadowTextureParamsList::iterator ShadowTextureParamsIterator; 00123 typedef ShadowTextureParamsList::const_iterator ShadowTextureParamsConstIterator; 00124 00125 // Protected methods 00126 protected: 00127 00128 00129 00133 virtual bool resolveParameters (ProgramSet* programSet); 00134 00138 virtual bool resolveDependencies (ProgramSet* programSet); 00139 00143 virtual bool addFunctionInvocations (ProgramSet* programSet); 00144 00148 bool addVSInvocation (Function* vsMain, const int groupOrder, int& internalCounter); 00149 00153 bool addPSInvocation (Program* psProgram, const int groupOrder, int& internalCounter); 00154 00155 00156 00157 00158 00159 // Attributes. 00160 protected: 00161 ShadowTextureParamsList mShadowTextureParamsList; // Shadow texture parameter list. 00162 UniformParameterPtr mPSSplitPoints; // Split points parameter. 00163 ParameterPtr mVSInPos; // Vertex shader input position parameter. 00164 ParameterPtr mVSOutPos; // Vertex shader output position (clip space) parameter. 00165 ParameterPtr mVSOutDepth; // Vertex shader output depth (clip space) parameter. 00166 ParameterPtr mPSInDepth; // Pixel shader input depth (clip space) parameter. 00167 ParameterPtr mPSLocalShadowFactor; // Pixel shader local computed shadow colour parameter. 00168 ParameterPtr mPSDiffuse; // Pixel shader in/local diffuse colour parameter. 00169 ParameterPtr mPSOutDiffuse; // Pixel shader output diffuse colour parameter. 00170 ParameterPtr mPSSpecualr; // Pixel shader in/local specular colour parameter. 00171 UniformParameterPtr mPSDerivedSceneColour; // Derived scene colour (ambient term). 00172 00173 }; 00174 00175 00180 class _OgreRTSSExport IntegratedPSSM3Factory : public SubRenderStateFactory 00181 { 00182 public: 00183 00187 virtual const String& getType () const; 00188 00192 virtual SubRenderState* createInstance (ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass, SGScriptTranslator* translator); 00193 00194 00195 protected: 00196 00200 virtual SubRenderState* createInstanceImpl (); 00201 00202 00203 }; 00204 00208 } 00209 } 00210 00211 #endif 00212 #endif 00213
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