Project

General

Profile

SO3Engine
SO3GBufferSchemeHandler.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
25#ifndef __SO3_DEFERRED_SHADING_G_BUFFER_SCHEME_HANDLER_H__
26#define __SO3_DEFERRED_SHADING_G_BUFFER_SCHEME_HANDLER_H__
27
29#include <OgreMaterialManager.h>
30
31namespace SO3
32{
33
42class SGBufferSchemeHandler : public Ogre::MaterialManager::Listener
43{
44public:
45protected:
46 static const Ogre::String NORMAL_MAP_PATTERN1; //The string that will be checked in textures (unit name and texture file name) to determine whether they are normal maps.
47 static const Ogre::String NORMAL_MAP_PATTERN2;
48 static const Ogre::String NORMAL_MAP_PATTERN3;
49 static const Ogre::String NORMAL_MAP_PATTERN4;
50 static const Ogre::String NORMAL_MAP_PATTERN5;
51 static const Ogre::String NORMAL_MAP_PATTERN6;
52 static const Ogre::String NORMAL_MAP_PATTERN7;
53 static const Ogre::String SPECULAR_MAP_PATTERN1; //The string that will be checked in textures (unit name and texture file name) to determine whether they are specular maps.
54 static const Ogre::String SPECULAR_MAP_PATTERN2;
55 static const Ogre::String LIGHT_MAP_PATTERN1; //The string that will be checked in textures (unit name and texture file name) to determine whether they are light maps.
56 static const Ogre::String LIGHT_MAP_PATTERN2;
57 static const Ogre::String LIGHT_MAP_PATTERN3;
58
60 struct PassProperties //A structure for containing the properties of a material, relevant to GBuffer rendering
61 {
63 Ogre::vector<Ogre::TextureUnitState*>::type regularTextures;
64 Ogre::TextureUnitState* normalMap;
65 Ogre::TextureUnitState* specularMap;
66 Ogre::TextureUnitState* lightMap;
72 //Example of possible extension : vertex colours
73 //Ogre::TrackVertexColourType vertexColourType;
75 normalMap(0),
76 specularMap(0),
77 lightMap(0),
78 isSkinned(false),
79 hasDiffuseColour(false),
80 hasSpecularColour(false),
81 hasEmissiveColour(false),
83 {
84 }
85 };
86private:
87
88public:
91 SGBufferSchemeHandler(SGBufferMaterialGenerator* materialGeneratorInstance);
92
96 virtual Ogre::Technique* handleSchemeNotFound(unsigned short schemeIndex, const Ogre::String& schemeName, Ogre::Material* originalMaterial, unsigned short lodIndex, const Ogre::Renderable* rend);
97protected:
101 PassProperties InspectPass(Ogre::Pass* pass, unsigned short lodIndex, const Ogre::Renderable* rend);
102
106 SGBufferMaterialPermutation GetPermutation(const PassProperties& props);
107
111 void FillPass(Ogre::Pass* gBufferPass, Ogre::Pass* originalPass, const PassProperties& props);
112
116 bool CheckNormalMap(Ogre::TextureUnitState* tus, PassProperties& props, const Ogre::String& lowerCaseName, const Ogre::String& lowerCaseAlias, const Ogre::String& lowerCaseFileName);
117
121 bool CheckSpecularMap(Ogre::TextureUnitState* tus, PassProperties& props, const Ogre::String& lowerCaseName, const Ogre::String& lowerCaseAlias, const Ogre::String& lowerCaseFileName);
122
126 bool CheckLightMap(Ogre::TextureUnitState* tus, PassProperties& props, const Ogre::String& lowerCaseName, const Ogre::String& lowerCaseAlias, const Ogre::String& lowerCaseFileName);
127private:
132};
133
134}
135
136#endif
static const Ogre::String NORMAL_MAP_PATTERN1
PassProperties InspectPass(Ogre::Pass *pass, unsigned short lodIndex, const Ogre::Renderable *rend)
static const Ogre::String NORMAL_MAP_PATTERN3
static const Ogre::String LIGHT_MAP_PATTERN1
static const Ogre::String NORMAL_MAP_PATTERN7
void FillPass(Ogre::Pass *gBufferPass, Ogre::Pass *originalPass, const PassProperties &props)
bool CheckSpecularMap(Ogre::TextureUnitState *tus, PassProperties &props, const Ogre::String &lowerCaseName, const Ogre::String &lowerCaseAlias, const Ogre::String &lowerCaseFileName)
static const Ogre::String LIGHT_MAP_PATTERN2
static const Ogre::String NORMAL_MAP_PATTERN5
static const Ogre::String NORMAL_MAP_PATTERN6
SGBufferMaterialPermutation GetPermutation(const PassProperties &props)
static const Ogre::String LIGHT_MAP_PATTERN3
static const Ogre::String SPECULAR_MAP_PATTERN1
virtual Ogre::Technique * handleSchemeNotFound(unsigned short schemeIndex, const Ogre::String &schemeName, Ogre::Material *originalMaterial, unsigned short lodIndex, const Ogre::Renderable *rend)
bool CheckNormalMap(Ogre::TextureUnitState *tus, PassProperties &props, const Ogre::String &lowerCaseName, const Ogre::String &lowerCaseAlias, const Ogre::String &lowerCaseFileName)
SGBufferMaterialGenerator * materialGenerator
static const Ogre::String NORMAL_MAP_PATTERN2
bool CheckLightMap(Ogre::TextureUnitState *tus, PassProperties &props, const Ogre::String &lowerCaseName, const Ogre::String &lowerCaseAlias, const Ogre::String &lowerCaseFileName)
static const Ogre::String SPECULAR_MAP_PATTERN2
static const Ogre::String NORMAL_MAP_PATTERN4
Ogre::vector< Ogre::TextureUnitState * >::type regularTextures