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