27 #ifndef _ShaderExNormalMapLighting_
28 #define _ShaderExNormalMapLighting_
31 #ifdef RTSHADER_SYSTEM_BUILD_EXT_SHADERS
48 #define SGX_LIB_NORMALMAPLIGHTING "SGXLib_NormalMapLighting"
49 #define SGX_FUNC_CONSTRUCT_TBNMATRIX "SGX_ConstructTBNMatrix"
50 #define SGX_FUNC_TRANSFORMNORMAL "SGX_TransformNormal"
51 #define SGX_FUNC_TRANSFORMPOSITION "SGX_TransformPosition"
52 #define SGX_FUNC_FETCHNORMAL "SGX_FetchNormal"
53 #define SGX_FUNC_LIGHT_DIRECTIONAL_DIFFUSE "SGX_Light_Directional_Diffuse"
54 #define SGX_FUNC_LIGHT_DIRECTIONAL_DIFFUSESPECULAR "SGX_Light_Directional_DiffuseSpecular"
55 #define SGX_FUNC_LIGHT_POINT_DIFFUSE "SGX_Light_Point_Diffuse"
56 #define SGX_FUNC_LIGHT_POINT_DIFFUSESPECULAR "SGX_Light_Point_DiffuseSpecular"
57 #define SGX_FUNC_LIGHT_SPOT_DIFFUSE "SGX_Light_Spot_Diffuse"
58 #define SGX_FUNC_LIGHT_SPOT_DIFFUSESPECULAR "SGX_Light_Spot_DiffuseSpecular"
74 virtual const String& getType()
const;
79 virtual int getExecutionOrder()
const;
84 virtual void updateGpuProgramsParams(Renderable* rend, Pass* pass,
const AutoParamDataSource* source,
const LightList* pLightList);
89 virtual void copyFrom(
const SubRenderState& rhs);
95 virtual bool preAddToRenderState(
const RenderState* renderState, Pass* srcPass, Pass* dstPass);
100 void setTexCoordIndex(
unsigned int index) { mVSTexCoordSetIndex = index;}
105 unsigned int getTexCoordIndex()
const {
return mVSTexCoordSetIndex; }
129 void setNormalMapSpace(NormalMapSpace normalMapSpace) { mNormalMapSpace = normalMapSpace; }
132 NormalMapSpace getNormalMapSpace()
const {
return mNormalMapSpace; }
137 void setNormalMapTextureName(
const String& textureName) { mNormalMapTextureName = textureName; }
142 const String& getNormalMapTextureName()
const {
return mNormalMapTextureName; }
151 { mNormalMapMinFilter = minFilter; mNormalMapMagFilter = magFilter; mNormalMapMipFilter = mipFilter; }
160 { minFilter = mNormalMapMinFilter; magFilter = mNormalMapMagFilter ; mipFilter = mNormalMapMipFilter; }
165 void setNormalMapAnisotropy(
unsigned int anisotropy) { mNormalMapAnisotropy = anisotropy; }
169 unsigned int getNormalMapAnisotropy()
const {
return mNormalMapAnisotropy; }
175 void setNormalMapMipBias(
Real mipBias) { mNormalMapMipBias = mipBias; }
179 Real getNormalMapMipBias()
const {
return mNormalMapMipBias; }
214 typedef vector<LightParams>::type LightParamsList;
215 typedef LightParamsList::iterator LightParamsIterator;
216 typedef LightParamsList::const_iterator LightParamsConstIterator;
238 void setLightCount(
const int lightCount[3]);
244 void getLightCount(
int lightCount[3])
const;
250 void setSpecularEnable(
bool enable) { mSpecularEnable = enable; }
255 bool getSpecularEnable()
const {
return mSpecularEnable; }
261 virtual bool resolveParameters(ProgramSet* programSet);
264 bool resolveGlobalParameters(ProgramSet* programSet);
267 bool resolvePerLightParameters(ProgramSet* programSet);
272 virtual bool resolveDependencies(ProgramSet* programSet);
277 virtual bool addFunctionInvocations(ProgramSet* programSet);
283 bool addVSInvocation(Function* vsMain,
const int groupOrder,
int& internalCounter);
288 bool addVSIlluminationInvocation(LightParams* curLightParams, Function* vsMain,
const int groupOrder,
int& internalCounter);
293 bool addPSNormalFetchInvocation(Function* psMain,
const int groupOrder,
int& internalCounter);
299 bool addPSGlobalIlluminationInvocation(Function* psMain,
const int groupOrder,
int& internalCounter);
304 bool addPSIlluminationInvocation(LightParams* curLightParams, Function* psMain,
const int groupOrder,
int& internalCounter);
309 bool addPSFinalAssignmentInvocation(Function* psMain,
const int groupOrder,
int& internalCounter);
315 String mNormalMapTextureName;
319 bool mSpecularEnable;
321 LightParamsList mLightParamsList;
323 unsigned short mNormalMapSamplerIndex;
325 unsigned int mVSTexCoordSetIndex;
333 unsigned int mNormalMapAnisotropy;
335 Real mNormalMapMipBias;
337 NormalMapSpace mNormalMapSpace;
399 static Light msBlankLight;
407 class _OgreRTSSExport NormalMapLightingFactory :
public SubRenderStateFactory
414 virtual const String& getType()
const;
419 virtual SubRenderState* createInstance(ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass, SGScriptTranslator* translator);
424 virtual void writeInstance(MaterialSerializer* ser, SubRenderState* subRenderState, Pass* srcPass, Pass* dstPass);
432 virtual SubRenderState* createInstanceImpl();
float Real
Software floating point type.
HashedVector< Light * > LightList
LightTypes
Defines the type of light.
SharedPtr< Parameter > ParameterPtr
SharedPtr< UniformParameter > UniformParameterPtr
FilterOptions
Filtering options for textures / mipmaps.
int TrackVertexColourType
An enumeration describing which material properties should track the vertex colours.