Sunday, November 6, 2016

Instanced Rendering Yields Forests

I've got crude code to use OpenGL instanced rendering working.  Each page measuring 2000 meters on a side has been populated with 150,000 trees.  There are 9 such pages being rendered each frame, for a total of 1,350,000 trees, and its running smoothly!  When making one rendering calls per tree using glDrawElements, a tenth that number of trees was causing the program to lag.  With instanced rendering, for each page I make a single call to glDrawElementsInstanced to render 150,000 trees, and all is smooth.

Possible areas to improve later today: slope and elevation awareness for object placement.  When mountains are tall enough (or far enough pole-ward) they tend to have a treeline, and elevation above which trees do not grow.  Also, trees tend to grow less commonly on the steepest portions of mountains, regardless of elevation or latitude.  Both of these properties should be fairly easy to implement.

Alas, there is yard work calling for my attention now, so I shall leave the virtual world alone for the moment and focus on the physical realm.

One hundred fifty thousand trees per 2 km x 2 km page of terrain

No comments:

Post a Comment