00001 #ifndef _FB_SHADER_H_
00002 #define _FB_SHADER_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00045 #include <kaydaradef.h>
00046 #ifndef FBSDK_DLL
00047
00050 #define FBSDK_DLL K_DLLIMPORT
00051 #endif
00052
00053 #include <fbsdk/fbcomponent.h>
00054 #include <fbsdk/fbcore.h>
00055
00056 K_FORWARD( KRenderOptions );
00057 K_FORWARD( KModelRenderInfo );
00058 K_FORWARD( IGraphicPrimitives );
00059
00060 #ifdef FBSDKUseNamespace
00061 namespace FBSDKNamespace {
00062 #endif
00063
00071 #define FBRegisterShader( UniqueNameStr, ClassName, Label, Description, IconFilename ) \
00072 HIObject RegisterShader##ClassName( HIObject ,char * pName,void * ) \
00073 { \
00074 ClassName *Class = new ClassName( pName ); \
00075 Class->UniqueName = UniqueNameStr; \
00076 Class->ShaderDescription = Description; \
00077 if (Class->FBCreate()) { \
00078 return Class->GetHIObject(); \
00079 } else { \
00080 delete Class; \
00081 return NULL; \
00082 } \
00083 } \
00084 FBLibraryModule( ClassName ) \
00085 { \
00086 FBRegisterObject( ClassName##R1,"renderer/usershader/ogl",Label,Description,RegisterShader##ClassName,true, IconFilename ); \
00087 FBRegisterObject( ClassName##R2,"FbxStorable/Shader",UniqueNameStr,Description,RegisterShader##ClassName,true, IconFilename ); \
00088 }
00089
00094 #define FBShaderDeclare( ClassName, Parent ) \
00095 FBClassDeclare( ClassName,Parent); \
00096 public: \
00097 ClassName(char * pName):Parent(pName) { FBClassInit; } \
00098 private:
00099
00103 #define FBShaderImplementation( ThisComponent ) \
00104 FBClassImplementation( ThisComponent )
00105
00107
00109 FB_FORWARD( FBShaderManager );
00110 FB_FORWARD( FBShader );
00111
00219 class FBSDK_DLL FBShaderManager
00220 {
00225 FBShaderManager( const FBShaderManager& );
00226
00231 FBShaderManager& operator=( const FBShaderManager& );
00232
00233 public:
00234
00236 FBShaderManager();
00237
00243 ~FBShaderManager();
00244
00256 HFBShader CreateShader( const char* pShaderTypeName );
00257
00266 FBStringList ShaderTypeNames;
00267
00289 FBStringList ShaderTypeNamesLocalized;
00290 };
00291
00292
00294
00296
00297
00298 FB_FORWARD( FBShaderModelInfo );
00299 class FBSDK_DLL FBShaderModelInfo
00300 {
00301 public:
00302 FBShaderModelInfo(HIGraphicPrimitives pGPS);
00303 virtual ~FBShaderModelInfo();
00304
00306 virtual void UpdateModelShaderInfo(int pShader_Version);
00307
00308 HFBModel GetFBModel();
00309
00310 public:
00312 HIGraphicPrimitives mGPS;
00313
00315 int mModel_Version;
00316
00318 int mShader_Version;
00319
00321 bool mOriginal_Texture_Flag;
00322 };
00323
00325 FB_FORWARD( FBRenderOptions );
00326 class FBSDK_DLL FBRenderOptions
00327 {
00328 public:
00329 FBRenderOptions(HKRenderOptions pOptions);
00330
00334 int GetRenderFrameId();
00335
00336 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00337
00338 HKRenderOptions mRenderOptions;
00339 #endif
00340 };
00341
00343
00346 enum FBRenderingPass {
00347 kFBPassInvalid = 0,
00348 kFBPassPreRender = 1 << 0,
00349 kFBPassFlat = 1 << 1,
00350 kFBPassLighted = 1 << 2,
00351 kFBPassMatte = 1 << 3,
00352 kFBPassZTranslucent = 1 << 4,
00353 kFBPassZTranslucentAlphaTest = 1 << 5,
00354 kFBPassTranslucent = 1 << 6,
00355 kFBPassAddColor = 1 << 7,
00356 kFBPassTranslucentZSort = 1 << 8,
00357 kFBPassPostRender = 1 << 9
00358 };
00359
00364 enum FBAlphaSource
00365 {
00366 kFBAlphaSourceNoAlpha ,
00367 kFBAlphaSourceAccurateAlpha ,
00368 kFBAlphaSourceTransluscentAlpha ,
00369 kFBAlphaSourceMatteAlpha ,
00370 kFBAlphaSource2DTransparency ,
00371 kFBAlphaSourceAdditiveAlpha ,
00372 kFBAlphaSourceTransluscentZSortAlpha,
00373 };
00374 FB_DEFINE_ENUM( FBSDK_DLL, AlphaSource )
00375
00376
00377 FB_DEFINE_ENUM( FBSDK_DLL, RenderingPass );
00378
00379 FB_FORWARD( FBRenderer );
00380 __FB_FORWARD( FBShader );
00381 FB_DEFINE_COMPONENT ( FBSDK_DLL, Shader );
00382 FB_DEFINE_LIST ( FBSDK_DLL, Shader );
00383
00385 class FBSDK_DLL FBShader : public FBBox
00386 {
00387
00388 __FBClassDeclare( FBShader, FBBox );
00389
00390 public:
00395 FBShader( const char* pName, HIObject pObject = NULL);
00396
00397 IObject_Declare(Implementation);
00398
00404 virtual HFBShaderModelInfo NewShaderModelInfo( HFBRenderOptions pOptions, HIGraphicPrimitives pGPS );
00405
00410 virtual void DestroyShaderModelInfo( HFBRenderOptions pOptions, HFBShaderModelInfo pInfo );
00411
00415 virtual void ReplaceAll( HFBModel pModel );
00416
00420 virtual void Append( HFBModel pModel );
00421
00425 virtual bool ShaderNeedBeginRender();
00426
00430 virtual void ShaderBeginRender( HFBRenderOptions pOptions, HFBShaderModelInfo pInfo );
00431
00437 virtual void ShadeModel( HFBRenderOptions pOptions, HFBShaderModelInfo pInfo, FBRenderingPass pPass );
00438
00442 virtual void CloneShaderParameter( HFBShader pNewShader );
00443
00448 virtual void DetachDisplayContext( HFBRenderOptions pOptions, HFBShaderModelInfo pInfo );
00449
00454 virtual bool FbxStore (HFBFbxObject pFbxObject);
00455
00461 virtual bool FbxRetrieve(HFBFbxObject pFbxObject, HFBRenderer pRenderer);
00462
00463 char* ShaderDescription;
00464
00470 FBPropertyRenderingPass RenderingPass;
00471
00473 int GetShaderVersion() const { return mShader_Version; }
00474
00475 protected:
00482 static FBRenderingPass GetRenderingPassNeededForAlpha(FBAlphaSource pTransparency);
00483
00484 int mShader_Version;
00485 };
00486
00488
00491 class FBSDK_DLL FBPropertyListShader : public FBPropertyListComponent
00492 {
00493 public:
00494 FBPropertyListShader();
00499 FBShader* operator[](int pIndex);
00500 };
00501
00503
00505 FB_FORWARD( FBShaderLighted );
00506 FB_DEFINE_COMPONENT( FBSDK_DLL, ShaderLighted );
00507
00574 class FBSDK_DLL FBShaderLighted : public FBShader
00575 {
00576
00577 FBClassDeclare( FBShaderLighted, FBShader );
00578
00579 public:
00584 FBShaderLighted( const char* pName, HIObject pObject = NULL );
00585
00586 FBPropertyBool UseContrast;
00587 FBPropertyDouble Contrast;
00588
00589 FBPropertyBool UseLuminosity;
00590 FBPropertyDouble Luminosity;
00591
00592 FBPropertyBool UseSpecular;
00593 FBPropertyDouble Specular;
00594
00595 FBPropertyAlphaSource Transparency;
00596 FBPropertyAnimatableDouble Alpha;
00597 };
00598
00599
00601
00603 FB_FORWARD( FBShaderShadowLive );
00604 FB_DEFINE_COMPONENT( FBSDK_DLL, ShaderShadowLive );
00605
00609 enum FBShadowType
00610 {
00611 kFBShadowTypeShadowPlanar ,
00612 kFBShadowTypeShadowProjectiveTexture ,
00613 kFBShadowTypeLightMapProjectiveTexture ,
00614 kFBShadowTypeZShadowProjectiveTexture ,
00615 kFBShadowTypeZLightMapProjectiveTexture,
00616 };
00617 FB_DEFINE_ENUM( FBSDK_DLL, ShadowType );
00618
00621 enum FBShadowFrameType
00622 {
00623 kFBShadowFrameTypeShadowReceiver,
00624 kFBShadowFrameTypeShadowCaster ,
00625 kFBShadowFrameTypeShadowCubeMap ,
00626 };
00627 FB_DEFINE_ENUM( FBSDK_DLL, ShadowFrameType );
00628
00629
00678 class FBSDK_DLL FBShaderShadowLive : public FBShader
00679 {
00680
00681 FBClassDeclare( FBShaderShadowLive, FBShader );
00682
00683 public:
00688 FBShaderShadowLive( const char* pName, HIObject pObject = NULL );
00689
00690 FBPropertyShadowType ShadowType;
00691 FBPropertyAnimatableDouble ShadowIntensity;
00692 FBPropertyBool LocalShadow;
00693 FBPropertyBool UseGobo;
00694 FBPropertyDouble ShadowZOffset;
00695 FBPropertyShadowFrameType ShadowFrameType;
00696
00697 FBPropertyListObject Lights;
00698 FBPropertyListObject Models;
00699
00700 };
00701
00702
00703 #ifdef FBSDKUseNamespace
00704 }
00705 #endif
00706 #endif