It looks like there are still problems.
The biggest problem in a flight sim happens when there is a shallow shore line on a land mass that is viewed from a large distance. The water/land joint jumps around very badly when the view point is moving.
The Z buffer resolution is just not good enough at those long distances because all the Z resolution is bunched up very close to the camera. (more so with the huge far/near frustum values being used)
The models are normally not so much of a problem because by the time they are in the very inaccurate area of the Z buffer values, they are too small to be visible.
I believe I have implemented your modification properly. Here is the code that I am using to check things out.(modified "Water.cpp" sample). Should it be of some help.
Code:
/******************************************************************************/
#include "stdafx.h"
/******************************************************************************/
MeshGroup terrain;
/******************************************************************************/
float NearPlain=1, SplitPlain=30,FarPlain=200000;//Set rendering distances
void InitPre()
{
App.name("Water");
App.flag=APP_FULL_TOGGLE;
IOPath("../data");
PakAdd("engine.pak");
D.mode(800,600);
ViewportFull.from=NearPlain;// set initial viewport near plain to 1 units
ViewportFull.range=FarPlain; // set initial viewport far plain to 200,000 units
D.full(true).ambPower(0.4).hpRt(true).hwDepthBuffer(true);
Cam.at.set(0,2,0);
Cam.pitch=-0.5;
Cam.dist =30;
Cam.yaw =2.8;
}
Bool Init()
{
terrain.load("obj/terrain/0.mshg"); // terrain
terrain.scale(Vec(1,10,1)).move(Vec(0,5,0)); // scale and move terrain vertically
Sky .set(); // sky
Suns.New().set(*Images("gfx/sky/sun.gfx")).light_color=1-D.ambPower(); // sun
Water.set(*Images("gfx/water/0.gfx"),*Images("gfx/water/0.n.gfx"),Images("gfx/fx/reflection.gfx")); // set water from textures
Water.wave_scale=0.8;
return true;
}
void Shut()
{
}
/******************************************************************************/
Bool Main()
{
if(Kb.bp(KB_ESC))return false;
CamHandle(0.01,500,CAMH_ZOOM|(Ms.b(1)?CAMH_MOVE:CAMH_ROT));
// here you can optionally set different water surface plane
if(Kb.b(KB_UP ))Water.plane(Water.plane() + Vec(0,1,0)*Tm.d()); // move water surface plane upwards
if(Kb.b(KB_DOWN))Water.plane(Water.plane() - Vec(0,1,0)*Tm.d()); // move water surface plane downwards
// update water waves movement
Water.update(Vec2(0.01,0.01));
return true;
}
/******************************************************************************/
void Render()
{
Viewport temp=ViewportActive; // get current viewport
switch(Renderer())
{
// When rendering water, an additional rendering mode has to be used
// RM_SOLID_M is "rendering solid in mirrors / water surfaces" mode
// for the most simplicity you can render the same things as in RM_SOLID mode
case RM_SOLID :
// Render under this mode as we don't want land to be reflected,
// speed is more important in a flight sim.
ViewportActive.from=SplitPlain; // limit rendering from SplitPlain to draw the "background"
ViewportActive.set();
terrain.draw(MatrixIdentity); // draw everything
D.clearZ(); // clear depth buffer
ViewportActive.from =NearPlain; // limit rendering from NearPlain to SplitPlain to draw the "foreground"
ViewportActive.range=SplitPlain;
ViewportActive.set();
terrain.draw(MatrixIdentity); // draw everything
temp.set(); // restore previous viewport
Renderer.rebuildDepth();// set Z-Buffer from F32 internal render target
case RM_SOLID_M:
//terrain.draw(MatrixIdentity);
break;
}
}
void Draw()
{
Renderer(Render);
D.text(0,0.9,S+"Fps "+Tm.fps());
D.text(0,0.8,"Press up/down keys to change water level");
}
/******************************************************************************/
EDIT: I have also noticed there is now a 200000/1 far to near ratio, if any larger then the water will no longer render.
In the earlier versions of the library I could use 300000/0.1 with water still rendering.