1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-10 21:40:15 +00:00

Move Shadow to Components

This commit is contained in:
AnyOldName3 2017-11-08 01:44:49 +00:00
parent 1a30a917af
commit e201e359a9
8 changed files with 16 additions and 17 deletions

View File

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

View File

@ -15,6 +15,7 @@
#include <components/esm/loadcell.hpp> #include <components/esm/loadcell.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include <components/sceneutil/visitor.hpp> #include <components/sceneutil/visitor.hpp>
#include <components/sceneutil/shadow.hpp>
#include <components/files/memorystream.hpp> #include <components/files/memorystream.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
@ -23,7 +24,6 @@
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "vismask.hpp" #include "vismask.hpp"
#include "shadow.hpp"
namespace 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); 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 *(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); 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); stateset->setTextureAttributeAndModes(i, fakeShadowMapTexture, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE | osg::StateAttribute::PROTECTED);
camera->addChild(lightSource); camera->addChild(lightSource);

View File

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

View File

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

View File

@ -56,7 +56,7 @@ add_component_dir (shader
add_component_dir (sceneutil add_component_dir (sceneutil
clone attach visitor util statesetupdater controller skeleton riggeometry morphgeometry lightcontroller 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 add_component_dir (nif

View File

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

View File

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

View File

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