2017-11-08 01:44:49 +00:00
|
|
|
#ifndef COMPONENTS_SCENEUTIL_SHADOW_H
|
|
|
|
#define COMPONENTS_SCENEUTIL_SHADOW_H
|
2017-10-03 02:40:23 +00:00
|
|
|
|
2017-12-27 02:32:17 +00:00
|
|
|
#include <osgShadow/ShadowSettings>
|
2017-10-11 19:47:19 +00:00
|
|
|
#include <osgShadow/ViewDependentShadowMap>
|
2017-10-03 02:40:23 +00:00
|
|
|
|
2018-02-05 23:03:18 +00:00
|
|
|
#include <components/terrain/quadtreeworld.hpp>
|
2017-11-22 20:07:07 +00:00
|
|
|
#include <components/shader/shadermanager.hpp>
|
|
|
|
|
2017-11-08 01:44:49 +00:00
|
|
|
namespace SceneUtil
|
2017-10-03 02:40:23 +00:00
|
|
|
{
|
2018-02-26 14:29:31 +00:00
|
|
|
class ShadowManager : public osgShadow::ViewDependentShadowMap
|
2017-10-03 02:40:23 +00:00
|
|
|
{
|
2017-10-11 19:47:19 +00:00
|
|
|
public:
|
2017-12-27 02:32:17 +00:00
|
|
|
static void setupShadowSettings(osg::ref_ptr<osgShadow::ShadowSettings> settings, int castsShadowMask);
|
2017-11-07 00:32:04 +00:00
|
|
|
|
2017-12-27 02:32:17 +00:00
|
|
|
static void disableShadowsForStateSet(osg::ref_ptr<osg::StateSet> stateSet);
|
2017-10-11 19:47:19 +00:00
|
|
|
|
2018-02-26 14:29:31 +00:00
|
|
|
ShadowManager();
|
2017-11-05 14:46:03 +00:00
|
|
|
|
2018-01-02 16:39:05 +00:00
|
|
|
virtual void cull(osgUtil::CullVisitor& cv) override;
|
2017-11-22 20:07:07 +00:00
|
|
|
|
|
|
|
virtual Shader::ShaderManager::DefineMap getShadowDefines();
|
|
|
|
|
|
|
|
virtual Shader::ShaderManager::DefineMap getShadowsDisabledDefines();
|
2018-02-04 23:27:45 +00:00
|
|
|
|
|
|
|
class ComputeLightSpaceBounds : public osg::NodeVisitor, public osg::CullStack
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ComputeLightSpaceBounds(osg::Viewport* viewport, const osg::Matrixd& projectionMatrix, osg::Matrixd& viewMatrix);
|
|
|
|
|
|
|
|
void apply(osg::Node& node);
|
|
|
|
|
|
|
|
void apply(osg::Geode& node);
|
|
|
|
|
|
|
|
void apply(osg::Drawable& drawable);
|
|
|
|
|
2018-02-05 23:03:18 +00:00
|
|
|
void apply(Terrain::QuadTreeWorld& quadTreeWorld);
|
|
|
|
|
2018-02-04 23:27:45 +00:00
|
|
|
void apply(osg::Billboard&);
|
|
|
|
|
|
|
|
void apply(osg::Projection&);
|
|
|
|
|
|
|
|
void apply(osg::Transform& transform);
|
|
|
|
|
|
|
|
void apply(osg::Camera&);
|
|
|
|
|
|
|
|
void updateBound(const osg::BoundingBox& bb);
|
|
|
|
|
|
|
|
void update(const osg::Vec3& v);
|
|
|
|
|
|
|
|
osg::BoundingBox _bb;
|
|
|
|
};
|
2017-10-03 02:40:23 +00:00
|
|
|
protected:
|
2017-11-03 14:33:06 +00:00
|
|
|
const int debugTextureUnit;
|
|
|
|
|
2017-11-07 00:32:04 +00:00
|
|
|
std::vector<osg::ref_ptr<osg::Camera>> debugCameras;
|
2017-10-11 19:47:19 +00:00
|
|
|
|
|
|
|
osg::ref_ptr<osg::Program> debugProgram;
|
|
|
|
|
2017-11-07 00:32:04 +00:00
|
|
|
std::vector<osg::ref_ptr<osg::Node>> debugGeometry;
|
2017-12-27 02:32:17 +00:00
|
|
|
|
|
|
|
const int numberOfShadowMapsPerLight;
|
|
|
|
const bool enableShadows;
|
|
|
|
const bool debugHud;
|
|
|
|
|
|
|
|
const int baseShadowTextureUnit;
|
2017-10-03 02:40:23 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-11-08 01:44:49 +00:00
|
|
|
#endif //COMPONENTS_SCENEUTIL_SHADOW_H
|