Board index FlightGear Development Scenery

Thousands of unnecessary triangles in Scenery 2.0 files?

Questions and discussion about enhancing and populating the FlightGear world.

Thousands of unnecessary triangles in Scenery 2.0 files?

Postby bschack » Thu Dec 05, 2013 7:29 pm

In the course modifying Atlas to work with the new scenery, I noticed that many triangles had two identical vertices - what I call "zero area triangles", or "ZATs" for short. Typically, 40% of triangles in a file are ZATs, which is a very significant number. Assuming that these are indeed superfluous, getting rid of them would save (1) disk space, (2) file loading time, and (3) GPU loading.

I modified Atlas to display these ZATs, drawing them as green lines. In the following image the area on the left is new scenery, the area on the right is old. You can see the new scenery is full of ZATs. The old scenery does have a few, in the airport (and I've noticed that the old scenery only seemed to have ZATs in airport files).

Image

(Go to http://postimg.org/image/d84hw0tnp/full/ for a full-sized version)

To give an idea of how they relate to "real" triangles (those that occupy space), here's the same place, but with real triangles drawn in red. The new scenery has far more triangles, not surprisingly. What's interesting is that the ZATs seem to span the regular triangles. Initially I thought ZATs would, say, be colinear with regular triangles, or somehow contained within them, but they're not. It's as if someone was drawing the triangles with a pen and weren't allowed to lift the pen from the paper.

Image

(Go to http://postimg.org/image/8lxt42kiv/full/ for the full-sized version)

Brian
Last edited by bschack on Thu Dec 05, 2013 9:51 pm, edited 1 time in total.
bschack
 
Posts: 195
Joined: Tue Jul 01, 2008 9:04 am

Re: Thousands of unnecessary triangles in Scenery 2.0 files?

Postby Crashpilot » Thu Dec 05, 2013 9:31 pm

In other words, it is possible to increase scenery quality even further by transforming insignificant ZATs into meanigful real surfaces with minimal (if any at all) further costs!?

And btw: If we are actually talking about 40%, the count is higher than thousands by magnitudes.
Crashpilot
 
Posts: 28
Joined: Tue Jan 29, 2008 9:38 pm
Location: Cologne

Re: Thousands of unnecessary triangles in Scenery 2.0 files?

Postby Johan G » Thu Dec 05, 2013 9:38 pm

Crashpilot wrote in Thu Dec 05, 2013 9:31 pm:...by transforming insignificant ZATs into meanigful real surfaces...

Unfortunately, looking at bschack's screenshot I would not consider that possible. :(
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Johan G
Moderator
 
Posts: 5437
Joined: Fri Aug 06, 2010 5:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 3.0.0
OS: Windows 7, 32 bit

Re: Thousands of unnecessary triangles in Scenery 2.0 files?

Postby alge » Thu Dec 05, 2013 10:04 pm

What's interesting is that the ZATs seem to span the regular triangles. Initially I thought ZATs would, say, be colinear with regular triangles, or somehow contained within them, but they're not. It's as if someone was drawing the triangles with a pen and weren't allowed to lift the pen from the paper.


My un-educated theory: It's "just" an artifact of using triangle strips (or something similar) for a fairly irregular mesh, so you have to do a lot of ZATs to jump to a new position for the next proper triangle. I assume it's using indexed drawing and hence not wasting time or space on the vertex data / processing itself, and the only "waste" would be the index storage and primitive set-up up to it can be culled because of identical vertices.

Crashpilot wrote in Thu Dec 05, 2013 9:31 pm:In other words, it is possible to increase scenery quality even further by transforming insignificant ZATs into meanigful real surfaces with minimal (if any at all) further costs!?


AFAICT, no:
1) If they re-use existing vertices, they don't really add the "quality" of the mesh.
2) The cost of these triangles should not be too big; these ZATs should be culled fairly early in the GPU pipe.
alge
 
Posts: 77
Joined: Thu Aug 30, 2012 12:45 am

Re: Thousands of unnecessary triangles in Scenery 2.0 files?

Postby psadro_gm » Fri Dec 06, 2013 2:44 am

That looks like a good find. We rely on CGAL for the triangulation and I've verified the winding of the triangles are all the same.

Look here
http://wiki.flightgear.org/FlightGear_World_Scenery_2.0

The last issue raised by i4dnf could be caused by this same issue. I'll have a look this weekend.

Thanks for noticing.

Pete
8.50 airport parser, textured roads and streams...
psadro_gm
 
Posts: 750
Joined: Thu Aug 25, 2011 2:23 am
Location: Atlanta, GA USA
IRC name: psadro_*
Version: git
OS: Fedora 21

Re: Thousands of unnecessary triangles in Scenery 2.0 files?

Postby psadro_gm » Fri Dec 06, 2013 1:56 pm

Confirmed. The issue is that when using CGAL's exact_construction kernel, we get a very precise triangulation. When we convert back to double, we get duplicate nodes because of roundoff. I now check each triangle for duplicate nodes before adding the triangle to the mesh. This has pretty much solved i4dnf's issue with the binormal and tangent vector generators as well. I'll submit this fix to tg-construct soon. We will need a couple more fixes before we rerun the scenery, though.

Thanks for sharing this info - It has saved me a lot of time looking into i4dnf's issue.
Pete
8.50 airport parser, textured roads and streams...
psadro_gm
 
Posts: 750
Joined: Thu Aug 25, 2011 2:23 am
Location: Atlanta, GA USA
IRC name: psadro_*
Version: git
OS: Fedora 21

Re: Thousands of unnecessary triangles in Scenery 2.0 files?

Postby f-ojac » Fri Dec 06, 2013 3:29 pm

Great. Thanks a lot too bschack, this will very probably solve bugs and give us back some more fps ;-)
--
If you want to support my Terrasync server, hosted on a private server, you can donate here: http://ns334561.ip-5-196-65.eu/WS2.0/WS ... 2.0.1.html
f-ojac
 
