1 | // author: Barnabas Aszodi (BME-IIT)
|
---|
2 |
|
---|
3 | #include "Ogre.h"
|
---|
4 | #include "OgreEffectWrapper.h"
|
---|
5 | #include "ManagedOgreRenderTexturePass.h"
|
---|
6 | #include "PreComputingRun.h"
|
---|
7 |
|
---|
8 | #include "CAURenderColorDistanceCubeMapPass.h"
|
---|
9 | #include "CAURenderUVCubeMapPass.h"
|
---|
10 | #include "CAURenderPhotonUVMapPass.h"
|
---|
11 | #include "CAURenderUmbraPass.h"
|
---|
12 | #include "CAURenderPhotonHitMapPass.h"
|
---|
13 | #include "CAURenderRefractObjectMapPass.h"
|
---|
14 |
|
---|
15 | #include "CausticMapRun.h"
|
---|
16 |
|
---|
17 |
|
---|
18 | CausticMapRun::CausticMapRun( Entity* entity, unsigned int width, unsigned int height)
|
---|
19 | {
|
---|
20 | Root* mRoot = Root::getSingletonPtr();
|
---|
21 | OgreAssert(mRoot!=NULL," NULL pointer found ");
|
---|
22 |
|
---|
23 | this->entity = entity;
|
---|
24 |
|
---|
25 | // CubeMap
|
---|
26 | this->cAURenderColorDistanceCubeMapPass =
|
---|
27 | new CAURenderColorDistanceCubeMapPass( mRoot,"CubeMapColorDistanceTexture",512,512,TEX_TYPE_CUBE_MAP,PF_FLOAT32_RGBA );
|
---|
28 | // CubeMap
|
---|
29 | this->cAURenderUVCubeMapPass =
|
---|
30 | new CAURenderUVCubeMapPass( mRoot,"CubeMapUVTexture",512,512,TEX_TYPE_CUBE_MAP,PF_FLOAT32_RGBA );
|
---|
31 |
|
---|
32 | this->cAURenderPhotonUVMapPass =
|
---|
33 | new CAURenderPhotonUVMapPass(mRoot,"PhotonUVMapTexture",512,512,TEX_TYPE_2D,PF_FLOAT32_RGBA);
|
---|
34 |
|
---|
35 | // Uses the other Pass created texture
|
---|
36 | cAURenderPhotonUVMapPass->changeTexture(cAURenderUVCubeMapPass->getRenderTextureName(),0);
|
---|
37 |
|
---|
38 |
|
---|
39 |
|
---|
40 | this->cAURenderUmbraPass =
|
---|
41 | new CAURenderUmbraPass(mRoot,"CubeMapLastTexture",512,512,TEX_TYPE_2D,PF_FLOAT32_RGBA);
|
---|
42 |
|
---|
43 | // Use the same texture (CubeMapLastTexture)
|
---|
44 | this->cAURenderPhotonHitMapPass =
|
---|
45 | new CAURenderPhotonHitMapPass(mRoot);
|
---|
46 |
|
---|
47 | // Use the same texture (CubeMapLastTexture)
|
---|
48 | this->cAURenderRefractObjectMapPass =
|
---|
49 | new CAURenderRefractObjectMapPass(mRoot);
|
---|
50 |
|
---|
51 | //g_pCubeMapTexture = TextureManager::getSingleton().load( cubeMapTexturePath,"Caustics");
|
---|
52 | //g_pPowerOfSnipetTexelTexture = TextureManager::getSingleton().load( cubeMapTexturePath,"Caustics");
|
---|
53 | //this->cAURenderPhotonHitMapPass->addRenderTarget(renderCubeMapLastPass->getRenderTexture());
|
---|
54 | //this->CubeMapLastPass=new CubeMapLastPass(CubeMapLastTextureNames,mRoot,"NO_RENDER_TARGET",1,1);
|
---|
55 | //TexturePtr fileTexture=TextureManager::getSingleton().load();
|
---|
56 | //cAURenderPhotonUVMapPass->changeTexture(fileTexture->getName(),1);
|
---|
57 | }
|
---|
58 |
|
---|
59 | void CausticMapRun::update()
|
---|
60 | {
|
---|
61 | cAURenderPhotonUVMapPass->update();
|
---|
62 | cAURenderUmbraPass->update();
|
---|
63 | cAURenderPhotonHitMapPass->update();
|
---|
64 | cAURenderRefractObjectMapPass->update();
|
---|
65 | }
|
---|
66 |
|
---|
67 | void CausticMapRun::init()
|
---|
68 | {
|
---|
69 | // Run just once
|
---|
70 | for( int i = 0; i< 6; i++ )
|
---|
71 | {
|
---|
72 | cAURenderColorDistanceCubeMapPass->clearRenderTargets();
|
---|
73 | cAURenderColorDistanceCubeMapPass->addRenderTarget(cAURenderColorDistanceCubeMapPass->getRenderTexture(),(CubeMapFaces)i);
|
---|
74 | cAURenderColorDistanceCubeMapPass->update();
|
---|
75 | cAURenderUVCubeMapPass->clearRenderTargets();
|
---|
76 | cAURenderUVCubeMapPass->addRenderTarget(cAURenderUVCubeMapPass->getRenderTexture(),(CubeMapFaces)i);
|
---|
77 | cAURenderUVCubeMapPass->update();
|
---|
78 | }
|
---|
79 | }
|
---|
80 |
|
---|
81 | const String& CausticMapRun::getResultTextureName()
|
---|
82 | {
|
---|
83 | return cAURenderPhotonHitMapPass->getMaterialName();
|
---|
84 | }
|
---|
85 |
|
---|
86 | CausticMapRun::~CausticMapRun()
|
---|
87 | {
|
---|
88 | SAFE_DELETE(cAURenderColorDistanceCubeMapPass);
|
---|
89 | SAFE_DELETE(cAURenderUVCubeMapPass);
|
---|
90 | SAFE_DELETE(cAURenderPhotonUVMapPass);
|
---|
91 | SAFE_DELETE(cAURenderUmbraPass);
|
---|
92 | SAFE_DELETE(cAURenderPhotonHitMapPass);
|
---|
93 | SAFE_DELETE(cAURenderRefractObjectMapPass);
|
---|
94 | }
|
---|