#pragma once //disable inheritance warning caused by multiple inheritance #if _WIN32 #if _MSC_VER #pragma warning(disable: 4250) #endif #endif #include "OgreRenderTechnique.h" #include "DepthShadowReceiverRenderTechnique.h" #include "Ogre.h" using namespace Ogre; /** @brief DepthShadowReceiverRenderTechnique used in an OGRE environment. This technique defines that the object will recieve shadows with the help of depth shadow maps. Each lightsource can have a depth map assigned to it. These are going to be refreshed only if shadow receivers are visible. It is the shadow receiver technique's resposibility to refresh them. The shadows from each light are calculated in separate passes. Each pass will modulate the shaded image, so thes should be the last passes (but before caustic passes). The given Pass* parameter n the constructor defines the pass after which new shadow recieving passes will be added by the technique. */ class __declspec( dllexport ) OgreDepthShadowReceiverRenderTechnique : public OgreRenderTechnique, public DepthShadowReceiverRenderTechnique { public: /** @brief Constructor. @param maxlights the maximum number of light sources to recieve shadow from @param shadowVertexProgram the vertex program to be used in the shadowing passes @param shadowFragmentProgram the fragment program to be used in the shadowing passes It should have one pass and the depth map of a light will be bound to the first sampler unit. @param WorldViewProjParamName the name of the gpu program parameter the world-view-projection matrix should be bound to @param WorldParamName the name of the gpu program parameter the world matrix should be bound to @param setLightViewMatrix bound light space view matrix to a gpu program parameter @param setLightViewProjMatrix bound light space view-projection matrix to a gpu program parameter @param setLightProjFarPlane bound light space projection far plane to a gpu program parameter @param lightViewProjParamName the name of the gpu program parameter the light space view-projection matrix should be bound to @param lightViewParamName the name of the gpu program parameter the light space view matrix should be bound to @param lightFarPlaneParamName the name of the gpu program parameter the light space projection far plane should be bound to @param passBlendingSRC source blend factor of the new passes @param passBlendingDEST destination blend factor of the new passes @param pass the pass after which shadowing passes should be added @param parentRenderable the object to operate on @param parentTechniqueGroup the TechniqueGroup this RenderedTechnique is attached to */ OgreDepthShadowReceiverRenderTechnique( int maxlights, String shadowVertexProgram, String shadowFragmentProgram, String WorldViewProjParamName, String WorldParamName, bool setLightViewMatrix, bool setLightViewProjMatrix, bool setLightProjFarPlane, String lightViewProjParamName, String lightViewParamName, String lightFarPlaneParamName, SceneBlendFactor passBlendingSRC, SceneBlendFactor passBlendingDEST, bool createNewPasses, int startTextureUnitID, bool nearestLightsFromCamera, bool bindToVertexShader, Pass* pass, OgreRenderable* parentRenderable, OgreTechniqueGroup* parentTechniqueGroup ); /** @brief Destructor. */ virtual ~OgreDepthShadowReceiverRenderTechnique(); //inherited virtual void update(unsigned long frameNum); protected: /** @brief the maximum number of light sources to recieve shadow from During update the nearest light sources will be found and used. */ int maxlights; /** @brief the vertex program to be used in the shadowing passes */ String shadowVertexProgram; /** @brief the fragment program to be used in the shadowing passes It should have one pass and the depth map of a light will be bound to the first sampler unit. */ String shadowFragmentProgram; /** @breif new passes created by this technique */ std::vector passes; /** @brief bound light space view matrix to a gpu program parameter */ bool setLightViewMatrix; /** @brief bound light space view-projection matrix to a gpu program parameter */ bool setLightViewProjMatrix; /** @brief bound light space projection far plane to a gpu program parameter */ bool setLightProjFarPlane; /** @brief the name of the gpu program parameter the light space view-projection matrix should be bound to */ String lightViewProjParamName; /** @brief the name of the gpu program parameter the light space view matrix should be bound to */ String lightViewParamName; /** @brief the name of the gpu program parameter the light space projection far plane should be bound to */ String lightFarPlaneParamName; /** @brief the name of the gpu program parameter the world-view-projection matrix should be bound to */ String WorldViewProjParamName; /** @brief the name of the gpu program parameter the world matrix should be bound to */ String WorldParamName; /** @brief source blend factor of the new passes */ SceneBlendFactor passBlendingSRC; /** @brief destination blend factor of the new passes */ SceneBlendFactor passBlendingDEST; bool createNewPasses; int startTextureUnitID; bool nearestLightsFromCamera; bool bindToVertexShader; }; /** @brief RenderTechniqueFactory to create OgreDepthShadowReceiverRenderTechnique instances. */ class __declspec( dllexport ) OgreDepthShadowReceiverRenderTechniqueFactory : public RenderTechniqueFactory { public: OgreDepthShadowReceiverRenderTechniqueFactory(); OgreRenderTechnique* createInstance(IllumTechniqueParams* params, Pass* pass, OgreRenderable* parentRenderable, OgreTechniqueGroup* parentTechniqueGroup); virtual bool needMaterialCopy(IllumTechniqueParams* params); int maxlights; String shadowVertexProgram; String shadowFragmentProgram; bool setLightViewMatrix; bool setLightViewProjMatrix; bool setLightProjFarPlane; String lightViewProjParamName; String lightViewParamName; String lightFarPlaneParamName; String WorldViewProjParamName; String WorldParamName; SceneBlendFactor passBlendingSRC; SceneBlendFactor passBlendingDEST; bool createNewPasses; int startTextureUnitID; bool nearestLightsFromCamera; bool bindToVertexShader; };