mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 10:53:53 +00:00
Slightly better ripple normal blending. Not physically accurate at all, but looks good.
This commit is contained in:
parent
3772cd9257
commit
499f3ac0d1
4 changed files with 15 additions and 7 deletions
|
@ -20,7 +20,8 @@ RippleSimulation::RippleSimulation(Ogre::SceneManager* mainSceneManager)
|
|||
mTextureSize(512),
|
||||
mRippleAreaLength(1000),
|
||||
mImpulseSize(20),
|
||||
mTexelOffset(0,0)
|
||||
mTexelOffset(0,0),
|
||||
mFirstUpdate(true)
|
||||
{
|
||||
Ogre::AxisAlignedBox aabInf;
|
||||
aabInf.setInfinite();
|
||||
|
@ -106,7 +107,7 @@ void RippleSimulation::update(float dt, Ogre::Vector2 position)
|
|||
// try to keep 20 fps
|
||||
mTime += dt;
|
||||
|
||||
while (mTime >= 1/20.0)
|
||||
while (mTime >= 1/20.0 || mFirstUpdate)
|
||||
{
|
||||
mPreviousFrameOffset = mCurrentFrameOffset;
|
||||
|
||||
|
@ -130,7 +131,10 @@ void RippleSimulation::update(float dt, Ogre::Vector2 position)
|
|||
heightMapToNormalMap();
|
||||
|
||||
swapHeightMaps();
|
||||
if (!mFirstUpdate)
|
||||
mTime -= 1/20.0;
|
||||
else
|
||||
mFirstUpdate = false;
|
||||
}
|
||||
|
||||
sh::Factory::getInstance().setSharedParameter("rippleCenter", sh::makeProperty<sh::Vector3>(
|
||||
|
|
|
@ -34,6 +34,8 @@ private:
|
|||
float mRippleAreaLength;
|
||||
float mImpulseSize;
|
||||
|
||||
bool mFirstUpdate;
|
||||
|
||||
Ogre::Camera* mCamera;
|
||||
|
||||
// own scenemanager to render our simulation
|
||||
|
|
|
@ -401,7 +401,8 @@ void Water::update(float dt, Ogre::Vector3 player)
|
|||
|
||||
mRendering->getSkyManager ()->setGlareEnabled (!mIsUnderwater);
|
||||
|
||||
if (player.y <= mTop)
|
||||
/// \todo player.y is the scene node position (which is above the head) and not the feet position
|
||||
//if (player.y <= mTop)
|
||||
{
|
||||
mSimulation->addImpulse(Ogre::Vector2(player.x, player.z));
|
||||
}
|
||||
|
|
|
@ -120,8 +120,8 @@
|
|||
#define WAVE_SCALE 75 // overall wave scale
|
||||
|
||||
#define BUMP 1.5 // overall water surface bumpiness
|
||||
#define REFL_BUMP 0.16 // reflection distortion amount
|
||||
#define REFR_BUMP 0.12 // refraction distortion amount
|
||||
#define REFL_BUMP 0.08 // reflection distortion amount
|
||||
#define REFR_BUMP 0.06 // refraction distortion amount
|
||||
|
||||
#define SCATTER_AMOUNT 3.0 // amount of sunlight scattering
|
||||
#define SCATTER_COLOUR float3(0.0,1.0,0.95) // colour of sunlight scattering
|
||||
|
@ -232,7 +232,8 @@
|
|||
float3 normal_ripple = normalize(shSample(rippleNormalMap, relPos.xy).xyz * 2 - 1);
|
||||
normal_ripple = normal_ripple.xzy;
|
||||
|
||||
normal = normalize(normal + normal_ripple);
|
||||
//normal = normalize(normal + normal_ripple);
|
||||
normal = normalize(float3(normal.x + normal_ripple.x, normal.y, normal.z + normal_ripple.z));
|
||||
|
||||
|
||||
// normal for sunlight scattering
|
||||
|
|
Loading…
Reference in a new issue