Posts: 1273
Joined: Fri Mar 07, 2008 9:50 am
Version: GIT
OS: GNU/Linux

Re: Thousands of unnecessary triangles in Scenery 2.0 files?

Postby Johan G » Mon Mar 24, 2014 1:38 pm

I would guess that this issue is being worked on, but what is the current status of it?
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Johan G
Moderator
 
Posts: 5437
Joined: Fri Aug 06, 2010 5:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 3.0.0
OS: Windows 7, 32 bit

Re: Thousands of unnecessary triangles in Scenery 2.0 files?

Postby psadro_gm » Mon Mar 24, 2014 1:49 pm

It has been fixed in terragear, and the base package KSFO scenery was generated with the fix.

New ws will also have the fix.
8.50 airport parser, textured roads and streams...
psadro_gm
 
Posts: 750
Joined: Thu Aug 25, 2011 2:23 am
Location: Atlanta, GA USA
IRC name: psadro_*
Version: git
OS: Fedora 21

Re: Thousands of unnecessary triangles in Scenery 2.0 files?

Postby Johan G » Mon Mar 24, 2014 2:05 pm

Thanks for the quick answer, and for the fix. :D
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Johan G
Moderator
 
Posts: 5437
Joined: Fri Aug 06, 2010 5:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 3.0.0
OS: Windows 7, 32 bit

Re: Thousands of unnecessary triangles in Scenery 2.0 files?

Postby hvengel » Mon Mar 24, 2014 3:10 pm

psadro_gm wrote in Mon Mar 24, 2014 1:49 pm:It has been fixed in terragear, and the base package KSFO scenery was generated with the fix.

New ws will also have the fix.


Does this mean that we will get the fix via terasync right now?
hvengel
Retired
 
Posts: 1128
Joined: Sun Dec 24, 2006 4:35 am
Location: Minden Nevada

Re: Thousands of unnecessary triangles in Scenery 2.0 files?

Postby Hooray » Mon Mar 24, 2014 3:19 pm

so we should then probably also update the deb/ppa packages ?
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11317
Joined: Tue Mar 25, 2008 8:40 am

Re: Thousands of unnecessary triangles in Scenery 2.0 files?

Postby Johan G » Mon Mar 24, 2014 4:01 pm

How big difference is there between the .btg files with and without the fix, i.e. is it significant?
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Johan G
Moderator
 
Posts: 5437
Joined: Fri Aug 06, 2010 5:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 3.0.0
OS: Windows 7, 32 bit

Re: Thousands of unnecessary triangles in Scenery 2.0 files?

Postby psadro_gm » Mon Mar 24, 2014 4:35 pm

hvengel: no the only terrain generated with the fix is the ksfo base package scenery - everything in terrasync has the bug
Hooray: the fix was committed January 24, 2014. I don't know when the packages were made.
Johan: I was going to compare, but never did. The number of triangles decreased in my test tiles by between 25% and 30%. perhaps a 20% reduction in btg size is possible. Note that the GPU driver likely tosses the triangles, so gpu memory won't be reduced, but we did see OSG choke on them when generating tangents and binormals.
8.50 airport parser, textured roads and streams...
psadro_gm
 
Posts: 750
Joined: Thu Aug 25, 2011 2:23 am
Location: Atlanta, GA USA
IRC name: psadro_*
Version: git
OS: Fedora 21

Re: Thousands of unnecessary triangles in Scenery 2.0 files?

Postby Thorsten » Mon Mar 24, 2014 6:33 pm

Note that the GPU driver likely tosses the triangles


Why would it do that? Several rendering techniques are based on sending degenerate meshes to the vertex pipeline, or to determine actual vertex position runtime based on other info.
Thorsten
 
Posts: 10643
Joined: Mon Nov 02, 2009 8:33 am

Next

Return to Scenery

Who is online

Users browsing this forum: No registered users and 1 guest