About Store Forum Documentation Contact
Donations:
158$/mo



Post Reply 
Draw mesh always behind world
Author Message
Kevin Offline
Member

Post: #1
Draw mesh always behind world
Hi,

Our game has a very big view range (up to 7km), and we decided to draw a lowpoly version of the terrain underneath the actual terrain. Well, this works really good, while we have huge view ranges the active world range is kept relatively small to take full advantage of EE world streaming.

Later we also want to add some lowpoly billboard-based forests, so it might happen that the lowpoly terrain is actually higher at some places than the EE terrain. In order to prevent seeing the lowpoly terrain on close range we want draw the lowpoly terrain always behind all of the world geometry (except the sky).

The lowpoly terrain is a simple Mesh and gets drawn explicitily in code. But so far I did not managed to get this working...

The desired draw order is:
Sky
Lowpoly Terrain
Game.World

I already noticed that I couldn't use the usual Renderer and disable depth writing for one draw call, because the draw calls in EE get delayed. With RM_BLEND it did not work because RM_BLEND seems to be called after RM_PREPARE (makes sense).

So I decided to make use of the background rendering feature of the engine:

Code:
D.clear(BLACK);
      
D.depthWrite(false);
_terrainMesh.draw(MatrixIdentity);  
D.depthWrite(true);

// Didn't work either:
//D.clearZ();
      
Renderer.combine = true;
Renderer(Render);  
Renderer.combine = false;

Why isn't that working? I am not quite sure how to achieve that the terrain gets rendered in front of the sky, but so far it doesn't even get rendererd behind the Game.World :(

So how long do draw calls get delayed? Is the reason why this isn't working, that the _terrainMesh gets added to a list and is rendered by the renderer (without depthwriter being disabled)? How do I prevent this from happening? Is there some kind of renderer flush method?

Does anyone have an idea how to get this working? Did I miss something?

Any help is greatly appreciated. smile

// Note: I am using EE 1.0
10-14-2013 11:43 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Draw mesh always behind world
Hi,

You could just try making the low poly mesh to be lower (so it's always below the high poly version in Y coordinates)

depthWrite will not work for many reasons, you won't get lighting in deferred mode, and you could get the low poly mesh to display as far faces get in front of the near faces.

Or you could cut out the part of the low poly mesh where the active areas are loaded.
10-16-2013 07:41 AM
Find all posts by this user Quote this message in a reply
Kevin Offline
Member

Post: #3
RE: Draw mesh always behind world
Okay, thank you for the information.

I will try using constructive solid geometry to dynamically cut out the parts where active terrain is loaded smile
10-16-2013 10:12 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Draw mesh always behind world
If the vertices are aligned to the area coordinates, then a simpler solution would be just removing those vertices inside the area rectangle. With some negative epsilon on the rectangle so you don't remove the border vertices
10-16-2013 10:44 PM
Find all posts by this user Quote this message in a reply
Post Reply