Fix chameleon shadows

pull/578/head
AnyOldName3 5 years ago
parent 53b9b41159
commit a3b032bf2b

@ -16,6 +16,7 @@
#include <components/resource/scenemanager.hpp>
#include <components/resource/keyframemanager.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/misc/constants.hpp>
#include <components/misc/resourcehelpers.hpp>
@ -37,6 +38,8 @@
#include <components/settings/settings.hpp>
#include <components/shader/shadermanager.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/esmstore.hpp"
@ -502,8 +505,9 @@ namespace MWRender
class TransparencyUpdater : public SceneUtil::StateSetUpdater
{
public:
TransparencyUpdater(const float alpha)
TransparencyUpdater(const float alpha, osg::ref_ptr<osg::Uniform> shadowUniform)
: mAlpha(alpha)
, mShadowUniform(shadowUniform)
{
}
@ -517,6 +521,9 @@ namespace MWRender
{
osg::BlendFunc* blendfunc (new osg::BlendFunc);
stateset->setAttributeAndModes(blendfunc, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
// TODO: don't do this anymore once custom shadow renderbin is handling it
if (mShadowUniform)
stateset->addUniform(mShadowUniform);
// FIXME: overriding diffuse/ambient/emissive colors
osg::Material* material = new osg::Material;
@ -535,6 +542,7 @@ namespace MWRender
private:
float mAlpha;
osg::ref_ptr<osg::Uniform> mShadowUniform;
};
struct Animation::AnimSource
@ -1744,7 +1752,7 @@ namespace MWRender
{
if (mTransparencyUpdater == nullptr)
{
mTransparencyUpdater = new TransparencyUpdater(alpha);
mTransparencyUpdater = new TransparencyUpdater(alpha, mResourceSystem->getSceneManager()->getShaderManager().getShadowMapAlphaTestEnableUniform());
mObjectRoot->addUpdateCallback(mTransparencyUpdater);
}
else

@ -232,7 +232,7 @@ namespace Shader
{
if (!writableStateSet)
writableStateSet = getWritableStateSet(node);
// We probably shouldn't construct a new version of this each time as StateSets only use pointer comparison by default.
// We probably shouldn't construct a new version of this each time as Uniforms use pointer comparison for early-out.
// Also it should probably belong to the shader manager
writableStateSet->addUniform(new osg::Uniform("useDiffuseMapForShadowAlpha", true));
}

Loading…
Cancel
Save