From dac1290597eb1af50854314ac7b8a8abe34a5b11 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 29 Jan 2015 22:59:38 +0100 Subject: [PATCH] Reduce size of water plane and increase subdivisions (Fixes #969) --- apps/openmw/mwrender/renderingmanager.cpp | 1 + apps/openmw/mwrender/water.cpp | 10 +++------- files/materials/water.shader | 11 ++++++----- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 149080d93..3ffd787c7 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -409,6 +409,7 @@ void RenderingManager::update (float duration, bool paused) mSkyManager->setGlare(mOcclusionQuery->getSunVisibility()); + mWater->changeCell(player.getCell()->getCell()); mWater->updateUnderwater(world->isUnderwater(player.getCell(), cam)); diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index fd790b363..9960b7b21 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -210,10 +210,10 @@ Water::Water (Ogre::Camera *camera, RenderingManager* rend) : mWaterPlane = Plane(Vector3::UNIT_Z, 0); - int waterScale = 300; + int waterScale = 30; MeshManager::getSingleton().createPlane("water", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, mWaterPlane, - CELL_SIZE*5*waterScale, CELL_SIZE*5*waterScale, 10, 10, true, 1, 3*waterScale,3*waterScale, Vector3::UNIT_Y); + CELL_SIZE*5*waterScale, CELL_SIZE*5*waterScale, 40, 40, true, 1, 3*waterScale,3*waterScale, Vector3::UNIT_Y); mWater = mSceneMgr->createEntity("water"); mWater->setVisibilityFlags(RV_Water); @@ -305,11 +305,7 @@ Water::~Water() void Water::changeCell(const ESM::Cell* cell) { - mTop = cell->mWater; - - setHeight(mTop); - - if(!(cell->mData.mFlags & cell->Interior)) + if(cell->isExterior()) mWaterNode->setPosition(getSceneNodeCoordinates(cell->mData.mX, cell->mData.mY)); } diff --git a/files/materials/water.shader b/files/materials/water.shader index a6f49e0a1..4dec57276 100644 --- a/files/materials/water.shader +++ b/files/materials/water.shader @@ -71,8 +71,6 @@ SH_BEGIN_PROGRAM shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix) - shVertexInput(float2, uv0) - shOutput(float2, UV) shOutput(float3, screenCoordsPassthrough) shOutput(float4, position) @@ -98,7 +96,6 @@ SH_START_PROGRAM { shOutputPosition = shMatrixMult(wvp, shInputPosition); - UV = uv0; #if !SH_GLSL @@ -187,7 +184,6 @@ } SH_BEGIN_PROGRAM - shInput(float2, UV) shInput(float3, screenCoordsPassthrough) shInput(float4, position) shInput(float, depthPassthrough) @@ -206,9 +202,10 @@ shSampler2D(depthMap) shSampler2D(normalMap) + shUniform(float4x4, wMat) @shAutoConstant(wMat, world_matrix) + #if RIPPLES shSampler2D(rippleNormalMap) - shUniform(float4x4, wMat) @shAutoConstant(wMat, world_matrix) #endif shUniform(float3, windDir_windSpeed) @shSharedParameter(windDir_windSpeed) @@ -251,6 +248,10 @@ SH_START_PROGRAM { + float3 worldPos = shMatrixMult (wMat, position).xyz; + float2 UV = worldPos.xy / (8192.0*5.0) * 3.0; + UV.y *= -1.0; + #if SHADOWS float shadow = depthShadowPCF (shadowMap0, lightSpacePos0, invShadowmapSize0); #endif