1 | #pragma once
|
---|
2 |
|
---|
3 | //disable inheritance warning caused by multiple inheritance
|
---|
4 | #if _WIN32
|
---|
5 | #if _MSC_VER
|
---|
6 | #pragma warning(disable: 4250)
|
---|
7 | #endif
|
---|
8 | #endif
|
---|
9 |
|
---|
10 | #include "OgreRenderTechnique.h"
|
---|
11 | #include "CausticReceiverRenderTechnique.h"
|
---|
12 | #include "Ogre.h"
|
---|
13 |
|
---|
14 | using namespace Ogre;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | @brief CausticReceiverRenderTechnique used in an OGRE environment.
|
---|
18 |
|
---|
19 | This technique defines that the object will recieve caustic lighting from caustic caster objects.
|
---|
20 | The caustic light spots will be calculated by the caustic caster's RenderingRuns.
|
---|
21 | These runs will only be updated if caustic redievers are visible, so it is the receiver technique's
|
---|
22 | responsibility to update them.
|
---|
23 |
|
---|
24 | Each caustic caster's light contribution will be added in separate passes. Each pass
|
---|
25 | will add some light to the shaded image, so these passes should be the last passes.
|
---|
26 | In the constructor the given Pass* parameter will be the pass after which the caustic lighting
|
---|
27 | passes will be added by the technique.
|
---|
28 | */
|
---|
29 | class OgreCausticReceiverRenderTechnique : public OgreRenderTechnique,
|
---|
30 | public CausticReceiverRenderTechnique
|
---|
31 | {
|
---|
32 | public:
|
---|
33 | /**
|
---|
34 | @brief Constructor.
|
---|
35 |
|
---|
36 | @param maxcasters the maximum number of caustic casters from which this receiver can recieve caustic light
|
---|
37 | @param causticVertexProgram the vertex program to be used in the caustic gathering passes
|
---|
38 | @param causticFragmentProgram the fragment program to be used in the caustic gathering passes.
|
---|
39 | It should have one pass and the caustic cubemap of a caster will be bound to the first sampler unit.
|
---|
40 | @param passBlendingSRC source blend factor of the new passes
|
---|
41 | @param passBlendingDEST destination blend factor of the new passes
|
---|
42 | @param pass the pass after which caustic gathering passes should be added
|
---|
43 | @param parentRenderable the object to operate on
|
---|
44 | @param parentTechniqueGroup the TechniqueGroup this RenderedTechnique is attached to
|
---|
45 | */
|
---|
46 | OgreCausticReceiverRenderTechnique(
|
---|
47 | int maxcasters,
|
---|
48 | String causticVertexProgram,
|
---|
49 | String causticFragmentProgram,
|
---|
50 | SceneBlendFactor passBlendingSRC,
|
---|
51 | SceneBlendFactor passBlendingDEST,
|
---|
52 | bool createNewPasses,
|
---|
53 | int startTextureUnitID,
|
---|
54 | String casterCenterVariableName,
|
---|
55 | String attenuationVariableName,
|
---|
56 | bool bindDistanceMap,
|
---|
57 | Pass* pass,
|
---|
58 | OgreRenderable* parentRenderable,
|
---|
59 | OgreTechniqueGroup* parentTechniqueGroup
|
---|
60 | );
|
---|
61 | /**
|
---|
62 | @brief Destructor.
|
---|
63 | */
|
---|
64 | virtual ~OgreCausticReceiverRenderTechnique();
|
---|
65 |
|
---|
66 | //inherited
|
---|
67 | virtual void update(unsigned long frameNum);
|
---|
68 |
|
---|
69 | protected:
|
---|
70 | /**
|
---|
71 | @brief the maximum number of caustic casters from which this receiver can recieve caustic light
|
---|
72 | */
|
---|
73 | int maxcasters;
|
---|
74 | /**
|
---|
75 | @brief the vertex program to be used in the caustic gathering passes
|
---|
76 | */
|
---|
77 | String causticVertexProgram;
|
---|
78 | /**
|
---|
79 | @brief the fragment program to be used in the caustic gathering passes
|
---|
80 |
|
---|
81 | It should have one pass and the caustic cubemap of a caster will be bound to the first sampler unit.
|
---|
82 | */
|
---|
83 | String causticFragmentProgram;
|
---|
84 | /**
|
---|
85 | @breif new passes created by this technique
|
---|
86 | */
|
---|
87 | std::vector<Pass*> passes;
|
---|
88 | /**
|
---|
89 | @brief the nearest caustic casters found during update
|
---|
90 | */
|
---|
91 | std::vector<OgreSharedRuns*> causticCasters;
|
---|
92 | /**
|
---|
93 | @brief source blend factor of the new passes
|
---|
94 | */
|
---|
95 | SceneBlendFactor passBlendingSRC;
|
---|
96 | /**
|
---|
97 | @brief destination blend factor of the new passes
|
---|
98 | */
|
---|
99 | SceneBlendFactor passBlendingDEST;
|
---|
100 | bool createNewPasses;
|
---|
101 | int startTextureUnitID;
|
---|
102 | String casterCenterVariableName;
|
---|
103 | String attenuationVariableName;
|
---|
104 | bool bindDistanceMap;
|
---|
105 | bool bindAttenuation;
|
---|
106 | };
|
---|
107 |
|
---|
108 | /**
|
---|
109 | @brief RenderTechniqueFactory to create OgreCausticReceiverRenderTechnique instances.
|
---|
110 | */
|
---|
111 | class OgreCausticReceiverRenderTechniqueFactory : public RenderTechniqueFactory
|
---|
112 | {
|
---|
113 | public:
|
---|
114 |
|
---|
115 | OgreCausticReceiverRenderTechniqueFactory();
|
---|
116 |
|
---|
117 | OgreRenderTechnique* createInstance(IllumTechniqueParams* params,
|
---|
118 | Pass* pass,
|
---|
119 | OgreRenderable* parentRenderable,
|
---|
120 | OgreTechniqueGroup* parentTechniqueGroup);
|
---|
121 |
|
---|
122 | virtual bool needMaterialCopy(IllumTechniqueParams* params){return true;}
|
---|
123 |
|
---|
124 | int maxcasters;
|
---|
125 | String causticVertexProgram;
|
---|
126 | String causticFragmentProgram;
|
---|
127 | SceneBlendFactor passBlendingSRC;
|
---|
128 | SceneBlendFactor passBlendingDEST;
|
---|
129 | bool createNewPasses;
|
---|
130 | int startTextureUnitID;
|
---|
131 | String casterCenterVariableName;
|
---|
132 | String attenuationVariableName;
|
---|
133 | bool bindDistanceMap;
|
---|
134 | };
|
---|
135 |
|
---|