From d485dd0782d95bca5f16a8841ca37c5677ea4efd Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 28 Oct 2015 19:11:32 +0100 Subject: [PATCH] Water: fix world UV coords --- apps/openmw/mwrender/water.cpp | 5 +++++ files/shaders/water_fragment.glsl | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 97e0df1b6..b56f21754 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -458,6 +458,11 @@ void Water::changeCell(const MWWorld::CellStore* store) mWaterNode->setPosition(getSceneNodeCoordinates(store->getCell()->mData.mX, store->getCell()->mData.mY)); else mWaterNode->setPosition(osg::Vec3f(0,0,mTop)); + + // create a new StateSet to prevent threading issues + osg::ref_ptr nodeStateSet (new osg::StateSet); + nodeStateSet->addUniform(new osg::Uniform("nodePosition", osg::Vec3f(mWaterNode->getPosition()))); + mWaterNode->setStateSet(nodeStateSet); } void Water::setHeight(const float height) diff --git a/files/shaders/water_fragment.glsl b/files/shaders/water_fragment.glsl index 994d74964..d7c0e1e6b 100644 --- a/files/shaders/water_fragment.glsl +++ b/files/shaders/water_fragment.glsl @@ -70,11 +70,11 @@ uniform float osg_SimulationTime; uniform float near; uniform float far; +uniform vec3 nodePosition; void main(void) { - // FIXME - vec3 worldPos = position.xyz; // ((wMat) * ( position)).xyz; + vec3 worldPos = position.xyz + nodePosition.xyz; vec2 UV = worldPos.xy / (8192.0*5.0) * 3.0; UV.y *= -1.0;