OGRE  1.9.0
OgreShaderExIntegratedPSSM3.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28#ifndef _ShaderExIntegratedPSSM3_
29#define _ShaderExIntegratedPSSM3_
30
32#ifdef RTSHADER_SYSTEM_BUILD_EXT_SHADERS
33#include "OgreVector4.h"
34#include "OgreLight.h"
35#include "OgreCommon.h"
37#include "OgreShaderParameter.h"
38
39namespace Ogre {
40namespace RTShader {
41
49#define SGX_LIB_INTEGRATEDPSSM "SGXLib_IntegratedPSSM"
50#define SGX_FUNC_COMPUTE_SHADOW_COLOUR3 "SGX_ComputeShadowFactor_PSSM3"
51#define SGX_FUNC_APPLYSHADOWFACTOR_DIFFUSE "SGX_ApplyShadowFactor_Diffuse"
52#define SGX_FUNC_MODULATE_SCALAR "SGX_ModulateScalar"
53
57class _OgreRTSSExport IntegratedPSSM3 : public SubRenderState
58{
59
60 // Interface.
61public:
62 typedef vector<Real>::type SplitPointList;
63
65 IntegratedPSSM3();
66
70 virtual const String& getType() const;
71
75 virtual int getExecutionOrder() const;
76
80 virtual void updateGpuProgramsParams(Renderable* rend, Pass* pass, const AutoParamDataSource* source, const LightList* pLightList);
81
85 virtual void copyFrom(const SubRenderState& rhs);
86
87
91 virtual bool preAddToRenderState(const RenderState* renderState, Pass* srcPass, Pass* dstPass);
92
93
94
101 void setSplitPoints(const SplitPointList& newSplitPoints);
102
103 static String Type;
104
105 // Protected types:
106protected:
107
108 // Shadow texture parameters.
109 struct _OgreRTSSExport ShadowTextureParams
110 {
111 // The max range of this shadow texture in terms of PSSM (far plane of viewing camera).
112 Real mMaxRange;
113 // The shadow map sampler index.
114 unsigned int mTextureSamplerIndex;
115 // The shadow map sampler.
116 UniformParameterPtr mTextureSampler;
117 // The inverse texture
118 UniformParameterPtr mInvTextureSize;
119 // The source light view projection matrix combined with world matrix.
120 UniformParameterPtr mWorldViewProjMatrix;
121 // The vertex shader output position in light space.
122 ParameterPtr mVSOutLightPosition;
123 // The pixel shader input position in light space.
124 ParameterPtr mPSInLightPosition;
125
126 };
127
128 typedef vector<ShadowTextureParams>::type ShadowTextureParamsList;
129 typedef ShadowTextureParamsList::iterator ShadowTextureParamsIterator;
130 typedef ShadowTextureParamsList::const_iterator ShadowTextureParamsConstIterator;
131
132 // Protected methods
133protected:
134
135
136
140 virtual bool resolveParameters(ProgramSet* programSet);
141
145 virtual bool resolveDependencies(ProgramSet* programSet);
146
150 virtual bool addFunctionInvocations(ProgramSet* programSet);
151
155 bool addVSInvocation(Function* vsMain, const int groupOrder, int& internalCounter);
156
160 bool addPSInvocation(Program* psProgram, const int groupOrder, int& internalCounter);
161
162
163
164
165
166 // Attributes.
167protected:
168 // Shadow texture parameter list.
169 ShadowTextureParamsList mShadowTextureParamsList;
170 // Split points parameter.
171 UniformParameterPtr mPSSplitPoints;
172 // Vertex shader input position parameter.
173 ParameterPtr mVSInPos;
174 // Vertex shader output position (clip space) parameter.
175 ParameterPtr mVSOutPos;
176 // Vertex shader output depth (clip space) parameter.
177 ParameterPtr mVSOutDepth;
178 // Pixel shader input depth (clip space) parameter.
179 ParameterPtr mPSInDepth;
180 // Pixel shader local computed shadow colour parameter.
181 ParameterPtr mPSLocalShadowFactor;
182 // Pixel shader in/local diffuse colour parameter.
183 ParameterPtr mPSDiffuse;
184 // Pixel shader output diffuse colour parameter.
185 ParameterPtr mPSOutDiffuse;
186 // Pixel shader in/local specular colour parameter.
187 ParameterPtr mPSSpecualr;
188 // Derived scene colour (ambient term).
189 UniformParameterPtr mPSDerivedSceneColour;
190
191};
192
193
198class _OgreRTSSExport IntegratedPSSM3Factory : public SubRenderStateFactory
199{
200public:
201
205 virtual const String& getType() const;
206
210 virtual SubRenderState* createInstance(ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass, SGScriptTranslator* translator);
211
212
213protected:
214
218 virtual SubRenderState* createInstanceImpl();
219
220
221};
222
226}
227}
228
229#endif
230#endif
231
#define _OgreRTSSExport
SharedPtr< Parameter > ParameterPtr
SharedPtr< UniformParameter > UniformParameterPtr
float Real
Software floating point type.
_StringBase String