Skip to content

Commit

Permalink
Merge branch 'first_person_mesh_distortion' into 'master'
Browse files Browse the repository at this point in the history
Fix distortion breaking in first person meshes

See merge request OpenMW/openmw!4231
  • Loading branch information
psi29a committed Jul 6, 2024
2 parents 6bb10ed + 4d7e9ba commit e8c4226
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions apps/openmw/mwrender/distortion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <osg/FrameBufferObject>

#include "postprocessor.hpp"

namespace MWRender
{
void DistortionCallback::drawImplementation(
Expand All @@ -10,6 +12,11 @@ namespace MWRender
osg::State* state = renderInfo.getState();
size_t frameId = state->getFrameStamp()->getFrameNumber() % 2;

PostProcessor* postProcessor = dynamic_cast<PostProcessor*>(renderInfo.getCurrentCamera()->getUserData());

if (!postProcessor || bin->getStage()->getFrameBufferObject() != postProcessor->getPrimaryFbo(frameId))
return;

mFBO[frameId]->apply(*state);

const osg::Texture* tex
Expand Down
3 changes: 2 additions & 1 deletion components/sceneutil/extradata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ namespace SceneUtil

osg::StateSet* stateset = node.getOrCreateStateSet();

stateset->setRenderBinDetails(14, "Distortion", osg::StateSet::OVERRIDE_RENDERBIN_DETAILS);
stateset->setNestRenderBins(false);
stateset->setRenderBinDetails(14, "Distortion", osg::StateSet::OVERRIDE_PROTECTED_RENDERBIN_DETAILS);
stateset->addUniform(new osg::Uniform("distortionStrength", distortionStrength));

stateset->setAttributeAndModes(depth, osg::StateAttribute::ON);
Expand Down

0 comments on commit e8c4226

Please sign in to comment.