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 "DepthShadowRecieverRenderTechnique.h"
|
---|
12 | #include "Ogre.h"
|
---|
13 |
|
---|
14 | using namespace Ogre;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | @brief DepthShadowRecieverRenderTechnique 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 recievers are visible. It is the shadow reciever 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 OgreDepthShadowRecieverRenderTechnique : public OgreRenderTechnique,
|
---|
31 | public DepthShadowRecieverRenderTechnique
|
---|
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 pass the pass after which shadowing passes should be added
|
---|
42 | @param parentRenderable the object to operate on
|
---|
43 | @param parentTechniqueGroup the TechniqueGroup this RenderedTechnique is attached to
|
---|
44 | */
|
---|
45 | OgreDepthShadowRecieverRenderTechnique(
|
---|
46 | int maxlights,
|
---|
47 | String shadowVertexProgram,
|
---|
48 | String shadowFragmentProgram,
|
---|
49 | bool setLightViewMatrix,
|
---|
50 | bool setLightViewProjMatrix,
|
---|
51 | bool setLightProjFarPlane,
|
---|
52 | String lightViewProjParamName,
|
---|
53 | String lightViewParamName,
|
---|
54 | String lightFarPlaneParamName,
|
---|
55 | Pass* pass,
|
---|
56 | OgreRenderable* parentRenderable,
|
---|
57 | OgreTechniqueGroup* parentTechniqueGroup
|
---|
58 | );
|
---|
59 | /**
|
---|
60 | @brief Destructor.
|
---|
61 | */
|
---|
62 | ~OgreDepthShadowRecieverRenderTechnique();
|
---|
63 |
|
---|
64 | //inherited
|
---|
65 | virtual void update(unsigned long frameNum);
|
---|
66 |
|
---|
67 | protected:
|
---|
68 | /**
|
---|
69 | @brief the maximum number of light sources to recieve shadow from
|
---|
70 |
|
---|
71 | During update the nearest light sources will be found and used.
|
---|
72 | */
|
---|
73 | int maxlights;
|
---|
74 | /**
|
---|
75 | @brief the vertex program to be used in the shadowing passes
|
---|
76 | */
|
---|
77 | String shadowVertexProgram;
|
---|
78 | /**
|
---|
79 | @brief the fragment program to be used in the shadowing passes
|
---|
80 |
|
---|
81 | It should have one pass and the depth map of a light will be bound to the first sampler unit.
|
---|
82 | */
|
---|
83 | String shadowFragmentProgram;
|
---|
84 | /**
|
---|
85 | @breif new passes created by this technique
|
---|
86 | */
|
---|
87 | std::vector<Pass*> passes;
|
---|
88 | bool setLightViewMatrix;
|
---|
89 | bool setLightViewProjMatrix;
|
---|
90 | bool setLightProjFarPlane;
|
---|
91 | String lightViewProjParamName;
|
---|
92 | String lightViewParamName;
|
---|
93 | String lightFarPlaneParamName;
|
---|
94 | };
|
---|
95 |
|
---|
96 |
|
---|
97 | class OgreDepthShadowRecieverRenderTechniqueFactory : public RenderTechniqueFactory
|
---|
98 | {
|
---|
99 | public:
|
---|
100 |
|
---|
101 | OgreDepthShadowRecieverRenderTechniqueFactory();
|
---|
102 |
|
---|
103 | OgreRenderTechnique* createInstance(IllumTechniqueParams* params,
|
---|
104 | Pass* pass,
|
---|
105 | OgreRenderable* parentRenderable,
|
---|
106 | OgreTechniqueGroup* parentTechniqueGroup);
|
---|
107 |
|
---|
108 |
|
---|
109 | int maxlights;
|
---|
110 | String shadowVertexProgram;
|
---|
111 | String shadowFragmentProgram;
|
---|
112 | bool setLightViewMatrix;
|
---|
113 | bool setLightViewProjMatrix;
|
---|
114 | bool setLightProjFarPlane;
|
---|
115 | String lightViewProjParamName;
|
---|
116 | String lightViewParamName;
|
---|
117 | String lightFarPlaneParamName;
|
---|
118 |
|
---|
119 | };
|
---|
120 |
|
---|