source: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.h @ 2397

Revision 2397, 6.4 KB checked in by szirmay, 17 years ago (diff)
Line 
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
14using 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*/
30class OgreDepthShadowReceiverRenderTechnique : public OgreRenderTechnique,
31                                                                                public DepthShadowReceiverRenderTechnique
32{
33public:
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                                                        Pass* pass,
73                                                        OgreRenderable* parentRenderable,
74                                                        OgreTechniqueGroup* parentTechniqueGroup
75                                                        );
76        /**
77                @brief Destructor.
78        */
79        virtual ~OgreDepthShadowReceiverRenderTechnique();
80       
81        //inherited
82        virtual void update(unsigned long frameNum);
83       
84protected:     
85        /**
86                @brief  the maximum number of light sources to recieve shadow from
87
88                During update the nearest light sources will be found and used.
89        */
90        int maxlights;
91        /**
92                @brief the vertex program to be used in the shadowing passes
93        */
94        String shadowVertexProgram;
95        /**
96                @brief the fragment program to be used in the shadowing passes
97                                                                               
98                It should have one pass and the depth map of a light will be bound to the first sampler unit.
99        */
100        String shadowFragmentProgram;
101        /**
102                @breif new passes created by this technique
103        */
104        std::vector<Pass*> passes;
105        /**
106                @brief bound light space view matrix to a gpu program parameter
107        */
108        bool setLightViewMatrix;
109        /**
110                @brief bound light space view-projection matrix to a gpu program parameter
111        */
112        bool setLightViewProjMatrix;
113        /**
114                @brief bound light space projection far plane to a gpu program parameter
115        */
116        bool setLightProjFarPlane;
117        /**
118                @brief the name of the gpu program parameter the light space view-projection matrix should be bound to
119        */
120        String lightViewProjParamName;
121        /**
122                @brief the name of the gpu program parameter the light space view matrix should be bound to
123        */
124        String lightViewParamName;
125        /**
126                @brief the name of the gpu program parameter the light space projection far plane should be bound to
127        */
128        String lightFarPlaneParamName;
129        /**
130                @brief the name of the gpu program parameter the world-view-projection matrix should be bound to
131        */     
132        String WorldViewProjParamName;
133        /**
134                @brief the name of the gpu program parameter the world matrix should be bound to
135        */
136        String WorldParamName;
137        /**
138                @brief source blend factor of the new passes
139        */
140        SceneBlendFactor passBlendingSRC;
141        /**
142                @brief destination blend factor of the new passes
143        */
144        SceneBlendFactor passBlendingDEST;     
145        bool createNewPasses;
146        int startTextureUnitID;
147        bool nearestLightsFromCamera;
148};
149
150/**
151        @brief RenderTechniqueFactory to create OgreDepthShadowReceiverRenderTechnique instances.
152*/
153class OgreDepthShadowReceiverRenderTechniqueFactory : public RenderTechniqueFactory
154{
155public:
156       
157        OgreDepthShadowReceiverRenderTechniqueFactory();
158
159        OgreRenderTechnique* createInstance(IllumTechniqueParams* params,
160                                                                                Pass* pass,
161                                                                                OgreRenderable* parentRenderable,
162                                                                                OgreTechniqueGroup* parentTechniqueGroup);
163
164        virtual bool needMaterialCopy(IllumTechniqueParams* params);
165
166        int maxlights;
167        String shadowVertexProgram;
168        String shadowFragmentProgram;
169        bool setLightViewMatrix;
170        bool setLightViewProjMatrix;
171        bool setLightProjFarPlane;
172        String lightViewProjParamName;
173        String lightViewParamName;
174        String lightFarPlaneParamName;
175        String WorldViewProjParamName;
176        String WorldParamName;
177        SceneBlendFactor passBlendingSRC;
178        SceneBlendFactor passBlendingDEST;
179        bool createNewPasses;
180        int startTextureUnitID;
181        bool nearestLightsFromCamera;
182};
183
Note: See TracBrowser for help on using the repository browser.