OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreShaderExIntegratedPSSM3.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef _ShaderExIntegratedPSSM3_
29 #define _ShaderExIntegratedPSSM3_
30 
32 #ifdef RTSHADER_SYSTEM_BUILD_EXT_SHADERS
33 #include "OgreCommon.h"
35 
36 namespace Ogre {
37 namespace RTShader {
38 
46 #define SGX_LIB_INTEGRATEDPSSM "SGXLib_IntegratedPSSM"
47 #define SGX_FUNC_COMPUTE_SHADOW_COLOUR3 "SGX_ComputeShadowFactor_PSSM3"
48 #define SGX_FUNC_APPLYSHADOWFACTOR_DIFFUSE "SGX_ApplyShadowFactor_Diffuse"
49 #define SGX_FUNC_MODULATE_SCALAR "SGX_ModulateScalar"
50 
54 class _OgreRTSSExport IntegratedPSSM3 : public SubRenderState
55 {
56 
57  // Interface.
58 public:
59  typedef vector<Real>::type SplitPointList;
60 
62  IntegratedPSSM3();
63 
67  virtual const String& getType() const;
68 
72  virtual int getExecutionOrder() const;
73 
77  virtual void updateGpuProgramsParams(Renderable* rend, Pass* pass, const AutoParamDataSource* source, const LightList* pLightList);
78 
82  virtual void copyFrom(const SubRenderState& rhs);
83 
84 
88  virtual bool preAddToRenderState(const RenderState* renderState, Pass* srcPass, Pass* dstPass);
89 
90 
91 
98  void setSplitPoints(const SplitPointList& newSplitPoints);
99 
100  static String Type;
101 
102  // Protected types:
103 protected:
104 
105  // Shadow texture parameters.
106  struct _OgreRTSSExport ShadowTextureParams
107  {
108  // The max range of this shadow texture in terms of PSSM (far plane of viewing camera).
109  Real mMaxRange;
110  // The shadow map sampler index.
111  unsigned int mTextureSamplerIndex;
112  // The shadow map sampler.
113  UniformParameterPtr mTextureSampler;
114  // The inverse texture
115  UniformParameterPtr mInvTextureSize;
116  // The source light view projection matrix combined with world matrix.
117  UniformParameterPtr mWorldViewProjMatrix;
118  // The vertex shader output position in light space.
119  ParameterPtr mVSOutLightPosition;
120  // The pixel shader input position in light space.
121  ParameterPtr mPSInLightPosition;
122 
123  };
124 
125  typedef vector<ShadowTextureParams>::type ShadowTextureParamsList;
126  typedef ShadowTextureParamsList::iterator ShadowTextureParamsIterator;
127  typedef ShadowTextureParamsList::const_iterator ShadowTextureParamsConstIterator;
128 
129  // Protected methods
130 protected:
131 
132 
133 
137  virtual bool resolveParameters(ProgramSet* programSet);
138 
142  virtual bool resolveDependencies(ProgramSet* programSet);
143 
147  virtual bool addFunctionInvocations(ProgramSet* programSet);
148 
152  bool addVSInvocation(Function* vsMain, const int groupOrder, int& internalCounter);
153 
157  bool addPSInvocation(Program* psProgram, const int groupOrder, int& internalCounter);
158 
159 
160 
161 
162 
163  // Attributes.
164 protected:
165  // Shadow texture parameter list.
166  ShadowTextureParamsList mShadowTextureParamsList;
167  // Split points parameter.
168  UniformParameterPtr mPSSplitPoints;
169  // Vertex shader input position parameter.
170  ParameterPtr mVSInPos;
171  // Vertex shader output position (clip space) parameter.
172  ParameterPtr mVSOutPos;
173  // Vertex shader output depth (clip space) parameter.
174  ParameterPtr mVSOutDepth;
175  // Pixel shader input depth (clip space) parameter.
176  ParameterPtr mPSInDepth;
177  // Pixel shader local computed shadow colour parameter.
178  ParameterPtr mPSLocalShadowFactor;
179  // Pixel shader in/local diffuse colour parameter.
180  ParameterPtr mPSDiffuse;
181  // Pixel shader output diffuse colour parameter.
182  ParameterPtr mPSOutDiffuse;
183  // Pixel shader in/local specular colour parameter.
184  ParameterPtr mPSSpecualr;
185  // Derived scene colour (ambient term).
186  UniformParameterPtr mPSDerivedSceneColour;
187 
188 };
189 
190 
195 class _OgreRTSSExport IntegratedPSSM3Factory : public SubRenderStateFactory
196 {
197 public:
198 
202  virtual const String& getType() const;
203 
207  virtual SubRenderState* createInstance(ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass, SGScriptTranslator* translator);
208 
209 
210 protected:
211 
215  virtual SubRenderState* createInstanceImpl();
216 
217 
218 };
219 
223 }
224 }
225 
226 #endif
227 #endif
228 
float Real
Software floating point type.
std::vector< Real, A > type
#define _OgreRTSSExport
SharedPtr< Parameter > ParameterPtr
HashedVector< LightClosest > LightList
Definition: OgreCommon.h:569
SharedPtr< UniformParameter > UniformParameterPtr
_StringBase String
Definition: OgreCommon.h:53