Horde3D

Next-Generation Graphics Engine
It is currently 22.11.2024, 13:12

All times are UTC + 1 hour




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Terrain
PostPosted: 12.03.2008, 21:31 
Offline

Joined: 17.02.2008, 21:08
Posts: 24
Location: Switzerland
I've just been checking out the Terrain extension. It looks great, and it's super fast!

However, it currently generates a lot of overdraw. I found a few improvements that made my GeForce 7600 Go a lot happier:

1: The geometry skirts are very big. I found that multiplying the skirt size by the eye distance to maintain an approximately constant screen-space size allowed much smaller skirts while still giving good results at larger distances.

2: Block rendering sequence is independant of camera position, sometimes resulting in a lot more back-to-front overdraw than is necessary. By trying to render in a more front-to-back order, depth culling can be a lot more effective.

3: (Not yet tested.) There's only one index buffer at the moment. If we use four instead, then they can traverse the geometry patch in different directions, and the renderer can pick the buffer with a mostly front-to-back sequence for the current camera location.

Some code for (1) and (2):

Code:
Index: terrain.cpp
===================================================================
--- terrain.cpp (revision 457)
+++ terrain.cpp (working copy)
@@ -136,7 +136,8 @@
                                        // Create skirt
                                        if( v == 0 || v == size - 1 || u == 0 || u == size - 1 )
                                        {
-                                               *vertHeight = maxf( *vertHeight - TerrainSkirtHeight, 0 );
+                                               float skirtHeight = TerrainSkirtHeight * dist;
+                                               *vertHeight = maxf( *vertHeight - skirtHeight, 0 );
                                        }
                                }
                        }
@@ -148,10 +149,26 @@
                else
                {
                        scale /= 2;
-                       drawTerrainBlock( terrain, minU, minV, halfU, halfV, level + 1, scale, localCamPos );
-                       drawTerrainBlock( terrain, halfU, minV, maxU, halfV, level + 1, scale, localCamPos );
-                       drawTerrainBlock( terrain, minU, halfV, halfU, maxV, level + 1, scale, localCamPos );
-                       drawTerrainBlock( terrain, halfU, halfV, maxU, maxV, level + 1, scale, localCamPos );
+                       Vec4f blocks[] =
+                       {
+                               Vec4f( minU, minV, halfU, halfV ),
+                               Vec4f( halfU, minV, maxU, halfV ),
+                               Vec4f( minU, halfV, halfU, maxV ),
+                               Vec4f( halfU, halfV, maxU, maxV )
+                       };
+                       // Sort blocks by distance from camera
+                       if( localCamPos.x > halfU )
+                       {
+                               std::swap( blocks[0], blocks[1] );
+                               std::swap( blocks[2], blocks[3] );
+                       }
+                       if( localCamPos.z > halfV )
+                       {
+                               std::swap( blocks[0], blocks[2] );
+                               std::swap( blocks[1], blocks[3] );
+                       }
+                       for( int b = 0; b < 4; ++b )
+                               drawTerrainBlock( terrain, blocks[b].x, blocks[b].y, blocks[b].z, blocks[b].w, level + 1, scale, localCamPos);
                }
        }


Much kudos to Volker for a clever and very fast system! I hope you can use these suggestions :)

Edit: Is it Volker's? I'm just guessing that from the credits line at the top including his name.


Top
 Profile  
Reply with quote  
 Post subject: Re: Terrain
PostPosted: 13.03.2008, 00:40 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
reiko wrote:
However, it currently generates a lot of overdraw. I found a few improvements that made my GeForce 7600 Go a lot happier:


Thanks a lot, I have already integrated the patch! These are very clever tricks. I like especially (1), it greatly reduces the size of the skirts and is so simple :)


reiko wrote:
Much kudos to Volker for a clever and very fast system! I hope you can use these suggestions :)

Edit: Is it Volker's? I'm just guessing that from the credits line at the top including his name.


The terrain extension is a joint project by Volker and me. We have done the core algorithm together with pair programming. We sometimes do this for complex code parts since it is fun and really more effective.

All in all I'm also very happy with the implementation. Especially the geometry analysis has a huge effect on quality and performance. I'm glad that we came up with the trick of linearizing the quadtree to get constant access time for the geometry complexity information.

As a little teaser, here is a screenshot from the upcoming sample.

Image


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 14.03.2008, 05:37 
Offline

Joined: 19.11.2007, 19:35
Posts: 218
Did I miss a memo? Is the extension stuff out? Or is this internal dev-talk?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 14.03.2008, 07:07 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
It's currently only in our SVN, but coming soon.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 14.03.2008, 09:30 
Offline

Joined: 19.11.2007, 19:35
Posts: 218
Whew..I was starting to question my sanity when I couldn't find any prior mentioning of a release.

Looks good though.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 14.03.2008, 14:23 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
Volker wrote:
It's currently only in our SVN, but coming soon.

Is public read-only access to the SVN a possibility?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 14.03.2008, 21:24 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Not yet, but Nicolas is going to migrate the page to Sourceforge in april, and I think then there will be a public readable SVN access.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 15.03.2008, 03:00 
Offline

Joined: 08.03.2008, 18:45
Posts: 23
:shock:

Good stuff!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 15.03.2008, 18:17 
Offline

Joined: 19.11.2007, 19:35
Posts: 218
I can already see my productivity dropping when that new toy comes out.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 16.03.2008, 17:09 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
Volker wrote:
Not yet, but Nicolas is going to migrate the page to Sourceforge in april, and I think then there will be a public readable SVN access.

Cool, I already have a sourceforge account.


Top
 Profile  
Reply with quote  
 Post subject: Re: Terrain
PostPosted: 12.04.2008, 23:23 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
I have the wireframe working now for the terrain, but still these glitches. Any idea what might be causing them?

Click for full size image
Image

I would also be grateful if someone could post a screen-shot of the terrain (normal, not wireframe), and also in debug mode (I only get a bounding box), so that I can see what it should look like...

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
 Post subject: Re: Terrain
PostPosted: 13.04.2008, 03:22 
Offline

Joined: 19.03.2008, 01:22
Posts: 79
swiftcoder wrote:
I would also be grateful if someone could post a screen-shot of the terrain (normal, not wireframe), and also in debug mode (I only get a bounding box), so that I can see what it should look like...


Here's what it should look like normally and in debug.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group