My Project
effect_file.h
1 #pragma once
2 #include <string>
3 #include <vector>
4 #include <list>
5 #include "AssetEntity.h"
6 #include "LightManager.h"
7 #include "ParameterBlock.h"
8 #include "EffectFileHandles.h"
9 #include "IObjectScriptingInterface.h"
10 
11 namespace ParaEngine
12 {
13  using namespace std;
14  class CSunLight;
15 
20  {
21  public:
22  const static int MAX_EFFECT_LIGHT_NUM = 4;
23 
28  {
30  TechCategory_default = 0,
39  };
40 
42  {
43  // matrix
44  k_worldMatrix = 0,
45  k_worldInverseMatrix,
46  k_worldViewMatrix,
47  k_worldViewProjMatrix,
48  k_worldMatrixArray,
49  k_viewMatrix,
50  k_projMatrix,
51  k_viewProjMatrix,
52  k_TexWorldViewProjMatrix,
53  k_skyBoxMatrix,
54 
55 
56  // parameters
57  k_first_parameter,
58  k_boneInfluenceCount,
59  k_ambientMaterialColor,
60  k_diffuseMaterialColor,
61  k_emissiveMaterialColor,
62  k_specularMaterialColor,
63  k_specularMaterialPower,
64  k_reflectFactor,
65  k_LayersNum, // how many alpha texture layers
66  k_LocalLightNum, // how many local lights are enabled
67  k_LightPositions, // vector array of float4(x,y,z,range)
68  k_LightColors, // vector array of float4(r,g,b,intensity)
69  k_LightParams, // vector array of float4(reserved, reserved,reserved,reserved)
70  k_patchCorners,
71  k_posScaleOffset,
72  k_uvScaleOffset,
73  k_lensFlareColor,
74  k_sunVector,
75  k_sunColor,
76  k_fresnelR0,
77  k_ambientLight,
78  k_atmosphericLighting,
79  k_cameraPos,
80  k_cameraDistances,
81  k_cameraFacing,
82  k_sunlightInscatter,
83  k_sunlightExtinction,
84  k_LightStrength,
85  k_bSunlightEnable,
86  k_nShadowmapSize,
87  k_fShadowRadius,
88  k_fogEnable,
89  k_fogParameters,
91  k_worldPos,
92  k_ConstVector0,
93  k_ConstVector1,
94  k_ConstVector2,
95  k_ConstVector3,
96  k_time, // scaler
97  k_specularPower, // specular scaler
98  k_texCoordOffset, // vector
99  k_opacity, // scaler
100  k_shadowFactor, //shadow factor, float2(x,1-x)
101  k_transitionFactor,
112  k_bAlphaBlending,
113  k_bBoolean0,
114  k_bBoolean1,
115  k_bBoolean2,
116  k_bBoolean3,
117  k_bBoolean4,
118  k_bBoolean5,
119  k_bBoolean6,
120  k_bBoolean7,
121  k_bBoolean8,
122  k_bBoolean9,
123  k_bBoolean10,
124  k_bBoolean11,
125  k_bBoolean12,
126  k_bBoolean13,
127  k_bBoolean14,
128  k_bBoolean15,
129  k_bBooleanMAX, // this is not used.
130 
131  // textures
132  k_tex0,
133  k_tex1,
134  k_tex2,
135  k_tex3,
136  k_tex4,
137  k_tex5,
138  k_tex6,
139  k_tex7,
140  k_tex8,
141  k_tex9,
142  k_tex10,
143  k_tex11,
144  k_tex12,
145  k_tex13,
146  k_tex14,
147  k_tex15,
148  k_tex_max,
149 
150  // textures matrix
151  k_tex_mat0,
152  k_tex_mat1,
153  k_tex_mat2,
154  k_tex_mat3,
155  k_tex_mat4,
156  k_tex_mat5,
157  k_tex_mat6,
158  k_tex_mat7,
159  k_tex_mat8,
160  k_tex_mat9,
161  k_tex_mat10,
162  k_tex_mat11,
163  k_tex_mat12,
164  k_tex_mat13,
165  k_tex_mat14,
166  k_tex_mat15,
167  k_tex_mat_max,
168 
169  // last one
170  k_max_param_handles
171  };
172 
173  enum CallBackType
174  {
175  Type_DrawPass
176  };
177 
180  {
181  TechniqueCategory nCategory;
182  public:
183  TechniqueDesc() :nCategory(TechCategory_default){
184  }
185  };
186 
187  public:
188  CEffectFileBase(){};
189  CEffectFileBase(const AssetKey& key) :AssetEntity(key){};
190  virtual ~CEffectFileBase(){};
191 
192  virtual AssetType GetType(){return effectfile;};
193 
194  // Mutators...
195  virtual HRESULT InitDeviceObjects(){ return S_OK; };
196  virtual HRESULT RestoreDeviceObjects(){ return S_OK; };
197  virtual HRESULT InvalidateDeviceObjects(){ return S_OK; };
198  virtual HRESULT DeleteDeviceObjects(){ return S_OK; };
199 
201  void SetFileName(const std::string& filename){};
202 
203  static void EnableTextures(bool bEnable){};
204  static bool AreTextureEnabled(){ return true; };
205 
206  int totalPasses()const { return 0; };
207 
209  void EnableSunLight(bool bEnableSunLight) {};
213  void applySurfaceMaterial(const ParaMaterial* pSurfaceMaterial, bool bUseGlobalAmbient = true) {};
214  void applyCameraMatrices() {};
215  void applyWorldMatrices() {};
216  void applyFogParameters(bool bEnableFog, const Vector4* fogParam, const LinearColor* fogColor) {};
217  void applyGlobalLightingData(CSunLight& sunlight) {};
218 
219  bool setParameter(eParameterHandles index, const void* data, int32 size = D3DX_DEFAULT) { return false; };
220  bool setParameter(eParameterHandles index, const Vector2* data) { return false; };
221  bool setParameter(eParameterHandles index, const Vector3* data) { return false; };
222  bool setParameter(eParameterHandles index, const Vector4* data) { return false; };
223 
224  bool setBool(eParameterHandles index, BOOL bBoolean) { return false; };
225  bool setInt(eParameterHandles index, int nValue) { return false; };
226  bool setFloat(eParameterHandles index, float fValue) { return false; };
227 
228  HRESULT SetRawValue(const char* hParameter, const void* pData, uint32 ByteOffset, uint32 Bytes) { return S_OK; };
229  bool SetBool(const char* hParameter, BOOL bBoolean) { return false; };
230  bool SetInt(const char* hParameter, int nValue) { return false; };
231  bool SetFloat(const char* hParameter, float fValue) { return false; };
232  bool SetVector2(const char* hParameter, const Vector2& vValue) { return false; };
233  bool SetVector3(const char* hParameter, const Vector3& vValue) { return false; };
234  bool SetVector4(const char* hParameter, const Vector4& vValue) { return false; };
235  bool SetMatrix(const char* hParameter, const Matrix4& data) { return false; };
236 
237  bool isParameterUsed(eParameterHandles index) { return false; };
238  bool setMatrix(eParameterHandles index, const Matrix4* data) { return false; };
239  bool isMatrixUsed(eParameterHandles index) { return false; };
240 
241  bool setTexture(int index, TextureEntity* data) { return false; };
242  bool setTexture(int index, DeviceTexturePtr_type pTex) { return false; };
243 
244  bool SetBoolean(int nIndex, bool value) { return false; };
245 
246  bool begin(bool bApplyParam = true, DWORD flag = 0) { return false; };
247  bool BeginPass(int pass, bool bForceBegin = false) { return false; };
248  void CommitChanges() {};
249  void EndPass(bool bForceEnd = false) {};
250  void end(bool bForceEnd = false) {};
251 
252  bool LoadBuildinShader() { return true; };
253 
257  void releaseEffect(int nPass = -1) {};
258 
264  bool EnableEnvironmentMapping(bool bEnable) { return false; };
271  bool EnableReflectionMapping(bool bEnable, float fSurfaceHeight = 0.f) { return false; };
272 
277  void SetReflectFactor(float fFactor) {};
282  void EnableNormalMap(bool bEnable) {};
283 
288  void EnableLightMap(bool bEnable) {};
289 
291  void EnableAlphaBlending(bool bAlphaBlending) {};
292 
294  void EnableAlphaTesting(bool bAlphaTesting) {};
295 
296 
309  bool SetTechniqueByIndex(int nIndex) { return false; };
311  const TechniqueDesc* GetCurrentTechniqueDesc() { return NULL; };
312 
313  void onDrawPass(CParameterBlock* pMaterialParams,int passIndex);
314  };
315 }
316 
317 #ifdef USE_DIRECTX_RENDERER
318 #include "effect_file_DirectX.h"
319 #elif defined(USE_OPENGL_RENDERER)
320 #include "effect_file_OpenGL.h"
321 #else
322 namespace ParaEngine{
323  class CEffectFile : public CEffectFileBase {
324  public:
325  CEffectFile(const AssetKey& key){};
326  };
327 }
328 #endif
Which DXT Compression to Use? Obviously, there are some trade-offs between the different formats whic...
Definition: TextureEntity.h:29
eParameterHandles
Definition: effect_file.h:41
boolean constants are for static branching,
Definition: effect_file.h:111
bool SetTechniqueByIndex(int nIndex)
Set technique if it is different from the current one.
Definition: effect_file.h:309
a technique description
Definition: effect_file.h:179
4-dimensional homogeneous vector.
Definition: ParaVector4.h:10
void SetFileName(const std::string &filename)
set inner file name, usually at the load time.
Definition: effect_file.h:201
AssetType
each asset type has a unique asset type number
Definition: AssetEntity.h:82
different physics engine has different winding order.
Definition: EventBinding.h:32
TechniqueCategory
The game engine will identified some predefined technique name from the the effect file...
Definition: effect_file.h:27
Modeling the global sun and its directional light, including sun position, direction, color, time of day, etc.
Definition: SunLight.h:26
void releaseEffect(int nPass=-1)
Definition: effect_file.h:257
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
technique name is "GenShadowMap"
Definition: effect_file.h:32
bool EnableReflectionMapping(bool bEnable, float fSurfaceHeight=0.f)
enable reflection mapping
Definition: effect_file.h:271
void applySurfaceMaterial(const ParaMaterial *pSurfaceMaterial, bool bUseGlobalAmbient=true)
Definition: effect_file.h:213
float4(fog_start, fog_range, fogDensity, reserved)
Definition: effect_file.h:90
technique name is "DetailCharacter"
Definition: effect_file.h:36
Standard 2-dimensional vector.
Definition: ParaVector2.h:16
bool SetFirstValidTechniqueByCategory(TechniqueCategory nCat)
Set technique if it is different from the current one.
Definition: effect_file.h:302
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
Definition: RenderCore.h:50
void EnableSunLight(bool bEnableSunLight)
whether to enable sun light calculation
Definition: effect_file.h:209
Definition: enum_maker.hpp:46
Definition: effect_file.h:323
const TechniqueDesc * GetCurrentTechniqueDesc()
get the current technique description.
Definition: effect_file.h:311
void EnableLightMap(bool bEnable)
whether to enable the use of light map
Definition: effect_file.h:288
bool EnableEnvironmentMapping(bool bEnable)
enable environment mapping
Definition: effect_file.h:264
void EnableAlphaBlending(bool bAlphaBlending)
whether to enable alpha blending in shader.
Definition: effect_file.h:291
technique name is "Character"
Definition: effect_file.h:34
Definition: IObjectScriptingInterface.h:6
std::string AssetKey
the unique key object for asset entity.
Definition: AssetEntity.h:13
technique name is "Vegetation"
Definition: effect_file.h:38
A linear, 32-bit/component floating point RGBA color.
Definition: ParaColor.h:12
void EnableAlphaTesting(bool bAlphaTesting)
whether to enable alpha testing
Definition: effect_file.h:294
void SetReflectFactor(float fFactor)
set shader parameter "reflectFactor"
Definition: effect_file.h:277
Base class for managed asset entity in ParaEngine.
Definition: AssetEntity.h:25
a list of CParameter{name, value} pairs of anything.
Definition: ParameterBlock.h:108
void EnableNormalMap(bool bEnable)
whether to enable the use of normal map
Definition: effect_file.h:282
asset entity: CEffectFile
Definition: effect_file.h:19