Move Shadow to Components

pull/541/head
AnyOldName3 7 years ago
parent 1a30a917af
commit e201e359a9

@ -24,7 +24,6 @@ add_openmw_dir (mwrender
creatureanimation effectmanager util renderinginterface pathgrid rendermode weaponanimation
bulletdebugdraw globalmap characterpreview camera localmap water terrainstorage ripplesimulation
renderbin actoranimation landmanager
shadow
)
add_openmw_dir (mwinput

@ -15,6 +15,7 @@
#include <components/esm/loadcell.hpp>
#include <components/settings/settings.hpp>
#include <components/sceneutil/visitor.hpp>
#include <components/sceneutil/shadow.hpp>
#include <components/files/memorystream.hpp>
#include "../mwbase/environment.hpp"
@ -23,7 +24,6 @@
#include "../mwworld/cellstore.hpp"
#include "vismask.hpp"
#include "shadow.hpp"
namespace
{
@ -206,7 +206,7 @@ osg::ref_ptr<osg::Camera> LocalMap::createOrthographicCamera(float x, float y, f
fakeShadowMapImage->allocateImage(1, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT);
*(float*)fakeShadowMapImage->data() = -std::numeric_limits<float>::infinity(); // this has been tried both positive and negative
osg::ref_ptr<osg::Texture> fakeShadowMapTexture = new osg::Texture2D(fakeShadowMapImage);
for (int i = MWShadow::baseShadowTextureUnit; i < MWShadow::baseShadowTextureUnit + MWShadow::numberOfShadowMapsPerLight; ++i)
for (int i = SceneUtil::MWShadow::baseShadowTextureUnit; i < SceneUtil::MWShadow::baseShadowTextureUnit + SceneUtil::MWShadow::numberOfShadowMapsPerLight; ++i)
stateset->setTextureAttributeAndModes(i, fakeShadowMapTexture, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE | osg::StateAttribute::PROTECTED);
camera->addChild(lightSource);

@ -34,6 +34,7 @@
#include <components/sceneutil/workqueue.hpp>
#include <components/sceneutil/unrefqueue.hpp>
#include <components/sceneutil/writescene.hpp>
#include <components/sceneutil/shadow.hpp>
#include <components/terrain/terraingrid.hpp>
#include <components/terrain/quadtreeworld.hpp>
@ -52,7 +53,6 @@
#include "water.hpp"
#include "terrainstorage.hpp"
#include "util.hpp"
#include "shadow.hpp"
namespace MWRender
{
@ -210,9 +210,9 @@ namespace MWRender
settings->setReceivesShadowTraversalMask(~0u);
//settings->setShadowMapProjectionHint(osgShadow::ShadowSettings::PERSPECTIVE_SHADOW_MAP);
settings->setBaseShadowTextureUnit(MWShadow::baseShadowTextureUnit);
settings->setBaseShadowTextureUnit(SceneUtil::MWShadow::baseShadowTextureUnit);
//settings->setMinimumShadowMapNearFarRatio(0);
settings->setNumShadowMapsPerLight(MWShadow::numberOfShadowMapsPerLight);
settings->setNumShadowMapsPerLight(SceneUtil::MWShadow::numberOfShadowMapsPerLight);
//settings->setShadowMapProjectionHint(osgShadow::ShadowSettings::ORTHOGRAPHIC_SHADOW_MAP);
//settings->setMultipleShadowMapHint(osgShadow::ShadowSettings::PARALLEL_SPLIT); // ignored
//settings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_PRIMITIVES);
@ -224,7 +224,7 @@ namespace MWRender
int mapres = 2048;
settings->setTextureSize(osg::Vec2s(mapres,mapres));
MWShadow* tech = new MWShadow();
SceneUtil::MWShadow* tech = new SceneUtil::MWShadow();
shadowedScene->setShadowTechnique(tech);
/*tech->setMaxFarPlane(0);

@ -42,13 +42,13 @@
#include <components/sceneutil/statesetupdater.hpp>
#include <components/sceneutil/controller.hpp>
#include <components/sceneutil/visitor.hpp>
#include <components/sceneutil/shadow.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "vismask.hpp"
#include "renderbin.hpp"
#include "shadow.hpp"
namespace
{
@ -1124,7 +1124,7 @@ SkyManager::SkyManager(osg::Group* parentNode, Resource::SceneManager* sceneMana
// Assign empty program to specify we don't want shaders
// The shaders generated by the SceneManager can't handle everything we need
skyroot->getOrCreateStateSet()->setAttributeAndModes(new osg::Program(), osg::StateAttribute::OVERRIDE|osg::StateAttribute::PROTECTED|osg::StateAttribute::ON);
for (int i = MWShadow::baseShadowTextureUnit; i < MWShadow::baseShadowTextureUnit + MWShadow::numberOfShadowMapsPerLight; ++i)
for (int i = SceneUtil::MWShadow::baseShadowTextureUnit; i < SceneUtil::MWShadow::baseShadowTextureUnit + SceneUtil::MWShadow::numberOfShadowMapsPerLight; ++i)
skyroot->getOrCreateStateSet()->setTextureMode(i, GL_TEXTURE_2D, osg::StateAttribute::PROTECTED | osg::StateAttribute::OFF);
skyroot->setNodeMask(Mask_Sky);

@ -56,7 +56,7 @@ add_component_dir (shader
add_component_dir (sceneutil
clone attach visitor util statesetupdater controller skeleton riggeometry morphgeometry lightcontroller
lightmanager lightutil positionattitudetransform workqueue unrefqueue pathgridutil waterutil writescene serialize optimizer
lightmanager lightutil positionattitudetransform workqueue unrefqueue pathgridutil waterutil writescene serialize optimizer shadow
)
add_component_dir (nif

@ -7,7 +7,7 @@
#include <osgDB/FileUtils>
#include <osgDB/ReadFile>
namespace MWRender
namespace SceneUtil
{
using namespace osgShadow;

@ -1,9 +1,9 @@
#ifndef OPENMW_MWRENDER_SHADOW_H
#define OPENMW_MWRENDER_SHADOW_H
#ifndef COMPONENTS_SCENEUTIL_SHADOW_H
#define COMPONENTS_SCENEUTIL_SHADOW_H
#include <osgShadow/ViewDependentShadowMap>
namespace MWRender
namespace SceneUtil
{
class MWShadow : public osgShadow::ViewDependentShadowMap
{
@ -27,4 +27,4 @@ namespace MWRender
};
}
#endif //OPENMW_MWRENDER_SHADOW_H
#endif //COMPONENTS_SCENEUTIL_SHADOW_H

@ -11,7 +11,7 @@
#include <boost/filesystem/fstream.hpp>
#include <boost/algorithm/string.hpp>
#include "apps/openmw/mwrender/shadow.hpp"
#include "components/sceneutil/shadow.hpp"
namespace Shader
{
@ -108,7 +108,7 @@ namespace Shader
// set up shadows in the shader
// get these values from settings manager
bool shadows = true & !disableShadows;
int numShadowMaps = MWRender::MWShadow::numberOfShadowMapsPerLight;
int numShadowMaps = SceneUtil::MWShadow::numberOfShadowMapsPerLight;
DefineMap definesWithShadows;
if (shadows)
{

Loading…
Cancel
Save