About Store Forum Documentation Contact



Post Reply 
Rendering Problem
Author Message
sydbod Offline
Member

Post: #16
Re: Rendering Problem
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.
08-29-2009 11:25 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #17
Re: Rendering Problem
when the next version of the engine will be available, please try setting Water.wave_scale=0; (this slightly increases precision for water for high viewport ratios)

and why do you have D.hwDepthBuffer(true); ?

Ive mentioned in the previous posts (code samples) :
Code:
D.hwDepthBuffer(false); // make sure hardware depth buffer is disabled
09-15-2009 05:30 PM
Find all posts by this user Quote this message in a reply
sydbod Offline
Member

Post: #18
Re: Rendering Problem
Quote:and why do you have D.hwDepthBuffer(true); ?

That must have been a moment of "BrainFade" for me ...... my apologies.

The sample is looking great now. smile
"float NearPlain=0.1, SplitPlain=30,FarPlain=300000;//Set rendering distances" is also working fine again. smile


With "D.hwDepthBuffer(false)", does that mean a software depth buffer is being used, and if so, what bit size is it ... or maybe can it be made 32bit or better still 64bit in size? :?:
09-16-2009 06:43 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #19
Re: Rendering Problem
Quote:With "D.hwDepthBuffer(false)", does that mean a software depth buffer is being used, and if so, what bit size is it ... or maybe can it be made 32bit or better still 64bit in size?
no, its not software, it's something else. when hwDepthBuffer is set to false, then additional F32 render target is used. they never are software because it is too slow, its wether to use 1 hw buffer, or 2 of them..
09-16-2009 11:02 AM
Find all posts by this user Quote this message in a reply
Post Reply