mirror of
https://github.com/OpenMW/openmw.git
synced 2026-01-03 15:13:07 +00:00
Improve high wind speed rain/snow behavior (#8864)
Enable water ripples and wrap-around Remove rain particle angle random element Simplify disabling rain ripples
This commit is contained in:
parent
dbcedf614d
commit
dec8a284aa
6 changed files with 8 additions and 32 deletions
|
|
@ -897,9 +897,7 @@ namespace MWRender
|
|||
|
||||
mResourceSystem->getSceneManager()->getShaderManager().update(*mViewer);
|
||||
|
||||
float rainIntensity = mSky->getPrecipitationAlpha();
|
||||
mWater->setRainIntensity(rainIntensity);
|
||||
mWater->setRainRipplesEnabled(mSky->getRainRipplesEnabled());
|
||||
mWater->setRainIntensity(mSky->getRainRipplesEnabled() ? mSky->getPrecipitationAlpha() : 0.f);
|
||||
|
||||
mWater->update(dt, paused);
|
||||
if (!paused)
|
||||
|
|
|
|||
|
|
@ -517,7 +517,7 @@ namespace MWRender
|
|||
|
||||
bool SkyManager::getRainRipplesEnabled() const
|
||||
{
|
||||
if (!mEnabled || mIsStorm)
|
||||
if (!mEnabled)
|
||||
return false;
|
||||
|
||||
if (hasRain())
|
||||
|
|
@ -531,10 +531,7 @@ namespace MWRender
|
|||
|
||||
float SkyManager::getPrecipitationAlpha() const
|
||||
{
|
||||
if (mEnabled && !mIsStorm && (hasRain() || mParticleNode))
|
||||
return mPrecipitationAlpha;
|
||||
|
||||
return 0.f;
|
||||
return mPrecipitationAlpha;
|
||||
}
|
||||
|
||||
void SkyManager::update(float duration)
|
||||
|
|
@ -729,7 +726,7 @@ namespace MWRender
|
|||
= static_cast<osgParticle::ParticleSystem*>(findPSVisitor.mFoundNodes[i]);
|
||||
|
||||
osg::ref_ptr<osgParticle::ModularProgram> program = new osgParticle::ModularProgram;
|
||||
if (!mIsStorm)
|
||||
if (occlusionEnabledForEffect)
|
||||
program->addOperator(new WrapAroundOperator(mCamera, defaultWrapRange));
|
||||
program->addOperator(new WeatherAlphaOperator(mPrecipitationAlpha, false));
|
||||
program->setParticleSystem(ps);
|
||||
|
|
|
|||
|
|
@ -1146,7 +1146,7 @@ namespace MWRender
|
|||
void RainShooter::shoot(osgParticle::Particle* particle) const
|
||||
{
|
||||
particle->setVelocity(mVelocity);
|
||||
particle->setAngle(osg::Vec3f(-mAngle, 0, (Misc::Rng::rollProbability() * 2 - 1) * osg::PIf));
|
||||
particle->setAngle(osg::Vec3f(-mAngle, 0.f, 0.f));
|
||||
}
|
||||
|
||||
void RainShooter::setVelocity(const osg::Vec3f& velocity)
|
||||
|
|
|
|||
|
|
@ -212,22 +212,15 @@ namespace MWRender
|
|||
class RainSettingsUpdater : public SceneUtil::StateSetUpdater
|
||||
{
|
||||
public:
|
||||
RainSettingsUpdater()
|
||||
: mRainIntensity(0.f)
|
||||
, mEnableRipples(false)
|
||||
{
|
||||
}
|
||||
RainSettingsUpdater() = default;
|
||||
|
||||
void setRainIntensity(float rainIntensity) { mRainIntensity = rainIntensity; }
|
||||
void setRipplesEnabled(bool enableRipples) { mEnableRipples = enableRipples; }
|
||||
|
||||
protected:
|
||||
void setDefaults(osg::StateSet* stateset) override
|
||||
{
|
||||
osg::ref_ptr<osg::Uniform> rainIntensityUniform = new osg::Uniform("rainIntensity", 0.0f);
|
||||
stateset->addUniform(rainIntensityUniform.get());
|
||||
osg::ref_ptr<osg::Uniform> enableRainRipplesUniform = new osg::Uniform("enableRainRipples", false);
|
||||
stateset->addUniform(enableRainRipplesUniform.get());
|
||||
}
|
||||
|
||||
void apply(osg::StateSet* stateset, osg::NodeVisitor* /*nv*/) override
|
||||
|
|
@ -235,14 +228,10 @@ namespace MWRender
|
|||
osg::ref_ptr<osg::Uniform> rainIntensityUniform = stateset->getUniform("rainIntensity");
|
||||
if (rainIntensityUniform != nullptr)
|
||||
rainIntensityUniform->set(mRainIntensity);
|
||||
osg::ref_ptr<osg::Uniform> enableRainRipplesUniform = stateset->getUniform("enableRainRipples");
|
||||
if (enableRainRipplesUniform != nullptr)
|
||||
enableRainRipplesUniform->set(mEnableRipples);
|
||||
}
|
||||
|
||||
private:
|
||||
float mRainIntensity;
|
||||
bool mEnableRipples;
|
||||
float mRainIntensity{ 0.f };
|
||||
};
|
||||
|
||||
class Refraction : public SceneUtil::RTTNode
|
||||
|
|
@ -807,12 +796,6 @@ namespace MWRender
|
|||
mRainSettingsUpdater->setRainIntensity(rainIntensity);
|
||||
}
|
||||
|
||||
void Water::setRainRipplesEnabled(bool enableRipples)
|
||||
{
|
||||
if (mRainSettingsUpdater)
|
||||
mRainSettingsUpdater->setRipplesEnabled(enableRipples);
|
||||
}
|
||||
|
||||
void Water::update(float dt, bool paused)
|
||||
{
|
||||
if (!paused)
|
||||
|
|
|
|||
|
|
@ -114,7 +114,6 @@ namespace MWRender
|
|||
void changeCell(const MWWorld::CellStore* store);
|
||||
void setHeight(const float height);
|
||||
void setRainIntensity(const float rainIntensity);
|
||||
void setRainRipplesEnabled(bool enableRipples);
|
||||
|
||||
void update(float dt, bool paused);
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ uniform float near;
|
|||
uniform float far;
|
||||
|
||||
uniform float rainIntensity;
|
||||
uniform bool enableRainRipples;
|
||||
|
||||
uniform vec2 screenRes;
|
||||
|
||||
|
|
@ -112,7 +111,7 @@ void main(void)
|
|||
|
||||
vec4 rainRipple;
|
||||
|
||||
if (rainIntensity > 0.01 && enableRainRipples)
|
||||
if (rainIntensity > 0.01)
|
||||
rainRipple = rainCombined(position.xy/1000.0, waterTimer) * clamp(rainIntensity, 0.0, 1.0);
|
||||
else
|
||||
rainRipple = vec4(0.0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue