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 "DepthShadowReceiverRenderTechnique.h"
|
---|
12 | #include "Ogre.h"
|
---|
13 |
|
---|
14 | using namespace Ogre;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | @brief DepthShadowReceiverRenderTechnique used in an OGRE environment.
|
---|
18 |
|
---|
19 | This technique defines that the object will recieve shadows with the help of depth shadow maps.
|
---|
20 | Each lightsource can have a depth map assigned to it. These are going to be refreshed only
|
---|
21 | if shadow receivers are visible. It is the shadow receiver technique's resposibility
|
---|
22 | to refresh them.
|
---|
23 |
|
---|
24 | The shadows from each light are calculated in separate passes. Each pass will
|
---|
25 | modulate the shaded image, so thes should be the last passes (but before caustic passes).
|
---|
26 | The given Pass* parameter n the constructor defines the pass after which new
|
---|
27 | shadow recieving passes will be added by the technique.
|
---|
28 |
|
---|
29 | */
|
---|
30 | class OgreDepthShadowReceiverRenderTechnique : public OgreRenderTechnique,
|
---|
31 | public DepthShadowReceiverRenderTechnique
|
---|
32 | {
|
---|
33 | public:
|
---|
34 | /**
|
---|
35 | @brief Constructor.
|
---|
36 |
|
---|
37 | @param maxlights the maximum number of light sources to recieve shadow from
|
---|
38 | @param shadowVertexProgram the vertex program to be used in the shadowing passes
|
---|
39 | @param shadowFragmentProgram the fragment program to be used in the shadowing passes
|
---|
40 | It should have one pass and the depth map of a light will be bound to the first sampler unit.
|
---|
41 | @param WorldViewProjParamName the name of the gpu program parameter the world-view-projection matrix should be bound to
|
---|
42 | @param WorldParamName the name of the gpu program parameter the world matrix should be bound to
|
---|
43 | @param setLightViewMatrix bound light space view matrix to a gpu program parameter
|
---|
44 | @param setLightViewProjMatrix bound light space view-projection matrix to a gpu program parameter
|
---|
45 | @param setLightProjFarPlane bound light space projection far plane to a gpu program parameter
|
---|
46 | @param lightViewProjParamName the name of the gpu program parameter the light space view-projection matrix should be bound to
|
---|
47 | @param lightViewParamName the name of the gpu program parameter the light space view matrix should be bound to
|
---|
48 | @param lightFarPlaneParamName the name of the gpu program parameter the light space projection far plane should be bound to
|
---|
49 | @param passBlendingSRC source blend factor of the new passes
|
---|
50 | @param passBlendingDEST destination blend factor of the new passes
|
---|
51 | @param pass the pass after which shadowing passes should be added
|
---|
52 | @param parentRenderable the object to operate on
|
---|
53 | @param parentTechniqueGroup the TechniqueGroup this RenderedTechnique is attached to
|
---|
54 | */
|
---|
55 | OgreDepthShadowReceiverRenderTechnique(
|
---|
56 | int maxlights,
|
---|
57 | String shadowVertexProgram,
|
---|
58 | String shadowFragmentProgram,
|
---|
59 | String WorldViewProjParamName,
|
---|
60 | String WorldParamName,
|
---|
61 | bool setLightViewMatrix,
|
---|
62 | bool setLightViewProjMatrix,
|
---|
63 | bool setLightProjFarPlane,
|
---|
64 | String lightViewProjParamName,
|
---|
65 | String lightViewParamName,
|
---|
66 | String lightFarPlaneParamName,
|
---|
67 | SceneBlendFactor passBlendingSRC,
|
---|
68 | SceneBlendFactor passBlendingDEST,
|
---|
69 | bool createNewPasses,
|
---|
70 | int startTextureUnitID,
|
---|
71 | bool nearestLightsFromCamera,
|
---|
72 | bool bindToVertexShader,
|
---|
73 | Pass* pass,
|
---|
74 | OgreRenderable* parentRenderable,
|
---|
75 | OgreTechniqueGroup* parentTechniqueGroup
|
---|
76 | );
|
---|
77 | /**
|
---|
78 | @brief Destructor.
|
---|
79 | */
|
---|
80 | virtual ~OgreDepthShadowReceiverRenderTechnique();
|
---|
81 |
|
---|
82 | //inherited
|
---|
83 | virtual void update(unsigned long frameNum);
|
---|
84 |
|
---|
85 | protected:
|
---|
86 | /**
|
---|
87 | @brief the maximum number of light sources to recieve shadow from
|
---|
88 |
|
---|
89 | During update the nearest light sources will be found and used.
|
---|
90 | */
|
---|
91 | int maxlights;
|
---|
92 | /**
|
---|
93 | @brief the vertex program to be used in the shadowing passes
|
---|
94 | */
|
---|
95 | String shadowVertexProgram;
|
---|
96 | /**
|
---|
97 | @brief the fragment program to be used in the shadowing passes
|
---|
98 |
|
---|
99 | It should have one pass and the depth map of a light will be bound to the first sampler unit.
|
---|
100 | */
|
---|
101 | String shadowFragmentProgram;
|
---|
102 | /**
|
---|
103 | @breif new passes created by this technique
|
---|
104 | */
|
---|
105 | std::vector<Pass*> passes;
|
---|
106 | /**
|
---|
107 | @brief bound light space view matrix to a gpu program parameter
|
---|
108 | */
|
---|
109 | bool setLightViewMatrix;
|
---|
110 | /**
|
---|
111 | @brief bound light space view-projection matrix to a gpu program parameter
|
---|
112 | */
|
---|
113 | bool setLightViewProjMatrix;
|
---|
114 | /**
|
---|
115 | @brief bound light space projection far plane to a gpu program parameter
|
---|
116 | */
|
---|
117 | bool setLightProjFarPlane;
|
---|
118 | /**
|
---|
119 | @brief the name of the gpu program parameter the light space view-projection matrix should be bound to
|
---|
120 | */
|
---|
121 | String lightViewProjParamName;
|
---|
122 | /**
|
---|
123 | @brief the name of the gpu program parameter the light space view matrix should be bound to
|
---|
124 | */
|
---|
125 | String lightViewParamName;
|
---|
126 | /**
|
---|
127 | @brief the name of the gpu program parameter the light space projection far plane should be bound to
|
---|
128 | */
|
---|
129 | String lightFarPlaneParamName;
|
---|
130 | /**
|
---|
131 | @brief the name of the gpu program parameter the world-view-projection matrix should be bound to
|
---|
132 | */
|
---|
133 | String WorldViewProjParamName;
|
---|
134 | /**
|
---|
135 | @brief the name of the gpu program parameter the world matrix should be bound to
|
---|
136 | */
|
---|
137 | String WorldParamName;
|
---|
138 | /**
|
---|
139 | @brief source blend factor of the new passes
|
---|
140 | */
|
---|
141 | SceneBlendFactor passBlendingSRC;
|
---|
142 | /**
|
---|
143 | @brief destination blend factor of the new passes
|
---|
144 | */
|
---|
145 | SceneBlendFactor passBlendingDEST;
|
---|
146 | bool createNewPasses;
|
---|
147 | int startTextureUnitID;
|
---|
148 | bool nearestLightsFromCamera;
|
---|
149 | bool bindToVertexShader;
|
---|
150 | };
|
---|
151 |
|
---|
152 | /**
|
---|
153 | @brief RenderTechniqueFactory to create OgreDepthShadowReceiverRenderTechnique instances.
|
---|
154 | */
|
---|
155 | class OgreDepthShadowReceiverRenderTechniqueFactory : public RenderTechniqueFactory
|
---|
156 | {
|
---|
157 | public:
|
---|
158 |
|
---|
159 | OgreDepthShadowReceiverRenderTechniqueFactory();
|
---|
160 |
|
---|
161 | OgreRenderTechnique* createInstance(IllumTechniqueParams* params,
|
---|
162 | Pass* pass,
|
---|
163 | OgreRenderable* parentRenderable,
|
---|
164 | OgreTechniqueGroup* parentTechniqueGroup);
|
---|
165 |
|
---|
166 | virtual bool needMaterialCopy(IllumTechniqueParams* params);
|
---|
167 |
|
---|
168 | int maxlights;
|
---|
169 | String shadowVertexProgram;
|
---|
170 | String shadowFragmentProgram;
|
---|
171 | bool setLightViewMatrix;
|
---|
172 | bool setLightViewProjMatrix;
|
---|
173 | bool setLightProjFarPlane;
|
---|
174 | String lightViewProjParamName;
|
---|
175 | String lightViewParamName;
|
---|
176 | String lightFarPlaneParamName;
|
---|
177 | String WorldViewProjParamName;
|
---|
178 | String WorldParamName;
|
---|
179 | SceneBlendFactor passBlendingSRC;
|
---|
180 | SceneBlendFactor passBlendingDEST;
|
---|
181 | bool createNewPasses;
|
---|
182 | int startTextureUnitID;
|
---|
183 | bool nearestLightsFromCamera;
|
---|
184 | bool bindToVertexShader;
|
---|
185 | };
|
---|
186 |
|
---|