Skip to content

Commit

Permalink
Fix chameleon shadows
Browse files Browse the repository at this point in the history
  • Loading branch information
AnyOldName3 authored and psi29a committed May 8, 2020
1 parent dfe43a2 commit fb72c32
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions apps/openmw/mwrender/animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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"
Expand Down Expand Up @@ -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)
{
}

Expand All @@ -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;
Expand All @@ -535,6 +542,7 @@ namespace MWRender

private:
float mAlpha;
osg::ref_ptr<osg::Uniform> mShadowUniform;
};

struct Animation::AnimSource
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion components/shader/shadervisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit fb72c32

Please sign in to comment.